| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | |
| | | public class StatusAnalyzer extends DirectoryThread |
| | | { |
| | | |
| | | private boolean finished = false; |
| | | private volatile boolean shutdown = false; |
| | | |
| | | /** |
| | | * The tracer object for the debug logger. |
| | | */ |
| | | private static final DebugTracer TRACER = getTracer(); |
| | | |
| | | private ReplicationServerDomain replicationServerDomain; |
| | | private int degradedStatusThreshold = -1; |
| | | private final ReplicationServerDomain replicationServerDomain; |
| | | private volatile int degradedStatusThreshold = -1; |
| | | |
| | | // Sleep time for the thread, in ms. |
| | | private int STATUS_ANALYZER_SLEEP_TIME = 5000; |
| | | private static final int STATUS_ANALYZER_SLEEP_TIME = 5000; |
| | | |
| | | private boolean done = false; |
| | | private volatile boolean done = false; |
| | | |
| | | private Object sleeper = new Object(); |
| | | private final Object shutdownLock = new Object(); |
| | | |
| | | /** |
| | | * Create a StatusAnalyzer. |
| | |
| | | } |
| | | |
| | | boolean interrupted = false; |
| | | while (!finished && !interrupted) |
| | | while (!shutdown && !interrupted) |
| | | { |
| | | try |
| | | { |
| | | synchronized (sleeper) |
| | | synchronized (shutdownLock) |
| | | { |
| | | sleeper.wait(STATUS_ANALYZER_SLEEP_TIME); |
| | | if (!shutdown) |
| | | { |
| | | shutdownLock.wait(STATUS_ANALYZER_SLEEP_TIME); |
| | | } |
| | | } |
| | | } catch (InterruptedException ex) |
| | | { |
| | |
| | | */ |
| | | public void shutdown() |
| | | { |
| | | if (debugEnabled()) |
| | | synchronized (shutdownLock) |
| | | { |
| | | TRACER.debugInfo("Shutting down status analyzer for dn " + |
| | | replicationServerDomain.getBaseDn().toString() + " in RS " + |
| | | replicationServerDomain.getReplicationServer().getServerId()); |
| | | } |
| | | finished = true; |
| | | synchronized (sleeper) |
| | | { |
| | | sleeper.notify(); |
| | | shutdown = true; |
| | | shutdownLock.notifyAll(); |
| | | |
| | | if (debugEnabled()) |
| | | { |
| | | TRACER.debugInfo("Shutting down status analyzer for dn " |
| | | + replicationServerDomain.getBaseDn().toString() + " in RS " |
| | | + replicationServerDomain.getReplicationServer().getServerId()); |
| | | } |
| | | } |
| | | } |
| | | |