From b4f8838b15342670c31753a484abf0129e3c9653 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...

---
 opendj-sdk/opends/src/server/org/opends/server/api/ClientConnection.java |  141 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 138 insertions(+), 3 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/api/ClientConnection.java b/opendj-sdk/opends/src/server/org/opends/server/api/ClientConnection.java
index e35379c..815f009 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/api/ClientConnection.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/api/ClientConnection.java
@@ -43,7 +43,7 @@
 import org.opends.server.core.PersistentSearch;
 import org.opends.server.core.PluginConfigManager;
 import org.opends.server.core.SearchOperation;
-import org.opends.server.core.NetworkGroup;
+import org.opends.server.core.networkgroups.NetworkGroup;
 import org.opends.server.loggers.debug.DebugTracer;
 import org.opends.server.types.AbstractOperation;
 import org.opends.server.types.Attribute;
@@ -131,6 +131,8 @@
   // The network group to which the connection belongs to.
   private NetworkGroup networkGroup;
 
+  /** Need to evaluate the network group for the first operation. */
+  protected boolean mustEvaluateNetworkGroup;
 
 
   /**
@@ -152,6 +154,18 @@
     finalized          = false;
     privileges         = new HashSet<Privilege>();
     networkGroup       = NetworkGroup.getDefaultNetworkGroup();
+    networkGroup.addConnection(this);
+    mustEvaluateNetworkGroup = true;
+    if (debugEnabled())
+      {
+        Message message =
+                INFO_CHANGE_NETWORK_GROUP.get(
+                  getConnectionID(),
+                  "null",
+                  networkGroup.getID());
+        TRACER.debugMessage(DebugLogLevel.INFO, message.toString());
+      }
+
   }
 
 
@@ -206,6 +220,8 @@
            authZEntry.getDN(), this);
     }
 
+    networkGroup.removeConnection(this);
+
     try
     {
       finalizeClientConnection();
@@ -313,6 +329,40 @@
 
 
   /**
+   * Retrieves the port number for this connection on the client
+   * system if available.
+   *
+   * @return The port number for this connection on the client system
+   *         or -1 if there is no client port associated with this
+   *         connection (e.g. internal client).
+   */
+  public abstract int getClientPort();
+
+
+
+  /**
+   * Retrieves the address and port (if available) of the client
+   * system, separated by a colon.
+   *
+   * @return The address and port of the client system, separated by a
+   *         colon.
+   */
+  public final String getClientHostPort()
+  {
+    int port = getClientPort();
+    if (port >= 0)
+    {
+      return getClientAddress() + ":" + port;
+    }
+    else
+    {
+      return getClientAddress();
+    }
+  }
+
+
+
+  /**
    * Retrieves a string representation of the address on the server to
    * which the client connected.
    *
@@ -323,6 +373,41 @@
 
 
 
+
+  /**
+   * Retrieves the port number for this connection on the server
+   * system if available.
+   *
+   * @return The port number for this connection on the server system
+   *         or -1 if there is no server port associated with this
+   *         connection (e.g. internal client).
+   */
+  public abstract int getServerPort();
+
+
+
+  /**
+   * Retrieves the address and port of the server system, separated by
+   * a colon.
+   *
+   * @return The address and port of the server system, separated by a
+   *         colon.
+   */
+  public final String getServerHostPort()
+  {
+    int port = getServerPort();
+    if (port >= 0)
+    {
+      return getServerAddress() + ":" + port;
+    }
+    else
+    {
+      return getServerAddress();
+    }
+  }
+
+
+
   /**
    * Retrieves the {@code java.net.InetAddress} associated with the
    * remote client system.
@@ -445,6 +530,34 @@
 
 
   /**
+   * Retrieves the total number of operations performed
+   * on this connection.
+   *
+   * @return The total number of operations performed
+   * on this connection.
+   */
+  public abstract long getNumberOfOperations();
+
+  /**
+   * Indicates whether the network group must be evaluated for
+   * the next connection.
+   * @return boolean indicating if the network group must be evaluated
+   */
+  public boolean mustEvaluateNetworkGroup() {
+    return mustEvaluateNetworkGroup;
+  }
+
+  /**
+   * Indicates that the network group will have to be evaluated
+   * for the next connection.
+   *
+   * @param bool true if the network group must be evaluated
+   */
+  public void mustEvaluateNetworkGroup(boolean bool) {
+      mustEvaluateNetworkGroup = bool;
+  }
+
+  /**
    * Indicates that the data in the provided buffer has been read from
    * the client and should be processed.  The contents of the provided
    * buffer will be in clear-text (the data may have been passed
@@ -1180,7 +1293,7 @@
     {
       for (Attribute a : attrList)
       {
-        for (AttributeValue v : a.getValues())
+        for (AttributeValue v : a)
         {
           String privName = toLowerCase(v.getStringValue());
 
@@ -1640,7 +1753,29 @@
    */
   public final void setNetworkGroup (NetworkGroup networkGroup)
   {
-    this.networkGroup = networkGroup;
+    if (this.networkGroup != networkGroup) {
+      if (debugEnabled())
+      {
+        Message message =
+                INFO_CHANGE_NETWORK_GROUP.get(
+                  getConnectionID(),
+                  this.networkGroup.getID(),
+                  networkGroup.getID());
+        TRACER.debugMessage(DebugLogLevel.INFO, message.toString());
+      }
+
+      // If there is a change, first remove this connection
+      // from the current network group
+      this.networkGroup.removeConnection(this);
+      // Then set the new network group
+      this.networkGroup = networkGroup;
+      // And add the connection to the new ng
+      this.networkGroup.addConnection(this);
+
+      // The client connection inherits the resource limits
+      sizeLimit = networkGroup.getSearchSizeLimit();
+      timeLimit = networkGroup.getSearchDurationLimit();
+    }
   }
 
 

--
Gitblit v1.10.0