use of voldemort.routing.StoreRoutingPlan in project voldemort by voldemort.
the class ClusterForkLiftToolTest method testPrimaryResolvingForkLift.
@Test
public void testPrimaryResolvingForkLift() throws Exception {
StoreRoutingPlan srcStoreInstance = new StoreRoutingPlan(srcCluster, primaryResolvingStoreDef);
// populate data on the source cluster..
for (Map.Entry<String, String> entry : kvPairs.entrySet()) {
srcPrimaryResolvingStoreClient.put(entry.getKey(), entry.getValue());
}
// generate a conflict on the master partition
int masterNode = srcStoreInstance.getNodeIdForPartitionId(srcStoreInstance.getMasterPartitionId(conflictKey.getBytes("UTF-8")));
VectorClock losingClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 0, 5)), System.currentTimeMillis());
VectorClock winningClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 1, 5)), losingClock.getTimestamp() + 1);
srcAdminClient.storeOps.putNodeKeyValue(PRIMARY_RESOLVING_STORE_NAME, new NodeValue<ByteArray, byte[]>(masterNode, new ByteArray(conflictKey.getBytes("UTF-8")), new Versioned<byte[]>("losing value".getBytes("UTF-8"), losingClock)));
srcAdminClient.storeOps.putNodeKeyValue(PRIMARY_RESOLVING_STORE_NAME, new NodeValue<ByteArray, byte[]>(masterNode, new ByteArray(conflictKey.getBytes("UTF-8")), new Versioned<byte[]>("winning value".getBytes("UTF-8"), winningClock)));
// do a write to destination cluster
dstPrimaryResolvingStoreClient.put(firstKey, "before forklift");
// perform the forklifting..
ClusterForkLiftTool forkLiftTool = new ClusterForkLiftTool(srcBootStrapUrl, dstBootStrapUrl, false, // ignoreSchemaMismatch
false, 10000, 1, 1000, Lists.newArrayList(PRIMARY_RESOLVING_STORE_NAME), null, ClusterForkLiftTool.ForkLiftTaskMode.primary_resolution);
forkLiftTool.run();
// do a write to destination cluster
dstPrimaryResolvingStoreClient.put(lastKey, "after forklift");
// verify data on the destination is as expected
for (Map.Entry<String, String> entry : kvPairs.entrySet()) {
if (entry.getKey().equals(firstKey)) {
assertEquals("Online write overwritten", dstPrimaryResolvingStoreClient.get(firstKey).getValue(), "before forklift");
} else if (entry.getKey().equals(lastKey)) {
assertEquals("can't update value after forklift", dstPrimaryResolvingStoreClient.get(lastKey).getValue(), "after forklift");
} else if (entry.getKey().equals(conflictKey)) {
assertEquals("Conflict resolution incorrect", dstPrimaryResolvingStoreClient.get(conflictKey).getValue(), "winning value");
} else {
assertEquals("fork lift data missing", dstPrimaryResolvingStoreClient.get(entry.getKey()).getValue(), entry.getValue());
}
}
}
use of voldemort.routing.StoreRoutingPlan in project voldemort by voldemort.
the class ClusterForkLiftToolTest method testNoresolutionForkLift.
@Test
public void testNoresolutionForkLift() throws Exception {
int versions = 0;
StoreRoutingPlan srcStoreInstance = new StoreRoutingPlan(srcCluster, nonResolvingStoreDef);
// generate a conflict on the master partition
int masterNode = srcStoreInstance.getNodeIdForPartitionId(srcStoreInstance.getMasterPartitionId(conflictKey.getBytes("UTF-8")));
VectorClock losingClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 0, 5)), System.currentTimeMillis());
VectorClock winningClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 1, 5)), losingClock.getTimestamp() + 1);
srcAdminClient.storeOps.putNodeKeyValue(MULTIPLE_VERSIONS_STORE_NAME, new NodeValue<ByteArray, byte[]>(masterNode, new ByteArray(conflictKey.getBytes("UTF-8")), new Versioned<byte[]>("losing value".getBytes("UTF-8"), losingClock)));
srcAdminClient.storeOps.putNodeKeyValue(MULTIPLE_VERSIONS_STORE_NAME, new NodeValue<ByteArray, byte[]>(masterNode, new ByteArray(conflictKey.getBytes("UTF-8")), new Versioned<byte[]>("winning value".getBytes("UTF-8"), winningClock)));
// perform the forklifting..
ClusterForkLiftTool forkLiftTool = new ClusterForkLiftTool(srcBootStrapUrl, dstBootStrapUrl, false, // ignoreSchemaMismatch
false, 10000, 1, 1000, Lists.newArrayList(MULTIPLE_VERSIONS_STORE_NAME), null, ClusterForkLiftTool.ForkLiftTaskMode.no_resolution);
forkLiftTool.run();
AdminClient dstAdminClient = new AdminClient(dstBootStrapUrl);
for (Node node : dstAdminClient.getAdminClientCluster().getNodes()) {
Iterator<Pair<ByteArray, Versioned<byte[]>>> entryItr = dstAdminClient.bulkFetchOps.fetchEntries(node.getId(), MULTIPLE_VERSIONS_STORE_NAME, node.getPartitionIds(), null, true);
while (entryItr.hasNext()) {
Pair<ByteArray, Versioned<byte[]>> record = entryItr.next();
ByteArray key = record.getFirst();
Versioned<byte[]> versioned = record.getSecond();
versions++;
}
}
assertEquals("Both conflicting versions present", versions, 2);
}
use of voldemort.routing.StoreRoutingPlan in project voldemort by voldemort.
the class VersionedPutPruningTest method setup.
@Before
public void setup() throws Exception {
cluster = VoldemortTestConstants.getNineNodeCluster();
StringReader reader = new StringReader(VoldemortTestConstants.getSingleStore322Xml());
storeDef = new StoreDefinitionsMapper().readStoreList(reader).get(0);
routingPlan = new StoreRoutingPlan(cluster, storeDef);
key = "key1".getBytes();
keyReplicas = Lists.newArrayList(0, 2, 1);
}
use of voldemort.routing.StoreRoutingPlan in project voldemort by voldemort.
the class FetchPartitionFileStreamRequestHandler method handleNextPartition.
private StreamRequestHandlerState handleNextPartition() {
StreamRequestHandlerState handlerState = StreamRequestHandlerState.WRITING;
if (partitionIterator.hasNext()) {
// Start a new partition
Integer partitionId = partitionIterator.next();
int nodeId = metadataStore.getNodeId();
int zoneId = metadataStore.getCluster().getNodeById(nodeId).getZoneId();
StoreDefinition storeDef = metadataStore.getStoreDef(request.getStoreName());
StoreRoutingPlan storeRoutingPlan = new StoreRoutingPlan(metadataStore.getCluster(), storeDef);
int getZoneNary = storeRoutingPlan.getZoneNaryForNodesPartition(zoneId, nodeId, partitionId);
currentPair = Pair.create(getZoneNary, partitionId);
currentChunkId = 0;
// First check if bucket exists
if (!bucketToNumChunks.containsKey(Pair.create(currentPair.getSecond(), currentPair.getFirst()))) {
throw new VoldemortException("Bucket [ partition = " + currentPair.getSecond() + ", replica = " + currentPair.getFirst() + " ] does not exist for store " + request.getStoreName());
}
numChunks = bucketToNumChunks.get(Pair.create(currentPair.getSecond(), currentPair.getFirst()));
dataFile = indexFile = null;
fetchStatus = FetchStatus.SEND_DATA_FILE;
} else {
// We are done since we have gone through the entire
// partition list
logger.info("Finished streaming files for partitions tuples " + partitionIds);
handlerState = StreamRequestHandlerState.COMPLETE;
}
return handlerState;
}
Aggregations