From 9357fb33c8425bb731ead54ae7359aa4725f2fd5 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Mon, 03 Jun 2013 09:13:08 +0000
Subject: [PATCH] Fix OPENDJ-866 Local RS is named differently to remote RS under cn=replication,cn=monitor
---
opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java | 18 ++
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java | 6
opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ProtocolSession.java | 9 +
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java | 19 +-
opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ServerStartECLMsg.java | 15 --
opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationMonitor.java | 8
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java | 33 ++---
opendj-sdk/opends/src/server/org/opends/server/replication/protocol/TLSSocketSession.java | 19 ++
opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java | 18 +-
opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java | 24 +---
opendj-sdk/opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java | 21 ++-
opendj-sdk/opends/src/server/org/opends/server/replication/server/DbHandler.java | 9
opendj-sdk/opends/src/server/org/opends/server/replication/server/DataServerHandler.java | 9 -
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java | 6
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/TopologyViewTest.java | 6
opendj-sdk/opends/src/server/org/opends/server/replication/common/DSInfo.java | 19 ++
opendj-sdk/opends/src/server/org/opends/server/replication/protocol/TopologyMsg.java | 21 +++
opendj-sdk/opends/src/server/org/opends/server/replication/server/DraftCNDbHandler.java | 2
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java | 6
opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ProtocolVersion.java | 35 +----
opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java | 12 ++
21 files changed, 176 insertions(+), 139 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/common/DSInfo.java b/opendj-sdk/opends/src/server/org/opends/server/replication/common/DSInfo.java
index 44e98c6..cf9a760 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/common/DSInfo.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/common/DSInfo.java
@@ -23,7 +23,7 @@
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
- * Portions copyright 2011-2012 ForgeRock AS
+ * Portions copyright 2011-2013 ForgeRock AS
*/
package org.opends.server.replication.common;
@@ -43,6 +43,8 @@
// DS server id
private int dsId = -1;
+ // DS server url
+ private String dsUrl;
// Server id of the RS the DS is connected to
private int rsId = -1;
// DS Generation Id
@@ -73,6 +75,7 @@
*
* @param dsId
* The DS id
+ * @param dsUrl Url of the DS
* @param rsId
* The RS id the DS is connected to
* @param generationId
@@ -96,13 +99,14 @@
* @param protocolVersion
* Protocol version supported by this server.
*/
- public DSInfo(int dsId, int rsId, long generationId,
+ public DSInfo(int dsId, String dsUrl, int rsId, long generationId,
ServerStatus status, boolean assuredFlag,
AssuredMode assuredMode, byte safeDataLevel, byte groupId,
List<String> refUrls, Set<String> eclIncludes,
Set<String> eclIncludesForDeletes, short protocolVersion)
{
this.dsId = dsId;
+ this.dsUrl = dsUrl;
this.rsId = rsId;
this.generationId = generationId;
this.status = status;
@@ -126,6 +130,15 @@
}
/**
+ * Get the DS URL.
+ * @return the DS URL
+ */
+ public String getDsUrl()
+ {
+ return dsUrl;
+ }
+
+ /**
* Get the RS id the DS is connected to.
* @return the RS id the DS is connected to
*/
@@ -298,6 +311,8 @@
StringBuilder sb = new StringBuilder();
sb.append("\nDS id: ");
sb.append(dsId);
+ sb.append(" ; DS url: ");
+ sb.append(dsUrl);
sb.append(" ; RS id: ");
sb.append(rsId);
sb.append(" ; Generation id: ");
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ProtocolSession.java b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ProtocolSession.java
index e356005..8bf6c5a 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ProtocolSession.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ProtocolSession.java
@@ -23,7 +23,7 @@
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS
+ * Portions copyright 2011-2013 ForgeRock AS
*/
package org.opends.server.replication.protocol;
@@ -109,6 +109,13 @@
public abstract boolean isEncrypted();
/**
+ * Retrieve the local URL in the form host:port.
+ *
+ * @return The local URL.
+ */
+ public abstract String getLocalUrl();
+
+ /**
* Retrieve the IP address of the remote server.
*
* @return The IP address of the remote server.
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ProtocolVersion.java b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ProtocolVersion.java
index 97f4b1c..377fea2 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ProtocolVersion.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ProtocolVersion.java
@@ -75,14 +75,15 @@
public static final short REPLICATION_PROTOCOL_V5 = 5;
/**
+ * The constant for the 6th version of the replication protocol.
+ * - include DS local URL in the DSInfo of TopologyMsg.
+ */
+ public static final short REPLICATION_PROTOCOL_V6 = 6;
+
+ /**
* The replication protocol version used by the instance of RS/DS in this VM.
*/
- private static short currentVersion = -1;
-
- static
- {
- resetCurrentVersion();
- }
+ private static final short CURRENT_VERSION = REPLICATION_PROTOCOL_V6;
/**
* Gets the current version of the replication protocol.
@@ -91,25 +92,7 @@
*/
public static short getCurrentVersion()
{
- return currentVersion;
- }
-
- /**
- * For test purpose.
- * @param curVersion The provided current version.
- */
- public static void setCurrentVersion(short curVersion)
- {
- currentVersion = curVersion;
- }
-
- /**
- * Resets the protocol version to the default value (the latest version).
- * For test purpose.
- */
- public static void resetCurrentVersion()
- {
- currentVersion = REPLICATION_PROTOCOL_V5;
+ return CURRENT_VERSION;
}
/**
@@ -121,7 +104,7 @@
*/
public static short minWithCurrent(short version)
{
- return (version < currentVersion ? version : currentVersion);
+ return (version < CURRENT_VERSION ? version : CURRENT_VERSION);
}
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ServerStartECLMsg.java b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ServerStartECLMsg.java
index b1ec977..db3b7e4 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ServerStartECLMsg.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ServerStartECLMsg.java
@@ -28,8 +28,6 @@
package org.opends.server.replication.protocol;
import java.io.UnsupportedEncodingException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.util.zip.DataFormatException;
import org.opends.server.replication.common.ServerState;
@@ -67,6 +65,7 @@
* Server after being connected to a replication server for a given
* replication domain.
*
+ * @param serverURL directory server URL
* @param maxReceiveDelay The max receive delay for this server.
* @param maxReceiveQueue The max receive Queue for this server.
* @param maxSendDelay The max Send Delay from this server.
@@ -80,7 +79,7 @@
* after the start messages have been exchanged.
* @param groupId The group id of the DS for this DN
*/
- public ServerStartECLMsg(int maxReceiveDelay,
+ public ServerStartECLMsg(String serverURL, int maxReceiveDelay,
int maxReceiveQueue, int maxSendDelay,
int maxSendQueue, int windowSize,
long heartbeatInterval,
@@ -92,6 +91,7 @@
{
super(protocolVersion, generationId);
+ this.serverURL = serverURL;
this.maxReceiveDelay = maxReceiveDelay;
this.maxReceiveQueue = maxReceiveQueue;
this.maxSendDelay = maxSendDelay;
@@ -101,15 +101,6 @@
this.sslEncryption = sslEncryption;
this.serverState = serverState;
this.groupId = groupId;
-
- try
- {
- /* TODO : find a better way to get the server URL */
- this.serverURL = InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException e)
- {
- this.serverURL = "Unknown host";
- }
}
/**
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java
index abcd8af..d516608 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java
@@ -28,8 +28,6 @@
package org.opends.server.replication.protocol;
import java.io.UnsupportedEncodingException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.util.zip.DataFormatException;
import org.opends.server.replication.common.ServerState;
@@ -70,6 +68,7 @@
*
* @param serverId2 The serverId of the server for which the ServerStartMsg
* is created.
+ * @param serverURL directory server URL
* @param baseDn The base DN.
* @param windowSize The window size used by this server.
* @param heartbeatInterval The requested heartbeat interval.
@@ -80,17 +79,15 @@
* after the start messages have been exchanged.
* @param groupId The group id of the DS for this DN
*/
- public ServerStartMsg(int serverId2, String baseDn, int windowSize,
- long heartbeatInterval,
- ServerState serverState,
- short protocolVersion,
- long generationId,
- boolean sslEncryption,
- byte groupId)
+ public ServerStartMsg(int serverId2, String serverURL, String baseDn,
+ int windowSize, long heartbeatInterval, ServerState serverState,
+ short protocolVersion, long generationId, boolean sslEncryption,
+ byte groupId)
{
super(protocolVersion, generationId);
this.serverId = serverId2;
+ this.serverURL = serverURL;
this.baseDn = baseDn;
this.maxReceiveDelay = 0;
this.maxReceiveQueue = 0;
@@ -101,15 +98,6 @@
this.sslEncryption = sslEncryption;
this.serverState = serverState;
this.groupId = groupId;
-
- try
- {
- /* TODO : find a better way to get the server URL */
- this.serverURL = InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException e)
- {
- this.serverURL = "Unknown host";
- }
}
/**
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/TLSSocketSession.java b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/TLSSocketSession.java
index 292cbea..805e8ba 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/TLSSocketSession.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/TLSSocketSession.java
@@ -23,7 +23,7 @@
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
- * Portions Copyright 2011-2012 ForgeRock AS
+ * Portions Copyright 2011-2013 ForgeRock AS
*/
package org.opends.server.replication.protocol;
@@ -65,6 +65,7 @@
private final byte[] rcvLengthBuf = new byte[8];
private final String readableRemoteAddress;
private final String remoteAddress;
+ private final String localUrl;
/**
* The time the last message published to this session.
@@ -124,8 +125,9 @@
this.output = secureSocket.getOutputStream();
this.readableRemoteAddress = plainSocket.getRemoteSocketAddress()
.toString();
- this.remoteAddress = plainSocket.getInetAddress()
- .getHostAddress();
+ this.remoteAddress = plainSocket.getInetAddress().getHostAddress();
+ this.localUrl = plainSocket.getLocalAddress().getHostName() + ":"
+ + plainSocket.getLocalPort();
}
@@ -260,6 +262,17 @@
* {@inheritDoc}
*/
@Override
+ public String getLocalUrl()
+ {
+ return localUrl;
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public String getReadableRemoteAddress()
{
return readableRemoteAddress;
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/TopologyMsg.java b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/TopologyMsg.java
index 132238e..16fbfc5 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/TopologyMsg.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/protocol/TopologyMsg.java
@@ -97,6 +97,19 @@
int dsId = Integer.valueOf(serverIdString);
pos += length + 1;
+ /* Read DS URL */
+ String dsUrl;
+ if (version >= ProtocolVersion.REPLICATION_PROTOCOL_V6)
+ {
+ length = getNextLength(in, pos);
+ dsUrl = new String(in, pos, length, "UTF-8");
+ pos += length + 1;
+ }
+ else
+ {
+ dsUrl = "";
+ }
+
/* Read RS id */
length =
getNextLength(in, pos);
@@ -187,7 +200,7 @@
/* Now create DSInfo and store it in list */
- DSInfo dsInfo = new DSInfo(dsId, rsId, generationId, status,
+ DSInfo dsInfo = new DSInfo(dsId, dsUrl, rsId, generationId, status,
assuredFlag, assuredMode, safeDataLevel, groupId, refUrls, attrs,
delattrs, protocolVersion);
dsList.add(dsInfo);
@@ -321,6 +334,12 @@
String.valueOf(dsInfo.getDsId()).getBytes("UTF-8");
oStream.write(byteServerId);
oStream.write(0);
+ if (version >= ProtocolVersion.REPLICATION_PROTOCOL_V6)
+ {
+ // Put DS URL
+ oStream.write(dsInfo.getDsUrl().getBytes("UTF-8"));
+ oStream.write(0);
+ }
// Put RS id
byteServerId =
String.valueOf(dsInfo.getRsId()).getBytes("UTF-8");
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/DataServerHandler.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/DataServerHandler.java
index bb23940..63a15fe 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/DataServerHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/DataServerHandler.java
@@ -346,10 +346,8 @@
@Override
public String getMonitorInstanceName()
{
- String str = serverURL + " " + String.valueOf(serverId);
-
- return "Connected Replica " + str +
- ",cn=" + replicationServerDomain.getMonitorInstanceName();
+ return "Connected directory server DS(" + serverId + ") " + serverURL
+ + ",cn=" + replicationServerDomain.getMonitorInstanceName();
}
/**
@@ -662,8 +660,7 @@
*/
public DSInfo toDSInfo()
{
-
- return new DSInfo(serverId, replicationServerId, generationId,
+ return new DSInfo(serverId, serverURL, replicationServerId, generationId,
status, assuredFlag, assuredMode, safeDataLevel, groupId, refUrls,
eclIncludes, eclIncludesForDeletes, protocolVersion);
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/DbHandler.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/DbHandler.java
index f0646c0..b1447e0 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/DbHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/DbHandler.java
@@ -557,11 +557,10 @@
@Override
public String getMonitorInstanceName()
{
- ReplicationServerDomain domain =
- replicationServer.getReplicationServerDomain(baseDn, false);
-
- return "ReplicationServer database " + String.valueOf(serverId) +
- ",cn=" + domain.getMonitorInstanceName();
+ ReplicationServerDomain domain = replicationServer
+ .getReplicationServerDomain(baseDn, false);
+ return "Changelog for DS(" + serverId + "),cn="
+ + domain.getMonitorInstanceName();
}
/**
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/DraftCNDbHandler.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/DraftCNDbHandler.java
index 0cbc1ea..1111f18 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/DraftCNDbHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/DraftCNDbHandler.java
@@ -472,7 +472,7 @@
@Override
public String getMonitorInstanceName()
{
- return "ReplicationServer DraftCN database ";
+ return "Draft Changelog";
}
/**
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java
index 5e562f6..9a9e721 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java
@@ -73,6 +73,8 @@
// Server id of this DS
private int serverId = -1;
+ // Server URL of this DS
+ private String serverUrl = null;
// Generation id of this DS
private long generationId = -1;
// Group id of the DS;
@@ -103,6 +105,7 @@
* @param replicationServerId The serverId of the RS this remote DS is
* connected to
* @param serverId The serverId of this remote DS.
+ * @param serverUrl The serverUrl of this remote DS.
* @param generationId The generation id of this remote DS.
* @param groupId The group id of the remote DS
* @param status The id of the remote DS
@@ -116,15 +119,17 @@
* @param protocolVersion The protocol version supported by the remote DS.
*/
public LightweightServerHandler(ReplicationServerHandler replServerHandler,
- int replicationServerId, int serverId, long generationId, byte groupId,
- ServerStatus status, List<String> refUrls, boolean assuredFlag,
- AssuredMode assuredMode, byte safeDataLevel, Set<String> eclInclude,
- Set<String> eclIncludeForDeletes, short protocolVersion)
+ int replicationServerId, int serverId, String serverUrl,
+ long generationId, byte groupId, ServerStatus status,
+ List<String> refUrls, boolean assuredFlag, AssuredMode assuredMode,
+ byte safeDataLevel, Set<String> eclInclude,
+ Set<String> eclIncludeForDeletes, short protocolVersion)
{
this.replServerHandler = replServerHandler;
this.rsDomain = replServerHandler.getDomain();
this.replicationServerId = replicationServerId;
this.serverId = serverId;
+ this.serverUrl = serverUrl;
this.generationId = generationId;
this.groupId = groupId;
this.status = status;
@@ -151,7 +156,7 @@
*/
public DSInfo toDSInfo()
{
- return new DSInfo(serverId, replicationServerId, generationId,
+ return new DSInfo(serverId, serverUrl, replicationServerId, generationId,
status, assuredFlag, assuredMode, safeDataLevel, groupId, refUrls,
eclInclude, eclIncludeForDeletes, protocolVersion);
}
@@ -216,10 +221,8 @@
@Override
public String getMonitorInstanceName()
{
- String serverURL=""; // FIXME
- String str = serverURL + " " + String.valueOf(serverId);
- return "Undirect Replica " + str +
- ",cn=" + replServerHandler.getMonitorInstanceName();
+ return "Connected directory server DS(" + serverId + ") " + serverUrl
+ + ",cn=" + replServerHandler.getMonitorInstanceName();
}
/**
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java
index 77853a8..60c1c75 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/server/ReplicationServerHandler.java
@@ -709,13 +709,11 @@
for (DSInfo dsInfo : dsInfos)
{
LightweightServerHandler lsh = new LightweightServerHandler(this,
- serverId, dsInfo.getDsId(), dsInfo.getGenerationId(),
- dsInfo.getGroupId(), dsInfo.getStatus(), dsInfo.getRefUrls(),
- dsInfo.isAssured(), dsInfo.getAssuredMode(),
- dsInfo.getSafeDataLevel(),
- dsInfo.getEclIncludes(),
- dsInfo.getEclIncludesForDeletes(),
- dsInfo.getProtocolVersion());
+ serverId, dsInfo.getDsId(), dsInfo.getDsUrl(),
+ dsInfo.getGenerationId(), dsInfo.getGroupId(), dsInfo.getStatus(),
+ dsInfo.getRefUrls(), dsInfo.isAssured(), dsInfo.getAssuredMode(),
+ dsInfo.getSafeDataLevel(), dsInfo.getEclIncludes(),
+ dsInfo.getEclIncludesForDeletes(), dsInfo.getProtocolVersion());
lsh.startHandler();
remoteDirectoryServers.put(lsh.getServerId(), lsh);
}
@@ -779,10 +777,8 @@
@Override
public String getMonitorInstanceName()
{
- String str = serverURL + " " + String.valueOf(serverId);
-
- return "Connected Replication Server " + str +
- ",cn=" + replicationServerDomain.getMonitorInstanceName();
+ return "Connected replication server RS(" + serverId + ") " + serverURL
+ + ",cn=" + replicationServerDomain.getMonitorInstanceName();
}
/**
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java b/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
index 3307e31..987998f 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
@@ -1239,17 +1239,19 @@
.isSslEncryption(server);
// Send our ServerStartMsg.
+ String url = socket.getLocalAddress().getHostName() + ":"
+ + socket.getLocalPort();
StartMsg serverStartMsg;
if (!isECL)
{
- serverStartMsg = new ServerStartMsg(serverId, baseDn,
+ serverStartMsg = new ServerStartMsg(serverId, url, baseDn,
maxRcvWindow, heartbeatInterval, state,
ProtocolVersion.getCurrentVersion(),
this.getGenerationID(), isSslEncryption, groupId);
}
else
{
- serverStartMsg = new ServerStartECLMsg(0, 0, 0, 0,
+ serverStartMsg = new ServerStartECLMsg(url, 0, 0, 0, 0,
maxRcvWindow, heartbeatInterval, state,
ProtocolVersion.getCurrentVersion(),
this.getGenerationID(), isSslEncryption, groupId);
@@ -3117,4 +3119,16 @@
return shutdown;
}
+ /**
+ * Returns the local address of this replication domain, or the empty string
+ * if it is not yet connected.
+ *
+ * @return The local address.
+ */
+ String getLocalUrl()
+ {
+ final ProtocolSession tmp = session;
+ return tmp != null ? tmp.getLocalUrl() : "";
+ }
+
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java b/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
index cf49fc3..ee69055 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationDomain.java
@@ -3565,6 +3565,18 @@
}
/**
+ * Returns the local address of this replication domain, or the empty string
+ * if it is not yet connected.
+ *
+ * @return The local address.
+ */
+ String getLocalUrl()
+ {
+ final ReplicationBroker tmp = broker;
+ return tmp != null ? tmp.getLocalUrl() : "";
+ }
+
+ /**
* Returns the total number of entries to be processed when a total update
* is in progress.
*
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationMonitor.java b/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationMonitor.java
index 2d0143f..3966c4b 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationMonitor.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationMonitor.java
@@ -23,6 +23,7 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
+ * Portions copyright 2013 ForgeRock AS.
*/
package org.opends.server.replication.service;
@@ -74,9 +75,10 @@
@Override
public String getMonitorInstanceName()
{
- return "Replication Domain " + domain.getServerId()
- + ",cn=" + domain.getServiceID().replace(',', '_').replace('=', '_')
- + ",cn=replication";
+ return "Directory server DS(" + domain.getServerId() + ") "
+ + domain.getLocalUrl() + ",cn="
+ + domain.getServiceID().replace(',', '_').replace('=', '_')
+ + ",cn=Replication";
}
/**
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
index c7ba93f..df8ff6f 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
@@ -23,7 +23,7 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions Copyright 2011-2012 ForgeRock AS
+ * Portions Copyright 2011-2013 ForgeRock AS
*/
package org.opends.server.replication;
@@ -632,7 +632,7 @@
protected long getMonitorAttrValue(DN baseDn, String attr) throws Exception
{
String monitorFilter =
- "(&(cn=replication Domain*)(domain-name=" + baseDn + "))";
+ "(&(cn=Directory server*)(domain-name=" + baseDn + "))";
InternalSearchOperation op;
int count = 0;
@@ -641,7 +641,7 @@
if (count++>0)
Thread.sleep(100);
op = connection.processSearch(
- ByteString.valueOf("cn=monitor"),
+ ByteString.valueOf("cn=replication,cn=monitor"),
SearchScope.WHOLE_SUBTREE,
LDAPFilter.decode(monitorFilter));
}
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
index 97801b7..463a644 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
@@ -23,7 +23,7 @@
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS
+ * Portions copyright 2011-2013 ForgeRock AS
*/
package org.opends.server.replication.plugin;
@@ -1829,7 +1829,7 @@
* Find monitoring entry for requested base DN
*/
String monitorFilter =
- "(&(cn=replication Domain*)(domain-name=" + baseDn + "))";
+ "(&(cn=Directory server*)(domain-name=" + baseDn + "))";
InternalSearchOperation op;
int count = 0;
@@ -1838,7 +1838,7 @@
if (count++>0)
Thread.sleep(100);
op = connection.processSearch(
- ByteString.valueOf("cn=monitor"),
+ ByteString.valueOf("cn=replication,cn=monitor"),
SearchScope.WHOLE_SUBTREE,
LDAPFilter.decode(monitorFilter));
}
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/TopologyViewTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/TopologyViewTest.java
index 8fe26ac..3934ac7 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/TopologyViewTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/TopologyViewTest.java
@@ -23,7 +23,7 @@
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS
+ * Portions copyright 2011-2013 ForgeRock AS
*/
package org.opends.server.replication.plugin;
@@ -933,7 +933,7 @@
urls.add(str);
}
- return new DSInfo(dsId, rsId, TEST_DN_WITH_ROOT_ENTRY_GENID, status, assuredFlag, assMode,
+ return new DSInfo(dsId, "dummy:1234", rsId, TEST_DN_WITH_ROOT_ENTRY_GENID, status, assuredFlag, assMode,
(byte)assuredSdLevel, groupId, urls, eclIncludes, eclIncludes, protocolVersion);
}
@@ -1137,7 +1137,7 @@
Set<String> eclInclude = rd.getEclIncludes();
Set<String> eclIncludeForDeletes = rd.getEclIncludesForDeletes();
short protocolVersion = ProtocolVersion.getCurrentVersion();
- DSInfo dsInfo = new DSInfo(dsId, rsId, TEST_DN_WITH_ROOT_ENTRY_GENID, status, assuredFlag, assuredMode,
+ DSInfo dsInfo = new DSInfo(dsId, "dummy:1234", rsId, TEST_DN_WITH_ROOT_ENTRY_GENID, status, assuredFlag, assuredMode,
safeDataLevel, groupId, refUrls, eclInclude, eclIncludeForDeletes, protocolVersion);
dsList.add(dsInfo);
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java
index 7dd2b85..0580d7a 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java
@@ -23,7 +23,7 @@
*
*
* Copyright 2009-2010 Sun Microsystems, Inc.
- * Portions copyright 2011-2012 ForgeRock AS
+ * Portions copyright 2011-2013 ForgeRock AS
*/
package org.opends.server.replication.protocol;
@@ -65,6 +65,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.replication.protocol.OperationContext.SYNCHROCONTEXT;
+import static org.opends.server.util.StaticUtils.byteToHex;
import static org.opends.messages.ReplicationMessages.*;
import static org.testng.Assert.assertEquals;
@@ -75,7 +76,8 @@
*/
public class ProtocolCompatibilityTest extends ReplicationTestCase {
- short REPLICATION_PROTOCOL_VLAST = ProtocolVersion.REPLICATION_PROTOCOL_V5;
+ short REPLICATION_PROTOCOL_VLAST = ProtocolVersion.getCurrentVersion();
+
/**
* Set up the environment for performing the tests in this Class.
*
@@ -87,8 +89,6 @@
public void setUp() throws Exception
{
super.setUp();
- // Be sure we use the latest protocol version for these tests
- ProtocolVersion.resetCurrentVersion();
}
/**
@@ -101,8 +101,6 @@
public void classCleanUp() throws Exception
{
super.classCleanUp();
- // Do not disturb other tests
- ProtocolVersion.resetCurrentVersion();
}
@DataProvider(name="createReplServerStartData")
@@ -945,12 +943,12 @@
@DataProvider(name = "createOldServerStartData")
public Object[][] createOldServerStartData()
{
- return new Object[][] {
- {"140531323438001f6f3d74657374003136006675726f6e0030003000" +
- "300030003130300031303000747275650032363300303030303030303030303030303034" +
- "623031303730303030303030350000",
- 16, "o=test", (byte) 31,}
- };
+ return new Object[][] { {
+ "14"
+ + byteToHex((byte) ProtocolVersion.getCurrentVersion())
+ + "31323438001f6f3d74657374003136006675726f6e0030003000"
+ + "300030003130300031303000747275650032363300303030303030303030303030303034"
+ + "623031303730303030303030350000", 16, "o=test", (byte) 31, } };
}
@Test(dataProvider = "createOldServerStartData")
@@ -964,8 +962,7 @@
assertEquals(msg.getServerId(), serverId);
assertEquals(msg.getBaseDn(), dn);
assertEquals(msg.getGroupId(), groupId);
- // We use V4 here because these PDU have not changed since 2.0.
- BigInteger bi = new BigInteger(msg.getBytes(ProtocolVersion.REPLICATION_PROTOCOL_V5));
+ BigInteger bi = new BigInteger(msg.getBytes());
assertEquals(bi.toString(16), oldPdu);
}
@@ -1069,16 +1066,16 @@
urls4.add("ldaps://host:port/dc=foobar1??sub?(sn=Another Entry 1)");
urls4.add("ldaps://host:port/dc=foobar2??sub?(sn=Another Entry 2)");
- DSInfo dsInfo1 = new DSInfo(13, 26, (long)154631, ServerStatus.FULL_UPDATE_STATUS,
+ DSInfo dsInfo1 = new DSInfo(13, "dsHost1:111", 26, (long)154631, ServerStatus.FULL_UPDATE_STATUS,
false, AssuredMode.SAFE_DATA_MODE, (byte)12, (byte)132, urls1, new HashSet<String>(), new HashSet<String>(), (short)-1);
- DSInfo dsInfo2 = new DSInfo(-436, 493, (long)-227896, ServerStatus.DEGRADED_STATUS,
+ DSInfo dsInfo2 = new DSInfo(-436, "dsHost2:222", 493, (long)-227896, ServerStatus.DEGRADED_STATUS,
true, AssuredMode.SAFE_READ_MODE, (byte)-7, (byte)-265, urls2, new HashSet<String>(), new HashSet<String>(), (short)-1);
- DSInfo dsInfo3 = new DSInfo(2436, 591, (long)0, ServerStatus.NORMAL_STATUS,
+ DSInfo dsInfo3 = new DSInfo(2436, "dsHost3:333", 591, (long)0, ServerStatus.NORMAL_STATUS,
false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, new HashSet<String>(), new HashSet<String>(), (short)-1);
- DSInfo dsInfo4 = new DSInfo(415, 146, (long)0, ServerStatus.BAD_GEN_ID_STATUS,
+ DSInfo dsInfo4 = new DSInfo(415, "dsHost4:444", 146, (long)0, ServerStatus.BAD_GEN_ID_STATUS,
true, AssuredMode.SAFE_DATA_MODE, (byte)2, (byte)15, urls4, new HashSet<String>(), new HashSet<String>(), (short)-1);
List<DSInfo> dsList1 = new ArrayList<DSInfo>();
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java
index 415b317..4d5e766 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/protocol/SynchronizationMsgTest.java
@@ -98,8 +98,6 @@
public void setUp() throws Exception
{
super.setUp();
- // Be sure we use the latest protocol version for these tests
- ProtocolVersion.resetCurrentVersion();
}
/**
@@ -837,10 +835,11 @@
ServerState state, long genId, boolean sslEncryption, byte groupId) throws Exception
{
ServerStartMsg msg = new ServerStartMsg(
- serverId, baseDN, window, window, state,
+ serverId, "localhost:1234", baseDN, window, window, state,
ProtocolVersion.getCurrentVersion(), genId, sslEncryption, groupId);
ServerStartMsg newMsg = new ServerStartMsg(msg.getBytes());
assertEquals(msg.getServerId(), newMsg.getServerId());
+ assertEquals(msg.getServerURL(), newMsg.getServerURL());
assertEquals(msg.getBaseDn(), newMsg.getBaseDn());
assertEquals(msg.getWindowSize(), newMsg.getWindowSize());
assertEquals(msg.getHeartbeatInterval(), newMsg.getHeartbeatInterval());
@@ -1006,19 +1005,18 @@
a3.add("uid");
Set<String> a4 = new HashSet<String>();
- DSInfo dsInfo1 = new DSInfo(13, 26, (long)154631, ServerStatus.FULL_UPDATE_STATUS,
+ DSInfo dsInfo1 = new DSInfo(13, "dsHost1:111", 26, (long)154631, ServerStatus.FULL_UPDATE_STATUS,
false, AssuredMode.SAFE_DATA_MODE, (byte)12, (byte)132, urls1, a1, a1, (short)1);
- DSInfo dsInfo2 = new DSInfo(-436, 493, (long)-227896, ServerStatus.DEGRADED_STATUS,
+ DSInfo dsInfo2 = new DSInfo(-436, "dsHost2:222", 493, (long)-227896, ServerStatus.DEGRADED_STATUS,
true, AssuredMode.SAFE_READ_MODE, (byte)-7, (byte)-265, urls2, a2, a2, (short)2);
- DSInfo dsInfo3 = new DSInfo(2436, 591, (long)0, ServerStatus.NORMAL_STATUS,
+ DSInfo dsInfo3 = new DSInfo(2436, "dsHost3:333", 591, (long)0, ServerStatus.NORMAL_STATUS,
false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, a3, a3, (short)3);
-
- DSInfo dsInfo4 = new DSInfo(415, 146, (long)0, ServerStatus.BAD_GEN_ID_STATUS,
+ DSInfo dsInfo4 = new DSInfo(415, "dsHost4:444", 146, (long)0, ServerStatus.BAD_GEN_ID_STATUS,
true, AssuredMode.SAFE_DATA_MODE, (byte)2, (byte)15, urls4, a4, a4, (short)4);
- DSInfo dsInfo5 = new DSInfo(452436, 45591, (long)0, ServerStatus.NORMAL_STATUS,
+ DSInfo dsInfo5 = new DSInfo(452436, "dsHost5:555", 45591, (long)0, ServerStatus.NORMAL_STATUS,
false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, a1, a1, (short)5);
List<DSInfo> dsList1 = new ArrayList<DSInfo>();
@@ -1422,9 +1420,10 @@
ServerState state, long genId, boolean sslEncryption, byte groupId) throws Exception
{
ServerStartECLMsg msg = new ServerStartECLMsg(
- window, window, window, window, window, window, state,
+ "localhost:1234", window, window, window, window, window, window, state,
ProtocolVersion.getCurrentVersion(), genId, sslEncryption, groupId);
ServerStartECLMsg newMsg = new ServerStartECLMsg(msg.getBytes());
+ assertEquals(msg.getServerURL(), newMsg.getServerURL());
assertEquals(msg.getMaxReceiveDelay(), newMsg.getMaxReceiveDelay());
assertEquals(msg.getMaxReceiveQueue(), newMsg.getMaxReceiveQueue());
assertEquals(msg.getMaxSendDelay(), newMsg.getMaxSendDelay());
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
index f6cf3e4..a17a8f1 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
@@ -985,8 +985,10 @@
try
{
// send a ServerStartMsg with an empty ServerState.
+ String url = socket.getLocalAddress().getCanonicalHostName() + ":"
+ + socket.getLocalPort();
ServerStartMsg msg =
- new ServerStartMsg( 1723, TEST_ROOT_DN_STRING,
+ new ServerStartMsg( 1723, url, TEST_ROOT_DN_STRING,
WINDOW, 5000, new ServerState(),
ProtocolVersion.getCurrentVersion(), 0, sslEncryption, (byte)-1);
session.publish(msg);
@@ -1621,7 +1623,7 @@
{
ByteArrayOutputStream oStream = new ByteArrayOutputStream();
ByteArrayOutputStream eStream = new ByteArrayOutputStream();
-
+
// test search as anonymous
String[] args =
{
--
Gitblit v1.10.0