From de49bcea2eb82b047ed99e5dae2190389e2a79e4 Mon Sep 17 00:00:00 2001
From: Chris Ridd <chris.ridd@forgerock.com>
Date: Mon, 15 Apr 2013 15:42:45 +0000
Subject: [PATCH] Fix OPENDJ-867 Cannot enable debug logging in ReplicationBroker
---
opends/src/server/org/opends/server/replication/service/ReplicationBroker.java | 81 +++++++++++++++++-----------------------
1 files changed, 34 insertions(+), 47 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java b/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
index 769eb10..346e137 100644
--- a/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
+++ b/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
@@ -29,6 +29,7 @@
import static org.opends.messages.ReplicationMessages.*;
import static org.opends.server.loggers.ErrorLogger.logError;
+import static org.opends.server.loggers.debug.DebugLogger.debugEnabled;
import static org.opends.server.loggers.debug.DebugLogger.getTracer;
import static org.opends.server.util.StaticUtils.*;
@@ -55,10 +56,8 @@
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-import org.opends.messages.Category;
import org.opends.messages.Message;
import org.opends.messages.MessageBuilder;
-import org.opends.messages.Severity;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.replication.common.ChangeNumber;
import org.opends.server.replication.common.DSInfo;
@@ -888,9 +887,9 @@
* out which one is the best to connect to.
*/
if (debugEnabled())
- debugInfo("serverId: " + serverId +
- " phase 1 : will perform PhaseOneH with each RS in " +
- " order to elect the preferred one");
+ TRACER.debugInfo("serverId: " + serverId
+ + " phase 1 : will perform PhaseOneH with each RS in "
+ + " order to elect the preferred one");
// Get info from every available replication servers
replicationServerInfos = collectReplicationServersInfo();
@@ -905,9 +904,9 @@
// Best found, now initialize connection to this one (handshake phase 1)
if (debugEnabled())
- debugInfo("serverId: " + serverId +
- " phase 2 : will perform PhaseOneH with the preferred RS="
- + electedRsInfo);
+ TRACER.debugInfo("serverId: " + serverId
+ + " phase 2 : will perform PhaseOneH with the preferred RS="
+ + electedRsInfo);
electedRsInfo = performPhaseOneHandshake(
electedRsInfo.getServerURL(), true, false);
@@ -1139,9 +1138,9 @@
if (debugEnabled())
{
- debugInfo("RB for dn " + baseDn +
- " and with server id " + Integer.toString(serverId) + " computed " +
- Integer.toString(nChanges) + " changes late.");
+ TRACER.debugInfo("RB for dn " + baseDn
+ + " and with server id " + Integer.toString(serverId)
+ + " computed " + Integer.toString(nChanges) + " changes late.");
}
/*
@@ -1247,9 +1246,9 @@
ReplicationMsg msg = localSession.receive();
if (debugEnabled())
{
- debugInfo("In RB for " + baseDn + "\nRB HANDSHAKE SENT:\n"
- + serverStartMsg.toString() + "\nAND RECEIVED:\n"
- + msg.toString());
+ TRACER.debugInfo("In RB for " + baseDn + "\nRB HANDSHAKE SENT:\n"
+ + serverStartMsg.toString() + "\nAND RECEIVED:\n"
+ + msg.toString());
}
// Wrap received message in a server info object
@@ -1349,7 +1348,7 @@
if (debugEnabled())
{
- debugInfo(errorMessage.toString());
+ TRACER.debugInfo(errorMessage.toString());
}
}
}
@@ -1384,9 +1383,8 @@
*/
if (debugEnabled())
{
- debugInfo("In RB for " + baseDn +
- "\nRB HANDSHAKE SENT:\n" + startECLSessionMsg.toString());
- // + "\nAND RECEIVED:\n" + topologyMsg.toString());
+ TRACER.debugInfo("In RB for " + baseDn
+ + "\nRB HANDSHAKE SENT:\n" + startECLSessionMsg.toString());
}
// Alright set the timeout to the desired value
@@ -1460,9 +1458,9 @@
if (debugEnabled())
{
- debugInfo("In RB for " + baseDn +
- "\nRB HANDSHAKE SENT:\n" + startSessionMsg.toString() +
- "\nAND RECEIVED:\n" + topologyMsg.toString());
+ TRACER.debugInfo("In RB for " + baseDn
+ + "\nRB HANDSHAKE SENT:\n" + startSessionMsg.toString()
+ + "\nAND RECEIVED:\n" + topologyMsg.toString());
}
// Alright set the timeout to the desired value
@@ -1569,7 +1567,7 @@
{
if (firstConnection)
{
- // We are no connected to a server yet
+ // We are not connected to a server yet
return computeBestServerForWeight(bestServers, -1, -1);
} else
{
@@ -2183,8 +2181,8 @@
if (debugEnabled())
{
- debugInfo(this + " end restart : connected=" + connected + " with RSid="
- + this.getRsServerId() + " genid=" + this.generationID);
+ TRACER.debugInfo(this + " end restart : connected=" + connected
+ + " with RSid=" + this.getRsServerId() + " genid=" + this.generationID);
}
}
@@ -2243,8 +2241,8 @@
if (debugEnabled())
{
- debugInfo("ReplicationBroker.publish() Publishing a " +
- "message is not possible due to existing connection error.");
+ TRACER.debugInfo("ReplicationBroker.publish() Publishing a "
+ + "message is not possible due to existing connection error.");
}
return false;
@@ -2345,8 +2343,8 @@
// ignore
if (debugEnabled())
{
- debugInfo("ReplicationBroker.publish() " +
- "Interrupted exception raised : " + e.getLocalizedMessage());
+ TRACER.debugInfo("ReplicationBroker.publish() "
+ + "Interrupted exception raised : " + e.getLocalizedMessage());
}
}
}
@@ -2355,8 +2353,8 @@
// just loop.
if (debugEnabled())
{
- debugInfo("ReplicationBroker.publish() " +
- "Interrupted exception raised." + e.getLocalizedMessage());
+ TRACER.debugInfo("ReplicationBroker.publish() "
+ + "Interrupted exception raised." + e.getLocalizedMessage());
}
}
}
@@ -2649,9 +2647,9 @@
public void stop()
{
if (debugEnabled())
- debugInfo("ReplicationBroker " + serverId + " is stopping and will" +
- " close the connection to replication server " + rsServerId + " for" +
- " domain " + baseDn);
+ TRACER.debugInfo("ReplicationBroker " + serverId + " is stopping and will"
+ + " close the connection to replication server " + rsServerId + " for"
+ + " domain " + baseDn);
synchronized (startStopLock)
{
@@ -2819,17 +2817,6 @@
return connected;
}
- private boolean debugEnabled()
- {
- return false;
- }
-
- private static void debugInfo(String s)
- {
- logError(Message.raw(Category.SYNC, Severity.NOTICE, s));
- TRACER.debugInfo(s);
- }
-
/**
* Determine whether the connection to the replication server is encrypted.
* @return true if the connection is encrypted, false otherwise.
@@ -2940,7 +2927,7 @@
public void receiveTopo(TopologyMsg topoMsg)
{
if (debugEnabled())
- debugInfo(this + " receive TopologyMsg=" + topoMsg);
+ TRACER.debugInfo(this + " receive TopologyMsg=" + topoMsg);
// Store new DS list
dsList = topoMsg.getDsList();
@@ -3029,8 +3016,8 @@
} else
{
if (debugEnabled())
- debugInfo(this +
- " is not configured to send CN heartbeat interval");
+ TRACER.debugInfo(this
+ + " is not configured to send CN heartbeat interval");
}
}
--
Gitblit v1.10.0