From 0af0c6ab9fdb449bdd468afecdeb5adc3ef426ea Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 24 Jul 2009 09:46:24 +0000
Subject: [PATCH] Refactor the code of dsreplication and extract some of its commodity methods and move them to the classes they apply to.
---
opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java b/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
index 0c34f65..f5af8fe 100644
--- a/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
+++ b/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
@@ -46,6 +46,7 @@
import javax.naming.ldap.Rdn;
import org.opends.admin.ads.util.ConnectionUtils;
+import org.opends.quicksetup.Constants;
import org.opends.quicksetup.util.Utils;
/**
@@ -1435,4 +1436,62 @@
}
return areDnsEqual;
}
+
+ /**
+ * Returns the replication server normalized String for a given host name
+ * and replication port.
+ * @param hostName the host name.
+ * @param replicationPort the replication port.
+ * @return the replication server normalized String for a given host name
+ * and replication port.
+ */
+ public static String getReplicationServer(String hostName,
+ int replicationPort)
+ {
+ return hostName.toLowerCase() + ":" + replicationPort;
+ }
+
+ /**
+ * Returns the normalized server representation for a given host name and
+ * port.
+ * @param hostName the host name.
+ * @param port the port.
+ * @return the normalized server representation for a given host name and
+ * port.
+ */
+ public static String getServerRepresentation(String hostName, int port)
+ {
+ return hostName.toLowerCase() + ":" + port;
+ }
+
+ /**
+ * Returns a representation of a base DN for a set of servers.
+ * @param baseDN the base DN.
+ * @param servers the servers.
+ * @return a representation of a base DN for a set of servers.
+ */
+ public static String getSuffixDisplay(String baseDN,
+ Set<ServerDescriptor> servers)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append(baseDN);
+ for (ServerDescriptor server : servers)
+ {
+ sb.append(Constants.LINE_SEPARATOR+" ");
+ sb.append(server.getHostPort(true));
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Tells whether the provided server descriptor represents the same server
+ * as this object.
+ * @param server the server to make the comparison.
+ * @return whether the provided server descriptor represents the same server
+ * as this object or not.
+ */
+ public boolean isSameServer(ServerDescriptor server)
+ {
+ return getId().equals(server.getId());
+ }
}
--
Gitblit v1.10.0