From 874f6e3a092bdaa5f151c512c9284b15f5886e82 Mon Sep 17 00:00:00 2001
From: mrossign <mrossign@localhost>
Date: Tue, 19 Jan 2010 09:53:03 +0000
Subject: [PATCH] This is about refactoring the way the directory server chooses the replication server it will connect to. This also introduces a new (weighed) load balancing feature that spreads DS connections across the RSs, according to the RS weights defined by the administrator,
---
opends/src/server/org/opends/server/replication/protocol/TopologyMsg.java | 29 +++++++++++++++++------------
1 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/protocol/TopologyMsg.java b/opends/src/server/org/opends/server/replication/protocol/TopologyMsg.java
index 85a4d1d..c2c777b 100644
--- a/opends/src/server/org/opends/server/replication/protocol/TopologyMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/TopologyMsg.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2007-2009 Sun Microsystems, Inc.
+ * Copyright 2007-2010 Sun Microsystems, Inc.
*/
package org.opends.server.replication.protocol;
@@ -198,6 +198,10 @@
if (version >= ProtocolVersion.REPLICATION_PROTOCOL_V4)
{
+ // Put server URL
+ oStream.write(rsInfo.getServerUrl().getBytes("UTF-8"));
+ oStream.write(0);
+
// Put RS weight
oStream.write(String.valueOf(rsInfo.getWeight()).getBytes("UTF-8"));
oStream.write(0);
@@ -242,8 +246,7 @@
int length = getNextLength(in, pos);
String serverIdString = new String(in, pos, length, "UTF-8");
int dsId = Integer.valueOf(serverIdString);
- pos +=
- length + 1;
+ pos += length + 1;
/* Read RS id */
length =
@@ -251,16 +254,14 @@
serverIdString =
new String(in, pos, length, "UTF-8");
int rsId = Integer.valueOf(serverIdString);
- pos +=
- length + 1;
+ pos += length + 1;
/* Read the generation id */
length = getNextLength(in, pos);
long generationId =
Long.valueOf(new String(in, pos, length,
"UTF-8"));
- pos +=
- length + 1;
+ pos += length + 1;
/* Read DS status */
ServerStatus status = ServerStatus.valueOf(in[pos++]);
@@ -296,8 +297,7 @@
length = getNextLength(in, pos);
String url = new String(in, pos, length, "UTF-8");
refUrls.add(url);
- pos +=
- length + 1;
+ pos += length + 1;
nRead++;
}
@@ -314,8 +314,7 @@
length = getNextLength(in, pos);
String attr = new String(in, pos, length, "UTF-8");
attrs.add(attr);
- pos +=
- length + 1;
+ pos += length + 1;
nRead++;
}
}
@@ -353,8 +352,13 @@
byte groupId = in[pos++];
int weight = 1;
+ String serverUrl = null;
if (version >= ProtocolVersion.REPLICATION_PROTOCOL_V4)
{
+ length = getNextLength(in, pos);
+ serverUrl = new String(in, pos, length, "UTF-8");
+ pos += length + 1;
+
/* Read RS weight */
length = getNextLength(in, pos);
weight = Integer.valueOf(new String(in, pos, length, "UTF-8"));
@@ -363,7 +367,8 @@
/* Now create RSInfo and store it in list */
- RSInfo rsInfo = new RSInfo(id, generationId, groupId, weight);
+ RSInfo rsInfo = new RSInfo(id, serverUrl, generationId, groupId,
+ weight);
rsList.add(rsInfo);
nRsInfo--;
--
Gitblit v1.10.0