Package voldemort.versioning

Examples of voldemort.versioning.VectorClock


                                                             "multipart/mixed");
            MimeMultipart mp = new MimeMultipart(ds);
            assertEquals("The number of body parts expected is not 1", 1, mp.getCount());

            MimeBodyPart part = (MimeBodyPart) mp.getBodyPart(0);
            VectorClock vc = RestUtils.deserializeVectorClock(part.getHeader(RestMessageHeaders.X_VOLD_VECTOR_CLOCK)[0]);
            int contentLength = Integer.parseInt(part.getHeader(RestMessageHeaders.CONTENT_LENGTH)[0]);
            byte[] bodyPartBytes = new byte[contentLength];

            part.getInputStream().read(bodyPartBytes);
            response = new String(bodyPartBytes);
View Full Code Here


    public Store<ByteArray, byte[], byte[]> getStore() throws Exception {
        return store;
    }

    public VectorClock getNewIncrementedVectorClock() {
        VectorClock vectorClock = new VectorClock();
        vectorClock.incrementVersion(this.nodeId, System.currentTimeMillis());
        return vectorClock;
    }
View Full Code Here

    @Test
    public void testFetchedEqualsPut() throws Exception {
        System.out.println("                    Testing Fetchhed equals put                    ");
        ByteArray key = getKey();
        Store<ByteArray, byte[], byte[]> store = getStore();
        VectorClock clock = getClock(1, 1, 2, 3, 3, 4);
        byte[] value = getValue();
        System.out.println("Value chosen : " + value);
        List<Versioned<byte[]>> resultList = store.get(key, null);
        assertNotNull("Null result list obtained from a get request", resultList);
        assertEquals("Store not empty at start!", 0, resultList.size());
View Full Code Here

            // this is good
        } catch(NullPointerException npe) {
            // this is good
        }
        try {
            store.delete(null, new VectorClock());
            fail("Store should not delete null keys!");
        } catch(IllegalArgumentException e) {
            // this is good
        } catch(NullPointerException npe) {
            // this is good
View Full Code Here

    @Test
    public void testGetVersions() throws Exception {
        List<ByteArray> keys = getKeys(2);
        ByteArray key = keys.get(0);
        byte[] value = getValue();
        VectorClock vc = getClock(0, 0);
        Store<ByteArray, byte[], byte[]> store = getStore();
        store.put(key, Versioned.value(value, vc), null);
        List<Versioned<byte[]>> versioneds = store.get(key, null);
        List<Version> versions = store.getVersions(key);
        assertEquals(1, versioneds.size());
View Full Code Here

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

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

        assertEquals(keys.size(), values.size());
        int count = keys.size();

        for(int i = 0; i < count; i++) {
            VectorClock vc = getClock(0, 0);
            store.put(keys.get(i), new Versioned<byte[]>(values.get(i), vc), null);
        }

        Map<ByteArray, List<Versioned<byte[]>>> result = store.getAll(keys, null);
        assertGetAllValues(keys, values, result);
View Full Code Here

    public void testGetWithBinaryData() throws Exception {
        Store<ByteArray, byte[], byte[]> store = getStore();

        byte[] allPossibleBytes = getAllPossibleBytes();
        ByteArray key = new ByteArray(allPossibleBytes);
        VectorClock vc = getClock(0, 0);
        Versioned<byte[]> versioned = new Versioned<byte[]>(allPossibleBytes, vc);
        store.put(key, versioned, null);

        List<Versioned<byte[]>> found = store.get(key, null);
        assertEquals("Should only be one version stored.", 1, found.size());
View Full Code Here

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

            }
            if(this.zoneId != INVALID_ZONE_ID) {
                rb.setHeader(RestMessageHeaders.X_VOLD_ZONE_ID, String.valueOf(this.zoneId));
            }
            // Serialize the Vector clock
            VectorClock vc = (VectorClock) version;

            // If the given Vector clock is empty, we'll let the receiver of
            // this request fetch the existing vector clock and increment
            // before
            // doing the put.
            if(vc != null && vc.getEntries().size() != 0) {
                String serializedVC = null;
                if(!vc.getEntries().isEmpty()) {
                    serializedVC = RestUtils.getSerializedVectorClock(vc);
                }

                if(serializedVC != null && serializedVC.length() > 0) {
                    rb.setHeader(RestMessageHeaders.X_VOLD_VECTOR_CLOCK, serializedVC);
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.