Skip to content
This repository has been archived by the owner on Jun 23, 2020. It is now read-only.

Commit

Permalink
Continued refactoring and clearing out deprecated code.
Browse files Browse the repository at this point in the history
OrderedClusterTransition
- removed unnecessary members:
  id
  currentCluster
  targetCluster
  rebalanceclusterPlan
  storeDefs

RebalanceController
- renamed some member variables for sake of clarity
- switched from orderedClusterTransition.getId to batchCount to uniquely ID batches of work...

RebalanceNodePlan
- added TODOs
- removed unnecessary members:
  attempt
  storeToReplicaToDeletePartitionList

Patched up all tests to not have 'compile time' errors. Have not run tests though...
  • Loading branch information
jayjwylie committed Jun 20, 2013
1 parent 70f8259 commit c1c367e
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 433 deletions.
6 changes: 1 addition & 5 deletions src/java/voldemort/client/protocol/pb/ProtoUtils.java
Expand Up @@ -99,9 +99,7 @@ public static RebalancePartitionsInfo decodeRebalancePartitionInfoMap(VAdminProt
RebalancePartitionsInfo rebalanceStealInfo = new RebalancePartitionsInfo(rebalancePartitionInfoMap.getStealerId(),
rebalancePartitionInfoMap.getDonorId(),
decodePerStorePartitionTuple(rebalancePartitionInfoMap.getReplicaToAddPartitionList()),
decodePerStorePartitionTuple(rebalancePartitionInfoMap.getReplicaToDeletePartitionList()),
new ClusterMapper().readCluster(new StringReader(rebalancePartitionInfoMap.getInitialCluster())),
rebalancePartitionInfoMap.getAttempt());
new ClusterMapper().readCluster(new StringReader(rebalancePartitionInfoMap.getInitialCluster())));
return rebalanceStealInfo;
}

Expand All @@ -116,9 +114,7 @@ public static RebalancePartitionInfoMap encodeRebalancePartitionInfoMap(Rebalanc
.setStealerId(stealInfo.getStealerId())
.setDonorId(stealInfo.getDonorId())
.addAllReplicaToAddPartition(ProtoUtils.encodePerStorePartitionTuple(stealInfo.getStoreToReplicaToAddPartitionList()))
.addAllReplicaToDeletePartition(ProtoUtils.encodePerStorePartitionTuple(stealInfo.getStoreToReplicaToDeletePartitionList()))
.setInitialCluster(new ClusterMapper().writeCluster(stealInfo.getInitialCluster()))
.setAttempt(stealInfo.getAttempt())
.build();
}

Expand Down
Expand Up @@ -3,12 +3,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.atomic.AtomicInteger;

import voldemort.cluster.Cluster;
import voldemort.store.StoreDefinition;
import voldemort.utils.ByteArray;
import voldemort.utils.KeyDistributionGenerator;
import voldemort.utils.Utils;

import com.google.common.collect.Lists;
Expand All @@ -24,62 +19,14 @@
*/
public class OrderedClusterTransition {

// TODO: (refactor) What is the value of this idGen member? It is only used
// in print outs? If it has no value, then remove it. (Same with member
// 'id')
private static final AtomicInteger idGen = new AtomicInteger(0);
private final Cluster currentCluster;
private final Cluster targetCluster;
private final RebalanceTypedBatchPlan rebalanceClusterPlan;
private final List<RebalancePartitionsInfo> orderedRebalancePartitionsInfoList;
private final List<StoreDefinition> storeDefs;
private String printedContent;
private final int id;

@Deprecated
public OrderedClusterTransition(final Cluster currentCluster,
final Cluster targetCluster,
List<StoreDefinition> storeDefs,
final RebalanceTypedBatchPlan rebalanceClusterPlan) {
this.id = idGen.incrementAndGet();
this.currentCluster = currentCluster;
this.targetCluster = targetCluster;
this.storeDefs = storeDefs;
this.rebalanceClusterPlan = rebalanceClusterPlan;
this.orderedRebalancePartitionsInfoList = orderedClusterPlan(rebalanceClusterPlan);
}

@Deprecated
public OrderedClusterTransition(final RebalanceTypedBatchPlan rebalanceClusterPlan) {
this.id = idGen.incrementAndGet();
/*-
this.currentCluster = rebalanceClusterPlan.getCurrentCluster();
this.targetCluster = rebalanceClusterPlan.getFinalCluster();
this.storeDefs = rebalanceClusterPlan.getStoreDefs();
*/
this.currentCluster = null;
this.targetCluster = null;
this.storeDefs = null;
this.rebalanceClusterPlan = rebalanceClusterPlan;
this.orderedRebalancePartitionsInfoList = orderedClusterPlan(rebalanceClusterPlan);
}

public List<StoreDefinition> getStoreDefs() {
return this.storeDefs;
}

public int getId() {
return id;
}

public Cluster getTargetCluster() {
return targetCluster;
}

public Cluster getCurrentCluster() {
return currentCluster;
}

public List<RebalancePartitionsInfo> getOrderedRebalancePartitionsInfoList() {
return orderedRebalancePartitionsInfoList;
}
Expand All @@ -88,24 +35,7 @@ public List<RebalancePartitionsInfo> getOrderedRebalancePartitionsInfoList() {
public String toString() {
if(printedContent == null) {
StringBuilder sb = new StringBuilder();
List<ByteArray> keys = KeyDistributionGenerator.generateKeys(KeyDistributionGenerator.DEFAULT_NUM_KEYS);
sb.append("- Rebalance Task Id : ").append(getId()).append(Utils.NEWLINE);
sb.append("- Current cluster : ")
.append(KeyDistributionGenerator.printOverallDistribution(getCurrentCluster(),
getStoreDefs(),
keys))
.append(Utils.NEWLINE);
sb.append("- Target cluster : ")
.append(KeyDistributionGenerator.printOverallDistribution(getTargetCluster(),
getStoreDefs(),
keys))
.append(Utils.NEWLINE);
/*-
sb.append("- Partition distribution : ")
.append(Utils.NEWLINE)
.append(getRebalanceClusterPlan().printPartitionDistribution())
.append(Utils.NEWLINE);
*/
sb.append("- OrderedClusterTransition ").append(Utils.NEWLINE);
sb.append("- Ordered rebalance node plan : ")
.append(Utils.NEWLINE)
.append(printRebalanceNodePlan(getOrderedRebalancePartitionsInfoList()));
Expand All @@ -122,10 +52,6 @@ private String printRebalanceNodePlan(List<RebalancePartitionsInfo> rebalancePar
return builder.toString();
}

private RebalanceTypedBatchPlan getRebalanceClusterPlan() {
return rebalanceClusterPlan;
}

/**
* Given a {@link RebalanceClusterPlan}, extracts the queue of
* {@link RebalanceNodePlan} and finally orders it
Expand Down
Expand Up @@ -235,9 +235,7 @@ public List<RebalancePartitionsInfo> shovelCrapOut() {
result.add(new RebalancePartitionsInfo(stealerDonor.getFirst(),
stealerDonor.getSecond(),
stealerDonorToStoreToStealPartition.get(stealerDonor),
new HashMap<String, HashMap<Integer, List<Integer>>>(),
targetCluster,
0));
targetCluster));
}
return result;
}
Expand Down

0 comments on commit c1c367e

Please sign in to comment.