From b1ab1b61b2a5cb4a09cd2e727e05f42feb8ca669 Mon Sep 17 00:00:00 2001
From: mrossign <mrossign@localhost>
Date: Fri, 06 Nov 2009 09:11:40 +0000
Subject: [PATCH] In order to support a more clever algorithm for the DS to choose his RS,  we introduce:

---
 opendj-sdk/opends/src/server/org/opends/server/replication/common/RSInfo.java |   30 +++++++++++++++++++++++++-----
 1 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/common/RSInfo.java b/opendj-sdk/opends/src/server/org/opends/server/replication/common/RSInfo.java
index 5b6d9e2..577ffd3 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/common/RSInfo.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/common/RSInfo.java
@@ -40,6 +40,11 @@
   private long generationId = -1;
   // Group id of the RS
   private byte groupId = (byte) -1;
+  // The weight of the RS
+  // It is important to keep the default value to 1 so that it is used as
+  // default value for a RS using protocol V3: this default value vill be used
+  // in algorithms that use weight
+  private int weight = 1;
 
   /**
    * Creates a new instance of RSInfo with every given info.
@@ -47,12 +52,14 @@
    * @param id The RS id
    * @param generationId The generation id the RS is using
    * @param groupId RS group id
+   * @param weight RS weight
    */
-  public RSInfo(int id, long generationId, byte groupId)
+  public RSInfo(int id, long generationId, byte groupId, int weight)
   {
     this.id = id;
     this.generationId = generationId;
     this.groupId = groupId;
+    this.weight = weight;
   }
 
   /**
@@ -83,6 +90,16 @@
   }
 
   /**
+   * Get the RS weight.
+   * @return The RS weight
+   */
+  public int getWeight()
+  {
+    return weight;
+  }
+
+
+  /**
    * Test if the passed object is equal to this one.
    * @param obj The object to test
    * @return True if both objects are equal
@@ -99,7 +116,8 @@
       RSInfo rsInfo = (RSInfo) obj;
       return ((id == rsInfo.getId()) &&
         (generationId == rsInfo.getGenerationId()) &&
-        (groupId == rsInfo.getGroupId()));
+        (groupId == rsInfo.getGroupId()) &&
+        (weight == rsInfo.getWeight()));
     } else
     {
       return false;
@@ -117,6 +135,7 @@
     hash = 37 * hash + this.id;
     hash = 37 * hash + (int) (this.generationId ^ (this.generationId >>> 32));
     hash = 37 * hash + this.groupId;
+    hash = 37 * hash + this.weight;
     return hash;
   }
 
@@ -130,11 +149,12 @@
     StringBuffer sb = new StringBuffer();
     sb.append("Id: ");
     sb.append(id);
-    sb.append(" Generation id: ");
+    sb.append(" ; Generation id: ");
     sb.append(generationId);
-    sb.append(" Group id: ");
+    sb.append(" ; Group id: ");
     sb.append(groupId);
+    sb.append(" ; Weight: ");
+    sb.append(weight);
     return sb.toString();
   }
-
 }

--
Gitblit v1.10.0