From a2bed334c56bacef8140fd78baab9374084ecdf3 Mon Sep 17 00:00:00 2001
From: jdemendi <jdemendi@localhost>
Date: Tue, 06 Jan 2009 09:55:26 +0000
Subject: [PATCH] add support of the client connection affinity

---
 opends/src/server/org/opends/server/core/networkgroups/NetworkGroup.java |   63 +++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 1 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/networkgroups/NetworkGroup.java b/opends/src/server/org/opends/server/core/networkgroups/NetworkGroup.java
index ecc8e71..ba44c8b 100644
--- a/opends/src/server/org/opends/server/core/networkgroups/NetworkGroup.java
+++ b/opends/src/server/org/opends/server/core/networkgroups/NetworkGroup.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2007-2008 Sun Microsystems, Inc.
+ *      Copyright 2007-2009 Sun Microsystems, Inc.
  */
 package org.opends.server.core.networkgroups;
 
@@ -141,6 +141,13 @@
   // The statistics
   private NetworkGroupStatistics stats;
 
+  // The client connection affinity policy.
+  private ClientConnectionAffinityPolicy affinityPolicy = null;
+
+  // The client connection affinity timeout (number of seconds).
+  private long affinityTimeout = 0;
+
+
   /**
    * Creates a new instance of the network group.
    *
@@ -731,6 +738,34 @@
   }
 
   /**
+   * Sets the affinity policy. The client connection affinity is the ability
+   * for the server to bypass a route algorithm like "load balancing" so
+   * that a request is always sent to the same data source regardless the
+   * route algorithm.
+   *
+   * @param  affinityPolicy
+   *         The client connection affinity policy of the network group.
+   */
+  public void setAffinityPolicy(
+      ClientConnectionAffinityPolicy affinityPolicy)
+  {
+    this.affinityPolicy = affinityPolicy;
+  }
+
+  /**
+   * Sets the affinity timeout value. The client connection affinity, when
+   * set, remains active until the time out expires. When the time out
+   * value is set to 0 then an active affinity never expires.
+   *
+   * @param timeout
+   *        The affinity timeout value (0 means never expire).
+   */
+  public void setAffinityTimeout(long timeout)
+  {
+    this.affinityTimeout = timeout;
+  }
+
+  /**
    * Gets the highest priority matching network group.
    *
    * @param connection the client connection
@@ -899,6 +934,32 @@
   }
 
   /**
+   * Gets the affinity policy. The client connection affinity is the ability
+   * for the server to bypass a route algorithm like "load balancing" so
+   * that a request is always sent to the same data source regardless the
+   * route algorithm.
+   *
+   * @return the client connection affinity policy of the network group
+   */
+  public ClientConnectionAffinityPolicy getAffinityPolicy()
+  {
+    return this.affinityPolicy;
+  }
+
+  /**
+   * Gets the affinity timeout value. The client connection affinity, when
+   * set, is active for a period of time. Once that period of time has
+   * expired, the client connection affinity is reset. A value of 0 means
+   * "no limit" - when an affinity is set it remains active for ever.
+   *
+   * @return the affinity timeout value (0 means no limit).
+   */
+  public long getAffinityTimeout()
+  {
+    return this.affinityTimeout;
+  }
+
+  /**
    * Checks the request filtering policy.
    * @param operation the operation to be checked
    * @param messages the error messages

--
Gitblit v1.10.0