From a733cedcf54ab0b979f7f1b762d086e49bd59d72 Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Tue, 27 Oct 2009 09:34:04 +0000
Subject: [PATCH] Fix for issue 4316 : Replication takes too much time to shutdown
---
opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java | 62 ++++++++++++++++++++-----------
1 files changed, 40 insertions(+), 22 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java b/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
index d41ee2c..4ef072c 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
@@ -808,7 +808,7 @@
cn.toString(), baseDn));
mb.append(stackTraceToSingleLineString(e));
logError(mb.toMessage());
- stopServer(origServer);
+ stopServer(origServer, false);
}
// Mark the ack info object as completed to prevent potential timeout
// code parallel run
@@ -887,7 +887,7 @@
cn.toString(), baseDn));
mb.append(stackTraceToSingleLineString(e));
logError(mb.toMessage());
- stopServer(origServer);
+ stopServer(origServer, false);
}
// Increment assured counters
boolean safeRead =
@@ -979,25 +979,28 @@
for (ReplicationServerHandler handler : replicationServers.values())
{
if (replServers.contains(handler.getServerAddressURL()))
- stopServer(handler);
+ stopServer(handler, false);
}
}
/**
* Stop operations with all servers this domain is connected with (RS and DS).
+ *
+ * @param shutdown A boolean indicating if the stop is due to a
+ * shutdown condition.
*/
- public void stopAllServers()
+ public void stopAllServers(boolean shutdown)
{
// Close session with other replication servers
for (ReplicationServerHandler serverHandler : replicationServers.values())
{
- stopServer(serverHandler);
+ stopServer(serverHandler, shutdown);
}
// Close session with other LDAP servers
for (DataServerHandler serverHandler : directoryServers.values())
{
- stopServer(serverHandler);
+ stopServer(serverHandler, shutdown);
}
}
@@ -1026,9 +1029,11 @@
/**
* Stop operations with a given server.
*
- * @param handler the server for which we want to stop operations
+ * @param handler the server for which we want to stop operations.
+ * @param shutdown A boolean indicating if the stop is due to a
+ * shutdown condition.
*/
- public void stopServer(ServerHandler handler)
+ public void stopServer(ServerHandler handler, boolean shutdown)
{
if (debugEnabled())
TRACER.debugInfo(
@@ -1049,9 +1054,13 @@
{
try
{
+
// Acquire lock on domain (see more details in comment of start()
// method of ServerHandler)
- lock();
+ if (!shutdown)
+ {
+ lock();
+ }
} catch (InterruptedException ex)
{
// Try doing job anyway...
@@ -1066,9 +1075,12 @@
// Check if generation id has to be reset
mayResetGenerationId();
- // Warn our DSs that a RS or DS has quit (does not use this
- // handler as already removed from list)
- buildAndSendTopoInfoToDSs(null);
+ if (!shutdown)
+ {
+ // Warn our DSs that a RS or DS has quit (does not use this
+ // handler as already removed from list)
+ buildAndSendTopoInfoToDSs(null);
+ }
}
} else
{
@@ -1093,10 +1105,13 @@
mayResetGenerationId();
// Update the remote replication servers with our list
// of connected LDAP servers
- buildAndSendTopoInfoToRSs();
- // Warn our DSs that a RS or DS has quit (does not use this
- // handler as already removed from list)
- buildAndSendTopoInfoToDSs(null);
+ if (!shutdown)
+ {
+ buildAndSendTopoInfoToRSs();
+ // Warn our DSs that a RS or DS has quit (does not use this
+ // handler as already removed from list)
+ buildAndSendTopoInfoToDSs(null);
+ }
}
else if (otherHandlers.contains(handler))
{
@@ -1113,7 +1128,10 @@
}
finally
{
- release();
+ if (!shutdown)
+ {
+ release();
+ }
}
}
}
@@ -1710,7 +1728,7 @@
mb2.append(ERR_CHANGELOG_ERROR_SENDING_ERROR.get(this.toString()));
mb2.append(stackTraceToSingleLineString(ioe));
logError(mb2.toMessage());
- stopServer(senderHandler);
+ stopServer(senderHandler, false);
}
} else
{
@@ -1746,8 +1764,8 @@
// an error happened on the sender session trying to recover
// from an error on the receiver session.
// We don't have much solution left beside closing the sessions.
- stopServer(senderHandler);
- stopServer(targetHandler);
+ stopServer(senderHandler, false);
+ stopServer(targetHandler, false);
}
// TODO Handle error properly (sender timeout in addition)
}
@@ -1766,7 +1784,7 @@
// Terminate the assured timer
assuredTimeoutTimer.cancel();
- stopAllServers();
+ stopAllServers(true);
stopDbHandlers();
}
@@ -3163,7 +3181,7 @@
{
TRACER.debugCaught(DebugLogLevel.ERROR, e);
logError(ERR_CHANGELOG_ERROR_SENDING_MSG.get(rsHandler.getName()));
- stopServer(rsHandler);
+ stopServer(rsHandler, false);
}
}
}
--
Gitblit v1.10.0