Search in sources :

Example 31 with VectorClock

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 });
}
Also used : VectorClock(voldemort.versioning.VectorClock) ByteArray(voldemort.utils.ByteArray) Test(org.junit.Test)

Example 32 with VectorClock

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);
}
Also used : VectorClock(voldemort.versioning.VectorClock) ByteArray(voldemort.utils.ByteArray) Test(org.junit.Test)

Example 33 with VectorClock

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"));
}
Also used : VectorClock(voldemort.versioning.VectorClock) Test(org.junit.Test)

Example 34 with VectorClock

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);
}
Also used : Node(voldemort.cluster.Node) StoreDefinition(voldemort.store.StoreDefinition) VectorClock(voldemort.versioning.VectorClock) Cluster(voldemort.cluster.Cluster) VoldemortConfig(voldemort.server.VoldemortConfig)

Example 35 with VectorClock

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);
}
Also used : Versioned(voldemort.versioning.Versioned) VectorClock(voldemort.versioning.VectorClock) ConfigurationStorageEngine(voldemort.store.configuration.ConfigurationStorageEngine) ClusterMapper(voldemort.xml.ClusterMapper)

Aggregations

VectorClock (voldemort.versioning.VectorClock)162 Versioned (voldemort.versioning.Versioned)73 Test (org.junit.Test)65 ByteArray (voldemort.utils.ByteArray)65 ArrayList (java.util.ArrayList)33 IOException (java.io.IOException)25 VoldemortException (voldemort.VoldemortException)24 List (java.util.List)22 HashMap (java.util.HashMap)21 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)21 Version (voldemort.versioning.Version)16 Node (voldemort.cluster.Node)15 AbstractByteArrayStoreTest (voldemort.store.AbstractByteArrayStoreTest)11 StoreDefinition (voldemort.store.StoreDefinition)11 AdminClient (voldemort.client.protocol.admin.AdminClient)10 VoldemortServer (voldemort.server.VoldemortServer)10 Pair (voldemort.utils.Pair)10 ClockEntry (voldemort.versioning.ClockEntry)10 File (java.io.File)8 Map (java.util.Map)8