| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2013 ForgeRock AS |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.replication.common.StatusMachineEvent; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.replication.common.ServerStatus.*; |
| | | import static org.opends.server.replication.common.StatusMachineEvent.*; |
| | | |
| | |
| | | { |
| | | |
| | | private volatile boolean shutdown = false; |
| | | |
| | | /** |
| | | * The tracer object for the debug logger. |
| | | */ |
| | | private static final DebugTracer TRACER = getTracer(); |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | private final ReplicationServerDomain replicationServerDomain; |
| | | private volatile int degradedStatusThreshold = -1; |
| | |
| | | @Override |
| | | public void run() |
| | | { |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | TRACER.debugInfo( |
| | | logger.trace( |
| | | getMessage("Directory server status analyzer starting.")); |
| | | } |
| | | |
| | |
| | | catch (InterruptedException e) |
| | | { |
| | | // Server shutdown monitor may interrupt slow threads. |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | } |
| | | logger.traceException(e); |
| | | shutdown = true; |
| | | break; |
| | | } |
| | |
| | | { |
| | | // Get number of pending changes for this server |
| | | int nChanges = serverHandler.getRcvMsgQueueSize(); |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | TRACER.debugInfo(getMessage("Status analyzer: DS " |
| | | logger.trace(getMessage("Status analyzer: DS " |
| | | + serverHandler.getServerId() + " has " + nChanges |
| | | + " message(s) in writer queue.")); |
| | | } |
| | |
| | | } |
| | | |
| | | done = true; |
| | | TRACER.debugInfo(getMessage("Status analyzer is terminated.")); |
| | | logger.trace(getMessage("Status analyzer is terminated.")); |
| | | } |
| | | |
| | | private String getMessage(String message) |
| | |
| | | if (replicationServerDomain.changeStatus(serverHandler, event)) |
| | | { |
| | | // Finish job and let thread die |
| | | TRACER.debugInfo( |
| | | logger.trace( |
| | | getMessage("Status analyzer has been interrupted and will die.")); |
| | | return true; |
| | | } |
| | |
| | | shutdown = true; |
| | | shutdownLock.notifyAll(); |
| | | |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | TRACER.debugInfo(getMessage("Shutting down status analyzer.")); |
| | | logger.trace(getMessage("Shutting down status analyzer.")); |
| | | } |
| | | } |
| | | } |
| | |
| | | n++; |
| | | if (n >= FACTOR) |
| | | { |
| | | TRACER.debugInfo(getMessage("Interrupting status analyzer.")); |
| | | logger.trace(getMessage("Interrupting status analyzer.")); |
| | | interrupt(); |
| | | } |
| | | } |
| | |
| | | */ |
| | | public void setDegradedStatusThreshold(int degradedStatusThreshold) |
| | | { |
| | | if (debugEnabled()) |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | TRACER.debugInfo(getMessage( |
| | | logger.trace(getMessage( |
| | | "Directory server status analyzer changing threshold value to " |
| | | + degradedStatusThreshold)); |
| | | } |