Examples of VectorClock


Examples of voldemort.versioning.VectorClock

    private void testObsoletePutFails(String message,
                                      Store<K, V, T> store,
                                      K key,
                                      Versioned<V> versioned) {
        VectorClock clock = (VectorClock) versioned.getVersion();
        clock = clock.clone();
        try {
            store.put(key, versioned, null);
            fail(message);
        } catch(ObsoleteVersionException e) {
            // this is good, but check that we didn't fuck with the version
View Full Code Here

Examples of voldemort.versioning.VectorClock

    @Test
    public void testFetchedEqualsPut() throws Exception {
        K key = getKey();
        Store<K, V, T> store = getStore();
        VectorClock clock = getClock(1, 1, 2, 3, 3, 4);
        V value = getValue();
        assertEquals("Store not empty at start!", 0, store.get(key, null).size());
        Versioned<V> versioned = new Versioned<V>(value, clock);
        store.put(key, versioned, null);
        List<Versioned<V>> found = store.get(key, null);
View Full Code Here

Examples of voldemort.versioning.VectorClock

    @Test
    public void testVersionedPut() throws Exception {
        K key = getKey();
        Store<K, V, T> store = getStore();
        VectorClock clock = getClock(1, 1);
        VectorClock clockCopy = clock.clone();
        V value = getValue();
        assertEquals("Store not empty at start!", 0, store.get(key, null).size());
        Versioned<V> versioned = new Versioned<V>(value, clock);

        // put initial version
View Full Code Here

Examples of voldemort.versioning.VectorClock

    @Test
    public void testDelete() throws Exception {
        K key = getKey();
        Store<K, V, T> store = getStore();
        VectorClock c1 = getClock(1, 1);
        VectorClock c2 = getClock(1, 2);
        V value = getValue();

        // can't delete something that isn't there
        assertTrue(!store.delete(key, c1));
View Full Code Here

Examples of voldemort.versioning.VectorClock

    @Override
    public void testDelete() {
        ByteArray key = getKey();
        Store<ByteArray, byte[], byte[]> store = getStore();
        VectorClock c1 = getClock(1, 1);
        byte[] value = getValue();

        // can't delete something that isn't there
        assertTrue(!store.delete(key, c1));
View Full Code Here

Examples of voldemort.versioning.VectorClock

        Store<ByteArray, byte[], byte[]> store = getStore();
        int putCount = 10;
        List<ByteArray> keys = getKeys(putCount);
        List<byte[]> values = getValues(putCount);
        assertEquals(putCount, values.size());
        VectorClock clock = new VectorClock();
        for(int i = 0; i < putCount; i++) {
            store.put(keys.get(i), new Versioned<byte[]>(values.get(i), clock), null);
            clock = clock.incremented(0, System.currentTimeMillis());
        }

        int countForGet = putCount / 2;
        List<ByteArray> keysForGet = keys.subList(0, countForGet);
        List<byte[]> valuesForGet = values.subList(0, countForGet);
View Full Code Here

Examples of voldemort.versioning.VectorClock

    @Test
    public void testConcurrentWriteFailure() {
        ByteArray key = getKey();
        Store<ByteArray, byte[], byte[]> store = getStore();
        VectorClock c1 = getClock(1, 1);
        VectorClock c2 = getClock(1, 2);
        byte[] value = getValue();

        // put two conflicting versions, then delete one
        Versioned<byte[]> v1 = new Versioned<byte[]>(value, c1);
        Versioned<byte[]> v2 = new Versioned<byte[]>(value, c2);
View Full Code Here

Examples of voldemort.versioning.VectorClock

                     null,
                     client.getValue("k", null));
        client.put("k", "v");
        assertEquals("If there is a value for k, get(k) should return it.",
                     new Versioned<String>("v",
                                           new VectorClock().incremented(nodeId,
                                                                         time.getMilliseconds())),
                     client.get("k", new Versioned<String>("v2")));
        assertNotNull(client.get("k").getVersion());
    }
View Full Code Here

Examples of voldemort.versioning.VectorClock

    @Test
    public void testPutVersioned() {
        client.put("k", Versioned.value("v"));
        Versioned<String> v = client.get("k");
        assertEquals("GET should return the version set by PUT.", "v", v.getValue());
        VectorClock expected = new VectorClock();
        expected.incrementVersion(nodeId, time.getMilliseconds());
        assertEquals("The version should be incremented after a put.", expected, v.getVersion());
        try {
            client.put("k", Versioned.value("v"));
            fail("Put of obsolete version should throw exception.");
        } catch(ObsoleteVersionException e) {
            // this is good
        }
        // PUT of a concurrent version should succeed
        client.put("k",
                   new Versioned<String>("v2",
                                         new VectorClock().incremented(nodeId + 1,
                                                                       time.getMilliseconds())));
        assertEquals("GET should return the new value set by PUT.", "v2", client.getValue("k"));
        assertEquals("GET should return the new version set by PUT.",
                     expected.incremented(nodeId + 1, time.getMilliseconds()),
                     client.get("k").getVersion());
    }
View Full Code Here

Examples of voldemort.versioning.VectorClock

    }

    @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"));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.