Package voldemort.versioning

Examples of voldemort.versioning.VectorClock


                   redirectingStoreNode2.get(primaryKey1, null).size() > 0);

        // 2. Test that put is still issued on top of version on remote version.
        // But once moved over, can be issued just on local version.
        ByteArray secondaryKey1 = testSecondaryKeys.get(1);
        VectorClock writeClock = makeSuperClock(time++);
        socketStoreNode0.put(secondaryKey1, new
                             Versioned<byte[]>("value-win".getBytes(),
                                               writeClock), null);
        try {
            redirectingStoreNode2.put(secondaryKey1, new
                                      Versioned<byte[]>("value-ove".getBytes(),
                                                        writeClock), null);
            fail("Missing OVE.. put should be based on remote version");
        } catch(ObsoleteVersionException ove) {
            // should have OVE if based on remote version due to equal clock
        }
        // But would have still move over value from Node 0
        assertEquals("Value not moved over from Node 0",
                     "value-win",
                     new String(socketStoreNode2.get(secondaryKey1, null).get(0).getValue()));
        socketStoreNode0.delete(secondaryKey1, makeSuperClock(time++));
        redirectingStoreNode2.put(secondaryKey1,
                                  new Versioned<byte[]>("value-final".getBytes(),
                                                        makeSuperClock(time++)),
                                  null);
        assertEquals("Final value not found on node 2",
                     "value-final",
                     new String(socketStoreNode2.get(secondaryKey1, null).get(0).getValue()));
        assertEquals("Final value not found on node 0",
                     "value-final",
                     new String(socketStoreNode0.get(secondaryKey1, null).get(0).getValue()));

        // delete all the primary and secondary keys from Node 2 and Node 0, to
        // begin getAll() tests
        for(ByteArray key: testPrimaryKeys) {
            socketStoreNode0.delete(key, makeSuperClock(time++));
            socketStoreNode2.delete(key, makeSuperClock(time++));
            socketStoreNode0.put(key, new Versioned<byte[]>("normal".getBytes(),
                                                            makeSuperClock(time++)), null);
        }
        for(ByteArray key: testSecondaryKeys) {
            socketStoreNode0.delete(key, makeSuperClock(time++));
            socketStoreNode2.delete(key, makeSuperClock(time++));
            socketStoreNode0.put(key, new Versioned<byte[]>("normal".getBytes(),
                                                            makeSuperClock(time++)), null);
        }

        // 3. Test case where some keys are moved over and some are n't for
        // getAlls.
        List<ByteArray> keyList = new ArrayList<ByteArray>();
        keyList.addAll(testPrimaryKeys);
        keyList.addAll(testSecondaryKeys);
        keyList.add(new ByteArray("non-existent-key".getBytes()));

        // add the first primary & secondary key with bigger vector clock on
        // Node 2 and lower clock on Node 0..
        VectorClock smallerClock = makeSuperClock(time++);
        VectorClock biggerClock = makeSuperClock(time++);
        socketStoreNode0.put(testPrimaryKeys.get(0), new
                             Versioned<byte[]>("loser".getBytes(),
                                               smallerClock), null);
        socketStoreNode2.put(testPrimaryKeys.get(0), new
                             Versioned<byte[]>("winner".getBytes(),
View Full Code Here


        assert deleted > 0;
        Cluster newCluster = new Cluster(cluster.getName(),
                                         ImmutableList.of(newNode0, newNode1),
                                         Lists.newArrayList(cluster.getZones()));
        for(Node node: cluster.getNodes()) {
            VectorClock clock = (VectorClock) versionedCluster.getVersion();
            clock.incrementVersion(node.getId(), System.currentTimeMillis());

            adminClient.metadataMgmtOps.updateRemoteCluster(node.getId(), newCluster, clock);
        }
    }
View Full Code Here

                Versioned<String> versioned = adminClient.metadataMgmtOps.getRemoteMetadata(nodeId,
                                                                                            MetadataStore.CLUSTER_KEY);
                Version version = versioned.getVersion();

                VectorClock vectorClock = (VectorClock) version;
                vectorClock.incrementVersion(nodeId, System.currentTimeMillis());

                try {
                    adminClient.metadataMgmtOps.updateRemoteMetadata(peerNodeId,
                                                                     MetadataStore.CLUSTER_KEY,
                                                                     versioned);
View Full Code Here

            socketStoreFactories.put(nodeId, socketStoreFactory);
            Store<ByteArray, byte[], byte[]> store = vs.getStoreRepository()
                    .getLocalStore(storeDef.getName());
            Node node = cluster.getNodeById(nodeId);

            VectorClock version1 = new VectorClock();
            version1.incrementVersion(0, System.currentTimeMillis());
            VectorClock version2 = version1.incremented(0, System.currentTimeMillis());

            if(node.getZoneId() == clientZoneId) {
                // local zone
                store.put(new ByteArray(k1_bytes), new Versioned<byte[]>(v1_bytes, version1), null);
                store.put(new ByteArray(k2_bytes), new Versioned<byte[]>(v1_bytes, version1), null);
View Full Code Here

public class NodeValueTest {
    private final static Logger logger = Logger.getLogger(NodeValueTest.class);

    public static Version createVersion(int nodeId, int clockEntry) {
        VectorClock version = TestUtils.getClock(nodeId);
        for (int i=0; i < clockEntry-1; i++) {
            TestUtils.increment(version, nodeId);
        }
        return version;
    }
View Full Code Here

                                                                                                                           "UTF-8"));
        byte[] value1 = ByteUtils.getBytes("value-" + new String(key1.get()), "UTF-8"), value2 = ByteUtils.getBytes("value-"
                                                                                                                            + new String(key2.get()),
                                                                                                                    "UTF-8");

        VectorClock vectorClock1 = new VectorClock(), vectorClock2 = new VectorClock();

        List<Versioned<Slop>> entrySet = Lists.newArrayList();
        for(String storeName: Lists.newArrayList("test-replication-memory",
                                                 "users",
                                                 "test-replication-persistent")) {
            entrySet.add(Versioned.value(new Slop(storeName,
                                                  Slop.Operation.PUT,
                                                  key1,
                                                  value1,
                                                  null,
                                                  1,
                                                  new Date()), vectorClock1));
            vectorClock1 = vectorClock1.incremented(0, System.currentTimeMillis());
            entrySet.add(Versioned.value(new Slop(storeName,
                                                  Slop.Operation.DELETE,
                                                  key1,
                                                  null,
                                                  null,
                                                  1,
                                                  new Date()), vectorClock1));
            vectorClock1 = vectorClock1.incremented(0, System.currentTimeMillis());
            entrySet.add(Versioned.value(new Slop(storeName,
                                                  Slop.Operation.PUT,
                                                  key1,
                                                  value2,
                                                  null,
                                                  1,
                                                  new Date()), vectorClock1));

            vectorClock2 = vectorClock2.incremented(0, System.currentTimeMillis());
            entrySet.add(Versioned.value(new Slop(storeName,
                                                  Slop.Operation.PUT,
                                                  key2,
                                                  value2,
                                                  null,
                                                  1,
                                                  new Date()), vectorClock2));
            vectorClock2 = vectorClock2.incremented(0, System.currentTimeMillis());
            entrySet.add(Versioned.value(new Slop(storeName,
                                                  Slop.Operation.DELETE,
                                                  key2,
                                                  null,
                                                  null,
View Full Code Here

                        for(int j = 0; j < 1000 && !returnedEmpty.get(); j++) {
                            List<Versioned<byte[]>> vals = store.get(new ByteArray(keyBytes), null);
                            if(vals.size() == 0 && j > 1)
                                returnedEmpty.set(true);
                            else {
                                VectorClock v = (VectorClock) vals.get(0).getVersion();
                                v.incrementVersion(0, System.currentTimeMillis());
                                try {
                                    store.put(new ByteArray(keyBytes),
                                              new Versioned<byte[]>(valueBytes, v),
                                              null);
                                } catch(ObsoleteVersionException e) {
View Full Code Here

        executor.execute(new Runnable() {

            public void run() {
                while(keepRunning.get()) {
                    byte[] bytes = Integer.toString(rand.nextInt(count.get())).getBytes();
                    store.delete(new ByteArray(bytes), new VectorClock());
                    count.incrementAndGet();
                }
            }
        });
View Full Code Here

            slops.addAll(validStoreSlops);
            SlopSerializer slopSerializer = new SlopSerializer();

            // Populate the store with the slops
            for(Versioned<Slop> slop: slops) {
                VectorClock clock = TestUtils.getClock(1);
                NodeValue<ByteArray, byte[]> nodeValue = new NodeValue<ByteArray, byte[]>(0,
                                                                                          slop.getValue()
                                                                                              .makeKey(),
                                                                                          new Versioned<byte[]>(slopSerializer.toBytes(slop.getValue()),
                                                                                                                clock));
View Full Code Here

    @Test
    public void testSimpleGetAndPut() {
        for(int i = 0; i <= TEST_RUNS; i++) {
            ByteArray key = getValidKey();
            VectorClock clock = (VectorClock) metadataStore.get(key, null).get(0).getVersion();
            Versioned<byte[]> value = new Versioned<byte[]>(getValidValue(key),
                                                            clock.incremented(0, 1));

            metadataStore.put(key, value, null);
            checkValues(value, metadataStore.get(key, null), key);
        }
    }
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.