use of voldemort.versioning.VectorClock in project voldemort by voldemort.
the class AbstractRequestFormatTest method testGetAllRequests.
@Test
public void testGetAllRequests() throws Exception {
testGetAllRequest(new ByteArray[] {}, new byte[][] {}, null, new VectorClock[] {}, new boolean[] {});
testGetAllRequest(new ByteArray[] { new ByteArray() }, new byte[][] { new byte[] {} }, null, new VectorClock[] { new VectorClock() }, new boolean[] { true });
testGetAllRequest(new ByteArray[] { TestUtils.toByteArray("hello") }, new byte[][] { "world".getBytes() }, null, new VectorClock[] { new VectorClock() }, new boolean[] { true });
testGetAllRequest(new ByteArray[] { TestUtils.toByteArray("hello"), TestUtils.toByteArray("holly") }, new byte[][] { "world".getBytes(), "cow".getBytes() }, null, new VectorClock[] { TestUtils.getClock(1, 1), TestUtils.getClock(1, 2) }, new boolean[] { true, false });
}
use of voldemort.versioning.VectorClock in project voldemort by voldemort.
the class AbstractRequestFormatTest method testPutRequests.
@Test
public void testPutRequests() throws Exception {
testPutRequest(new ByteArray(), new byte[0], null, new VectorClock(), null, true);
testPutRequest(TestUtils.toByteArray("hello"), "world".getBytes(), null, new VectorClock(), null, false);
testPutRequest(TestUtils.toByteArray("hello"), "world".getBytes(), null, new VectorClock(), ObsoleteVersionException.class, true);
}
use of voldemort.versioning.VectorClock in project voldemort by voldemort.
the class DefaultStoreClientTest method testDeleteVersion.
@Test
public void testDeleteVersion() {
assertFalse("Delete of non-existant key should be false.", client.delete("k", new VectorClock()));
client.put("k", new Versioned<String>("v"));
assertFalse("Delete of a lesser version should be false.", client.delete("k", new VectorClock()));
assertNotNull("After failed delete, value should still be there.", client.get("k"));
assertTrue("Delete of k, with the current version should succeed.", client.delete("k", new VectorClock().incremented(nodeId, time.getMilliseconds())));
assertNull("After a successful delete(k), get(k) should return null.", client.get("k"));
}
use of voldemort.versioning.VectorClock in project voldemort by voldemort.
the class RebalanceRebootstrapConsistencyTest method rebalance.
/*
* simulate rebalance behavior
*/
public void rebalance() {
assert servers != null && servers.size() > 1;
VoldemortConfig config = servers.get(0).getVoldemortConfig();
adminClient = AdminClient.createTempAdminClient(config, cluster, 4);
List<Integer> partitionIds = ImmutableList.of(0, 1);
int req = adminClient.storeMntOps.migratePartitions(0, 1, testStoreNameRW, partitionIds, null, null);
adminClient.rpcOps.waitForCompletion(1, req, 5, TimeUnit.SECONDS);
Versioned<Cluster> versionedCluster = adminClient.metadataMgmtOps.getRemoteCluster(0);
Node node0 = versionedCluster.getValue().getNodeById(0);
Node node1 = versionedCluster.getValue().getNodeById(1);
Node newNode0 = new Node(node0.getId(), node0.getHost(), node0.getHttpPort(), node0.getSocketPort(), node0.getAdminPort(), ImmutableList.<Integer>of());
Node newNode1 = new Node(node1.getId(), node1.getHost(), node1.getHttpPort(), node1.getSocketPort(), node1.getAdminPort(), ImmutableList.of(0, 1));
adminClient.storeMntOps.deletePartitions(0, testStoreNameRW, ImmutableList.of(0, 1), null);
newCluster = new Cluster(cluster.getName(), ImmutableList.of(newNode0, newNode1), Lists.newArrayList(cluster.getZones()));
newstoredefs = new ArrayList<StoreDefinition>();
newstoredefs.add(rwStoreDefWithReplication2);
for (Node node : cluster.getNodes()) {
VectorClock clock = (VectorClock) versionedCluster.getVersion();
clock.incrementVersion(node.getId(), System.currentTimeMillis());
adminClient.metadataMgmtOps.updateRemoteMetadata(node.getId(), MetadataStore.STORES_KEY, new Versioned<String>(storeMapper.writeStoreList(newstoredefs), clock));
adminClient.metadataMgmtOps.updateRemoteMetadata(node.getId(), MetadataStore.CLUSTER_KEY, new Versioned<String>(clusterMapper.writeCluster(newCluster), clock));
}
adminClient.metadataMgmtOps.updateMetadataversion(adminClient.getAdminClientCluster().getNodeIds(), CLUSTER_VERSION_KEY);
}
use of voldemort.versioning.VectorClock in project voldemort by voldemort.
the class VoldemortServer method getTestMetadataStore.
private static MetadataStore getTestMetadataStore(VoldemortConfig voldemortConfig, Cluster cluster) {
ConfigurationStorageEngine metadataInnerEngine = new ConfigurationStorageEngine("metadata-config-store", voldemortConfig.getMetadataDirectory());
List<Versioned<String>> clusterXmlValue = metadataInnerEngine.get(MetadataStore.CLUSTER_KEY, null);
VectorClock version = null;
if (clusterXmlValue.size() <= 0) {
version = new VectorClock();
} else {
version = (VectorClock) clusterXmlValue.get(0).getVersion();
}
int nodeId = getNodeId(voldemortConfig, cluster);
version.incrementVersion(nodeId, System.currentTimeMillis());
metadataInnerEngine.put(MetadataStore.CLUSTER_KEY, new Versioned<String>(new ClusterMapper().writeCluster(cluster), version), null);
return MetadataStore.createInMemoryMetadataStore(metadataInnerEngine, nodeId);
}
Aggregations