From f73b655466092169abac34833fb628fce1fcdebe Mon Sep 17 00:00:00 2001
From: jcduff <jcduff@localhost>
Date: Thu, 23 Oct 2008 14:04:24 +0000
Subject: [PATCH] The commit will bring the following features :     - An updated version of the underlying database. BDB JE 3.3 is now used.     - Attribute API refactoring providing a better abstraction and offering improved performances.     - A new GUI called the Control-Panel to replace the Status-Panel: the specifications for this       GUI are available on OpenDS Wiki and contains a link to a mockup.        See <https://www.opends.org/wiki/page/ControlPanelUISpecification>.     - Some changes in the replication protocol to implement "Assured Replication Mode". The        specifications are on OpenDS Wiki at <https://www.opends.org/wiki/page/AssuredMode> and section 7       described some of the replication changes required to support this. Assured Replication is not finished,       but the main replication protocol changes to support it are done. As explained by Gilles on an email on       the Dev mailing list (http://markmail.org/message/46rgo3meq3vriy4a), with these changes the newer versions       of OpenDS may not be able to replicate with OpenDS 1.0 instances.     - Support for Service Tags on the platforms where the functionality is available and enabled. Specifications       are published at <https://www.opends.org/wiki/page/OpenDSServiceTagEnabled>. For more information on       Service Tags see <http://wikis.sun.com/display/ServiceTag/Sun+Service+Tag+FAQ>.     - The Admin Connector service. In order to provide agentry of the OpenDS server at any time, a new service       has been added, dedicated to the administration, configuration and monitoring of the server.       An overview of the Admin Connector service and it's use is available on the       OpenDS wiki <https://www.opends.org/wiki/page/ManagingAdministrationTrafficToTheServer>     - Updates to the various command line tools to support the Admin Connector service.     - Some internal re-architecting of the server to put the foundation of future developments such as virtual       directory services. The new NetworkGroups and WorkFlow internal services which have been specified in       <https://www.opends.org/wiki/page/BasicOperationRoutingThroughNetworkGroup> are now implemented.     - Many bug fixes...

---
 opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java |  118 ++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 81 insertions(+), 37 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java b/opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java
index ea8ffc8..19a4671 100644
--- a/opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java
+++ b/opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java
@@ -32,18 +32,20 @@
 
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.LinkedHashSet;
 
+import java.util.List;
 import org.opends.server.admin.std.server.MonitorProviderCfg;
 import org.opends.server.api.MonitorProvider;
 import org.opends.server.config.ConfigException;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.loggers.debug.DebugTracer;
+import org.opends.server.replication.common.AssuredMode;
+import org.opends.server.replication.common.DSInfo;
 import org.opends.server.replication.common.ServerState;
+import org.opends.server.replication.common.ServerStatus;
 import org.opends.server.types.Attribute;
-import org.opends.server.types.AttributeType;
-import org.opends.server.types.AttributeValue;
-import org.opends.server.types.DN;
+import org.opends.server.types.AttributeBuilder;
+import org.opends.server.types.Attributes;
 import org.opends.server.types.InitializationException;
 
 /**
@@ -62,27 +64,62 @@
   // The tracer object for the debug logger.
   private static final DebugTracer TRACER = getTracer();
 
-  short serverId;
-  ServerHandler replServerHandler;
-  ReplicationServerDomain rsDomain;
-  DN baseDn;
+  private ServerHandler replServerHandler;
+  private ReplicationServerDomain rsDomain;
+  // The id of the RS this DS is connected to
+  private short replicationServerId = -1;
+
+  // Server id of this DS
+  private short serverId = -1;
+  // Generation id of this DS
+  private long generationId = -1;
+  // Group id of the DS;
+  private byte groupId = (byte) -1;
+  // Status of this DS
+  private ServerStatus status = ServerStatus.INVALID_STATUS;
+  // Referrals URLs this DS is exporting
+  private List<String> refUrls = new ArrayList<String>();
+  // Assured replication enabled on DS or not
+  private boolean assuredFlag = false;
+  // DS assured mode (relevant if assured replication enabled)
+  private AssuredMode assuredMode = AssuredMode.SAFE_DATA_MODE;
+  // DS safe data level (relevant if assured mode is safe data)
+  private byte safeDataLevel = (byte) -1;
 
   /**
    * Creates a new LighweightServerHandler with the provided serverid, connected
    * to the remote Replication Server represented by replServerHandler.
    *
-   * @param serverId The serverId of this remote LDAP server.
-   * @param replServerHandler The server handler of the Replication Server to
-   * which this LDAP server is remotely connected.
+   * @param replServerHandler The server handler of the RS this remote DS is
+   * connected to
+   * @param replicationServerId The serverId of the RS this remote DS is
+   * connected to
+   * @param serverId The serverId 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
+   * @param refUrls The exported referral URLs of the remote DS
+   * @param assuredFlag The assured flag of the remote DS
+   * @param assuredMode The assured mode of the remote DS
+   * @param safeDataLevel The safe data level of the remote DS
    */
