From a6be5db964ffa77a68b91966d99f6fa0b36b532e Mon Sep 17 00:00:00 2001
From: gbellato <gbellato@localhost>
Date: Tue, 29 May 2007 09:27:46 +0000
Subject: [PATCH] Fix for 1561 : ReplicationDomain.disable() should wait for all threads to die be fore returning
---
opends/src/server/org/opends/server/replication/server/ServerReader.java | 63 ++++++++++++++++++++++++++-----
1 files changed, 53 insertions(+), 10 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/server/ServerReader.java b/opends/src/server/org/opends/server/replication/server/ServerReader.java
index 3c72463..41fb483 100644
--- a/opends/src/server/org/opends/server/replication/server/ServerReader.java
+++ b/opends/src/server/org/opends/server/replication/server/ServerReader.java
@@ -29,6 +29,8 @@
import static org.opends.server.loggers.ErrorLogger.logError;
import static org.opends.server.messages.MessageHandler.getMessage;
import static org.opends.server.messages.ReplicationMessages.*;
+import static org.opends.server.loggers.debug.DebugLogger.*;
+
import java.io.IOException;
@@ -45,6 +47,7 @@
import org.opends.server.replication.protocol.WindowMessage;
import org.opends.server.types.ErrorLogCategory;
import org.opends.server.types.ErrorLogSeverity;
+import org.opends.server.loggers.debug.DebugTracer;
/**
@@ -59,6 +62,11 @@
*/
public class ServerReader extends DirectoryThread
{
+ /**
+ * The tracer object for the debug logger.
+ */
+ private static final DebugTracer TRACER = getTracer();
+
private short serverId;
private ProtocolSession session;
private ServerHandler handler;
@@ -87,8 +95,18 @@
*/
public void run()
{
+ if (debugEnabled())
+ {
+ if (handler.isReplicationServer())
+ {
+ TRACER.debugInfo("Replication server reader starting " + serverId);
+ }
+ else
+ {
+ TRACER.debugInfo("LDAP server reader starting " + serverId);
+ }
+ }
/*
- * TODO : catch exceptions in case of bugs
* wait on input stream
* grab all incoming messages and publish them to the replicationCache
*/
@@ -98,12 +116,6 @@
{
ReplicationMessage msg = session.receive();
- if (msg == null)
- {
- // TODO : generate error in the log
- // make sure that connection is closed
- return;
- }
if (msg instanceof AckMessage)
{
AckMessage ack = (AckMessage) msg;
@@ -147,7 +159,19 @@
ErrorMessage errorMsg = (ErrorMessage) msg;
handler.process(errorMsg);
}
-
+ else if (msg == null)
+ {
+ /*
+ * The remote server has sent an unknown message,
+ * close the conenction.
+ */
+ int msgID = MSGID_READER_NULL_MSG;
+ String message = getMessage(msgID, handler.toString());
+ logError(ErrorLogCategory.SYNCHRONIZATION,
+ ErrorLogSeverity.SEVERE_ERROR,
+ message, msgID);
+ return;
+ }
}
} catch (IOException e)
{
@@ -160,7 +184,7 @@
String message = getMessage(msgID, handler.toString());
logError(ErrorLogCategory.SYNCHRONIZATION,
ErrorLogSeverity.NOTICE,
- message, msgID);
+ message + e.getMessage(), msgID);
} catch (ClassNotFoundException e)
{
/*
@@ -174,7 +198,15 @@
message, msgID);
} catch (Exception e)
{
-
+ /*
+ * The remote server has sent an unknown message,
+ * close the conenction.
+ */
+ int msgID = MSGID_READER_EXCEPTION;
+ String message = getMessage(msgID, handler.toString());
+ logError(ErrorLogCategory.SYNCHRONIZATION,
+ ErrorLogSeverity.SEVERE_ERROR,
+ message, msgID);
}
finally
{
@@ -192,5 +224,16 @@
}
replicationCache.stopServer(handler);
}
+ if (debugEnabled())
+ {
+ if (handler.isReplicationServer())
+ {
+ TRACER.debugInfo("Replication server reader stopping " + serverId);
+ }
+ else
+ {
+ TRACER.debugInfo("LDAP server reader stopping " + serverId);
+ }
+ }
}
}
--
Gitblit v1.10.0