From 56b6935e2ca8870820294a9c45dd3a88117a355b Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 20 May 2014 13:56:59 +0000
Subject: [PATCH] Code cleanup.
---
opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java | 42 +++++++++++++-----------------------------
1 files changed, 13 insertions(+), 29 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java b/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
index 0b2401b..3e74946 100644
--- a/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
+++ b/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -220,7 +220,7 @@
private boolean solveConflictFlag = true;
private final InternalClientConnection conn = getRootConnection();
- private volatile boolean shutdown = false;
+ private final AtomicBoolean shutdown = new AtomicBoolean();
private volatile boolean disabled = false;
private volatile boolean stateSavingDisabled = false;
@@ -264,7 +264,7 @@
*/
/** Holds the fractional configuration for this domain, if any. */
- private FractionalConfig fractionalConfig;
+ private final FractionalConfig fractionalConfig;
/**
* The list of attributes that cannot be used in fractional replication
@@ -380,11 +380,6 @@
private class RSUpdater extends DirectoryThread
{
private final CSN startCSN;
- /**
- * Used to communicate that the current thread computation needs to
- * shutdown.
- */
- private AtomicBoolean shutdown = new AtomicBoolean(false);
protected RSUpdater(CSN replServerMaxCSN)
{
@@ -398,8 +393,8 @@
@Override
public void run()
{
- // Replication server is missing some of our changes: let's
- // send them to him.
+ // Replication server is missing some of our changes:
+ // let's send them to him.
logger.trace(DEBUG_GOING_TO_SEARCH_FOR_CHANGES);
/*
@@ -408,7 +403,7 @@
*/
try
{
- if (buildAndPublishMissingChanges(startCSN, broker, shutdown))
+ if (buildAndPublishMissingChanges(startCSN, broker))
{
logger.trace(DEBUG_CHANGES_SENT);
synchronized(replayOperations)
@@ -427,7 +422,8 @@
*/
logger.error(ERR_CANNOT_RECOVER_CHANGES, getBaseDNString());
}
- } catch (Exception e)
+ }
+ catch (Exception e)
{
/*
* An error happened trying to search for the updates
@@ -446,17 +442,8 @@
rsUpdater.compareAndSet(this, null);
}
}
-
- /** {@inheritDoc} */
- @Override
- public void initiateShutdown()
- {
- this.shutdown.set(true);
- super.initiateShutdown();
- }
}
-
/**
* Creates a new ReplicationDomain using configuration from configEntry.
*
@@ -823,7 +810,7 @@
*/
static class AttributeValueStringIterator implements Iterator<String>
{
- private Iterator<ByteString> attrValIt;
+ private final Iterator<ByteString> attrValIt;
/**
* Creates a new AttributeValueStringIterator object.
@@ -2261,9 +2248,8 @@
*/
public void shutdown()
{
- if (!shutdown)
+ if (shutdown.compareAndSet(false, true))
{
- shutdown = true;
final RSUpdater rsUpdater = this.rsUpdater.get();
if (rsUpdater != null)
{
@@ -2286,7 +2272,7 @@
disableService();
}
- // wait for completion of the persistentServerState thread.
+ // wait for completion of the ServerStateFlush thread.
try
{
while (!done)
@@ -4134,14 +4120,12 @@
* The CSN where we need to start the search
* @param session
* The session to use to publish the changes
- * @param shutdown
- * whether the current run must be stopped
* @return A boolean indicating he success of the operation.
* @throws Exception
* if an Exception happens during the search.
*/
- boolean buildAndPublishMissingChanges(CSN startCSN,
- ReplicationBroker session, AtomicBoolean shutdown) throws Exception
+ boolean buildAndPublishMissingChanges(CSN startCSN, ReplicationBroker session)
+ throws Exception
{
// Trim the changes in replayOperations that are older than the startCSN.
synchronized (replayOperations)
@@ -4654,7 +4638,7 @@
/**
* Base DN the fractional configuration is for.
*/
- private DN baseDN;
+ private final DN baseDN;
/**
* Constructs a new fractional configuration object.
--
Gitblit v1.10.0