Package voldemort.versioning

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


    @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

    @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

        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

    @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

                     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

    @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

    }

    @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

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

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

        assertEquals("Only one file of name key should be present.", 1, store.get(keyName, null)
                                                                             .size());

        // do a new put
        VectorClock clock = (VectorClock) store.get(keyName, null).get(0).getVersion();
        store.put(keyName, new Versioned<String>("testValue1", clock.incremented(0, 1)), null);
        assertEquals("Only one file of name key should be present.", 1, store.get(keyName, null)
                                                                             .size());
        assertEquals("Value should match.", "testValue1", store.get(keyName, null)
                                                               .get(0)
                                                               .getValue());
View Full Code Here

TOP

Related Classes of voldemort.versioning.VectorClock

Copyright © 2018 www.massapicom. 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.