Skip to content

Commit

Permalink
code clean up for donor-based rebalancing
Browse files Browse the repository at this point in the history
  • Loading branch information
Lei Gao committed Sep 9, 2011
1 parent b410087 commit 30d183a
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 71 deletions.
46 changes: 19 additions & 27 deletions config/test_config1/config/cluster.xml
@@ -1,27 +1,19 @@
<cluster>
<name>mycluster</name>
<server>
<id>0</id>
<host>localhost</host>
<http-port>8081</http-port>
<socket-port>6666</socket-port>
<admin-port>6667</admin-port>
<partitions>0, 1, 2</partitions>
</server>
<server>
<id>1</id>
<host>localhost</host>
<http-port>8082</http-port>
<socket-port>6668</socket-port>
<admin-port>6669</admin-port>
<partitions>3</partitions>
</server>
<server>
<id>2</id>
<host>localhost</host>
<http-port>8083</http-port>
<socket-port>6670</socket-port>
<admin-port>6671</admin-port>
<partitions />
</server>
</cluster>
<cluster>
<name>mycluster</name>
<server>
<id>0</id>
<host>localhost</host>
<http-port>8081</http-port>
<socket-port>6666</socket-port>
<admin-port>6667</admin-port>
<partitions>0, 1</partitions>
</server>
<server>
<id>1</id>
<host>localhost</host>
<http-port>8082</http-port>
<socket-port>6668</socket-port>
<admin-port>6669</admin-port>
<partitions>2, 3</partitions>
</server>
</cluster>
46 changes: 19 additions & 27 deletions config/test_config2/config/cluster.xml
@@ -1,27 +1,19 @@
<cluster>
<name>mycluster</name>
<server>
<id>0</id>
<host>localhost</host>
<http-port>8081</http-port>
<socket-port>6666</socket-port>
<admin-port>6667</admin-port>
<partitions>0, 1, 2</partitions>
</server>
<server>
<id>1</id>
<host>localhost</host>
<http-port>8082</http-port>
<socket-port>6668</socket-port>
<admin-port>6669</admin-port>
<partitions>3</partitions>
</server>
<server>
<id>2</id>
<host>localhost</host>
<http-port>8083</http-port>
<socket-port>6670</socket-port>
<admin-port>6671</admin-port>
<partitions />
</server>
</cluster>
<cluster>
<name>mycluster</name>
<server>
<id>0</id>
<host>localhost</host>
<http-port>8081</http-port>
<socket-port>6666</socket-port>
<admin-port>6667</admin-port>
<partitions>0, 1</partitions>
</server>
<server>
<id>1</id>
<host>localhost</host>
<http-port>8082</http-port>
<socket-port>6668</socket-port>
<admin-port>6669</admin-port>
<partitions>2, 3</partitions>
</server>
</cluster>
13 changes: 6 additions & 7 deletions src/java/voldemort/VoldemortAdminTool.java
Expand Up @@ -684,9 +684,8 @@ private static void executeSetMetadata(Integer nodeId,
+ adminClient.getAdminClientCluster()
.getNodeById(currentNodeId)
.getId());
adminClient.updateRemoteMetadata(currentNodeId,
key,
Versioned.value(value.toString(), updatedVersion));
adminClient.updateRemoteMetadata(currentNodeId, key, Versioned.value(value.toString(),
updatedVersion));
}
}

Expand Down Expand Up @@ -747,10 +746,10 @@ private static void executeROMetadata(Integer nodeId,

}

public static void executeGetMetadata(Integer nodeId,
AdminClient adminClient,
String metadataKey,
String outputDir) throws IOException {
private static void executeGetMetadata(Integer nodeId,
AdminClient adminClient,
String metadataKey,
String outputDir) throws IOException {
File directory = null;
if(outputDir != null) {
directory = new File(outputDir);
Expand Down
2 changes: 1 addition & 1 deletion src/java/voldemort/VoldemortClientShell.java
Expand Up @@ -124,7 +124,7 @@ public static void main(String[] args) throws Exception {
System.out.println("Established connection to " + storeName + " via " + bootstrapUrl);
System.out.print(PROMPT);
if(fileReader != null) {
processCommands(factory, adminClient, fileReader, false);
processCommands(factory, adminClient, fileReader, true);
fileReader.close();
}
processCommands(factory, adminClient, inputReader, false);
Expand Down
6 changes: 6 additions & 0 deletions src/java/voldemort/utils/Entropy.java
Expand Up @@ -225,6 +225,9 @@ public void generateEntropy(Cluster cluster,
false);
for(long keyId = 0; keyId < numKeysPerNode && keys.hasNext(); keyId++) {
ByteArray key = keys.next();
// entropy returns distinct keys from each
// node - record the key only if this node
// holds the primary partition of the key
if(RebalanceUtils.getNodeIds(strategy.routeRequest(key.get())
.subList(0, 1))
.contains(node.getId())) {
Expand All @@ -251,6 +254,9 @@ public void generateEntropy(Cluster cluster,
false);
while(keys.hasNext() && numKeysStored < numKeys) {
ByteArray key = keys.next();
// entropy returns distinct keys from each
// node - record the key only if this node
// holds the primary partition of the key
if(RebalanceUtils.getNodeIds(strategy.routeRequest(key.get())
.subList(0, 1))
.contains(nodeId)) {
Expand Down
11 changes: 2 additions & 9 deletions src/java/voldemort/utils/RebalanceUtils.java
Expand Up @@ -645,18 +645,11 @@ public static boolean containsPreferenceList(Cluster cluster,
* Updates the existing cluster such that we remove partitions mentioned
* from the stealer node and add them to the donor node
*
* <<<<<<< HEAD
*
* @param currentCluster Existing cluster metadata. Both stealer and donor
* node should already exist in this metadata
* @param stealerNodeId Id of node from which we are stealing the partitions
* @param donorNodeId Id of node to which we are donating
* @param donatedPartitions List of partitions we are moving =======
* @param cluster Existing cluster metadata
* @param stealerNode Node which steals the partitions from another node
* @param donorNode Node which donates partitions to the stealer
* @param partitionList List of partitions we are moving >>>>>>>
* upstream/master
* @param donatedPartitions List of partitions we are moving
* @param partitionList List of partitions we are moving
* @return Updated cluster metadata
*/
public static Cluster createUpdatedCluster(Cluster currentCluster,
Expand Down

0 comments on commit 30d183a

Please sign in to comment.