Created
March 8, 2011 23:14
-
-
Save rsumbaly/861332 to your computer and use it in GitHub Desktop.
invokeUpdateClusterMetadata in AdminStoreSwapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void invokeUpdateClusterMetadata() { | |
Versioned<Cluster> latestCluster = new Versioned<Cluster>(adminClient.getAdminClientCluster()); | |
List<Integer> requiredNodeIds = new ArrayList<Integer>(); | |
ArrayList<Versioned<Cluster>> clusterList = new ArrayList<Versioned<Cluster>>(); | |
clusterList.add(latestCluster); | |
boolean sameCluster = true; | |
for(Node node: adminClient.getAdminClientCluster().getNodes()) { | |
requiredNodeIds.add(node.getId()); | |
try { | |
Versioned<Cluster> versionedCluster = adminClient.getRemoteCluster(node.getId()); | |
VectorClock newClock = (VectorClock) versionedCluster.getVersion(); | |
if(null != newClock && !clusterList.contains(versionedCluster)) { | |
if(sameCluster | |
&& !adminClient.getAdminClientCluster().equals(versionedCluster.getValue())) { | |
sameCluster = false; | |
} | |
// check no two clocks are concurrent. | |
RebalanceUtils.checkNotConcurrent(clusterList, newClock); | |
// add to clock list | |
clusterList.add(versionedCluster); | |
// update latestClock | |
Occured occured = newClock.compare(latestCluster.getVersion()); | |
if(Occured.AFTER.equals(occured)) | |
latestCluster = versionedCluster; | |
} | |
} catch(Exception e) { | |
throw new VoldemortException("Failed to get cluster metadata from node:" + node, e); | |
} | |
} | |
if(!sameCluster) { | |
VectorClock latestClock = (VectorClock) latestCluster.getVersion(); | |
latestClock.incrementVersion(cluster.getNodes().iterator().next().getId(), | |
System.currentTimeMillis()); | |
RebalanceUtils.propagateCluster(adminClient, cluster, latestClock, requiredNodeIds); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment