Skip to content

Commit

Permalink
More work around Redirecting store, exchanging metadata, swapping rea…
Browse files Browse the repository at this point in the history
…d-only store
  • Loading branch information
rsumbaly committed Oct 1, 2010
1 parent c0fb423 commit 4c97e49
Show file tree
Hide file tree
Showing 21 changed files with 1,449 additions and 346 deletions.
75 changes: 75 additions & 0 deletions clients/python/voldemort_admin_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -191,6 +191,7 @@ public void testGracefulRecovery() throws Exception {
Arrays.asList(2,
3),
Arrays.asList(testStoreNameRW),
new HashMap<String, String>(),
0);
int requestId = adminClient.rebalanceNode(rebalancePartitionsInfo);
logger.info("started rebalanceNode, request id = " + requestId);
Expand Down
37 changes: 37 additions & 0 deletions src/java/voldemort/client/protocol/admin/AdminClient.java
Expand Up @@ -73,6 +73,7 @@
import voldemort.xml.StoreDefinitionsMapper;

import com.google.common.collect.AbstractIterator;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.protobuf.ByteString;
import com.google.protobuf.Message;
Expand Down Expand Up @@ -616,6 +617,7 @@ public int rebalanceNode(RebalancePartitionsInfo stealInfo) {
.addAllUnbalancedStore(stealInfo.getUnbalancedStoreList())
.addAllDeletePartitions(stealInfo.getDeletePartitionsList())
.addAllStealMasterPartitions(stealInfo.getStealMasterPartitions())
.addAllStoreToRODir(decodeROStoreVersionDirMap(stealInfo.getStoreToRODir()))
.build();
VAdminProto.VoldemortAdminRequest adminRequest = VAdminProto.VoldemortAdminRequest.newBuilder()
.setType(VAdminProto.AdminRequestType.INITIATE_REBALANCE_NODE)
Expand Down Expand Up @@ -1278,6 +1280,30 @@ public void swapStore(int nodeId, String storeName, String storeDir) {
return;
}

/**
* Swap multiple read-only stores and clear the rebalancing state
*
* @param nodeId The node id on which to swap the stores
* @param storeToDir A map of read-only store names with their respective
* directories
*/
public void swapStoresAndCleanState(int nodeId, Map<String, String> storeToDir) {
VAdminProto.SwapStoresAndCleanStateRequest.Builder swapStoreRequest = VAdminProto.SwapStoresAndCleanStateRequest.newBuilder()
.addAllRoStoreVersions(decodeROStoreVersionDirMap(storeToDir));

VAdminProto.VoldemortAdminRequest adminRequest = VAdminProto.VoldemortAdminRequest.newBuilder()
.setSwapStoresAndCleanState(swapStoreRequest)
.setType(VAdminProto.AdminRequestType.SWAP_STORES_AND_CLEAN_STATE)
.build();
VAdminProto.SwapStoresAndCleanStateResponse.Builder response = sendAndReceive(nodeId,
adminRequest,
VAdminProto.SwapStoresAndCleanStateResponse.newBuilder());
if(response.hasError()) {
throwException(response.getError());
}
return;
}

/**
* Returns the max version of push currently being used by read-only store.
* Important to remember that this may not be the 'current' version since
Expand Down Expand Up @@ -1382,6 +1408,17 @@ public Map<String, Long> getROCurrentVersion(int nodeId, List<String> storeNames
return returnMap;
}

private List<ROStoreVersionDirMap> decodeROStoreVersionDirMap(Map<String, String> storeVersionDirMap) {
List<ROStoreVersionDirMap> storeToVersionDir = Lists.newArrayList();
for(String storeName: storeVersionDirMap.keySet()) {
storeToVersionDir.add(ROStoreVersionDirMap.newBuilder()
.setStoreName(storeName)
.setStoreDir(storeVersionDirMap.get(storeName))
.build());
}
return storeToVersionDir;
}

private Map<String, String> encodeROStoreVersionDirMap(List<ROStoreVersionDirMap> storeVersionDirMap) {
Map<String, String> storeToVersionDir = Maps.newHashMap();
for(ROStoreVersionDirMap currentStore: storeVersionDirMap) {
Expand Down

0 comments on commit 4c97e49

Please sign in to comment.