-  public LightweightServerHandler(String serverId,
-      ServerHandler replServerHandler)
+  public LightweightServerHandler(ServerHandler replServerHandler,
+    short replicationServerId, short serverId, long generationId, byte groupId,
+    ServerStatus status, List<String> refUrls, boolean assuredFlag,
+    AssuredMode assuredMode, byte safeDataLevel)
   {
     super("Server Handler");
-    this.serverId = Short.valueOf(serverId);
     this.replServerHandler = replServerHandler;
     this.rsDomain = replServerHandler.getDomain();
-    this.baseDn = rsDomain.getBaseDn();
+    this.replicationServerId = replicationServerId;
+    this.serverId = serverId;
+    this.generationId = generationId;
+    this.groupId = groupId;
+    this.status = status;
+    this.refUrls = refUrls;
+    this.assuredFlag = assuredFlag;
+    this.assuredMode = assuredMode;
+    this.safeDataLevel = safeDataLevel;
 
     if (debugEnabled())
       TRACER.debugInfo(
@@ -94,6 +131,18 @@
 }
 
   /**
+   * Creates a DSInfo structure representing this remote DS.
+   * @return The DSInfo structure representing this remote DS
+   */
+  public DSInfo toDSInfo()
+  {
+    DSInfo dsInfo = new DSInfo(serverId, replicationServerId, generationId,
+      status, assuredFlag, assuredMode, safeDataLevel, groupId, refUrls);
+
+    return dsInfo;
+  }
+
+  /**
    * Get the serverID associated with this LDAP server.
    * @return The serverId.
    */
@@ -154,7 +203,7 @@
   public String getMonitorInstanceName()
   {
     String serverURL=""; // FIXME
-    String str = baseDn.toString() + " " + serverURL + " "
+    String str = rsDomain.getBaseDn().toString() + " " + serverURL + " "
        + String.valueOf(serverId);
     return "Undirect LDAP Server " + str;
   }
@@ -202,11 +251,11 @@
   {
     ArrayList<Attribute> attributes = new ArrayList<Attribute>();
 
-    attributes.add(new Attribute("server-id",
+    attributes.add(Attributes.create("server-id",
         String.valueOf(serverId)));
-    attributes.add(new Attribute("base-dn",
+    attributes.add(Attributes.create("base-dn",
         rsDomain.getBaseDn().toNormalizedString()));
-    attributes.add(new Attribute("connected-to",
+    attributes.add(Attributes.create("connected-to",
         replServerHandler.getMonitorInstanceName()));
 
     // Retrieves the topology counters
@@ -222,42 +271,37 @@
       }
 
       /* get the Server State */
-      final String ATTR_SERVER_STATE = "server-state";
-      AttributeType type =
-        DirectoryServer.getDefaultAttributeType(ATTR_SERVER_STATE);
-      LinkedHashSet<AttributeValue> values =
-        new LinkedHashSet<AttributeValue>();
+      AttributeBuilder builder = new AttributeBuilder("server-state");
       for (String str : remoteState.toStringSet())
       {
-        values.add(new AttributeValue(type,str));
+        builder.add(str);
       }
-      if (values.size() == 0)
+      if (builder.size() == 0)
       {
-        values.add(new AttributeValue(type,"unknown"));
+        builder.add("unknown");
       }
-      Attribute attr = new Attribute(type, ATTR_SERVER_STATE, values);
-      attributes.add(attr);
+      attributes.add(builder.toAttribute());
 
       // Oldest missing update
       Long approxFirstMissingDate=md.getApproxFirstMissingDate(serverId);
       if ((approxFirstMissingDate != null) && (approxFirstMissingDate>0))
       {
         Date date = new Date(approxFirstMissingDate);
-        attributes.add(new Attribute("approx-older-change-not-synchronized",
-          date.toString()));
-        attributes.add(
-            new Attribute("approx-older-change-not-synchronized-millis",
-            String.valueOf(approxFirstMissingDate)));
+        attributes.add(Attributes.create(
+            "approx-older-change-not-synchronized", date.toString()));
+        attributes.add(Attributes.create(
+            "approx-older-change-not-synchronized-millis", String
+                .valueOf(approxFirstMissingDate)));
       }
 
       // Missing changes
       long missingChanges = md.getMissingChanges(serverId);
-      attributes.add(new Attribute("missing-changes",
+      attributes.add(Attributes.create("missing-changes",
           String.valueOf(missingChanges)));
 
       // Replication delay
       long delay = md.getApproxDelay(serverId);
-      attributes.add(new Attribute("approximate-delay",
+      attributes.add(Attributes.create("approximate-delay",
           String.valueOf(delay)));
 
     }
@@ -265,7 +309,7 @@
     {
       // TODO: improve the log
       // We failed retrieving the remote monitor data.
-      attributes.add(new Attribute("error",
+      attributes.add(Attributes.create("error",
         stackTraceToSingleLineString(e)));
     }
     return attributes;

--
Gitblit v1.10.0