Examples of ClockEntry


Examples of org.sdnplatform.sync.internal.version.ClockEntry

     * passing to ClockEntry constructor
     */
    @Test
    public void testMergeWithLargeVersion() {
        VectorClock clock1 = getClock(1);
        VectorClock clock2 = new VectorClock(Lists.newArrayList(new ClockEntry((short) 1,
                                                                               Short.MAX_VALUE + 1)),
                                             System.currentTimeMillis());
        VectorClock mergedClock = clock1.merge(clock2);
        assertEquals(mergedClock.getMaxVersion(), Short.MAX_VALUE + 1);
    }
View Full Code Here

Examples of org.sdnplatform.sync.internal.version.ClockEntry

*/
public class ClockEntryTest {

    @Test
    public void testEquality() {
        ClockEntry v1 = new ClockEntry((short) 0, 1);
        ClockEntry v2 = new ClockEntry((short) 0, 1);
        assertTrue(v1.equals(v1));
        assertTrue(!v1.equals(null));
        assertEquals(v1, v2);

        v1 = new ClockEntry((short) 0, 1);
        v2 = new ClockEntry((short) 0, 2);
        assertTrue(!v1.equals(v2));

        v1 = new ClockEntry(Short.MAX_VALUE, 256);
        v2 = new ClockEntry(Short.MAX_VALUE, 256);
        assertEquals(v1, v2);
    }
View Full Code Here

Examples of org.sdnplatform.sync.internal.version.ClockEntry

        assertEquals(v1, v2);
    }

    @Test
    public void testIncrement() {
        ClockEntry v = new ClockEntry((short) 0, 1);
        assertEquals(v.getNodeId(), 0);
        assertEquals(v.getVersion(), 1);
        ClockEntry v2 = v.incremented();
        assertEquals(v.getVersion(), 1);
        assertEquals(v2.getVersion(), 2);
    }
View Full Code Here

Examples of org.sdnplatform.sync.internal.version.ClockEntry

        ArrayList<ClockEntry> entries =
                new ArrayList<ClockEntry>();
        if (tvc.getVersions() != null) {
            for (org.sdnplatform.sync.thrift.ClockEntry ce :
                tvc.getVersions()) {
                entries.add(new ClockEntry(ce.getNodeId(), ce.getVersion()));
            }
        }
        return new VectorClock(entries, tvc.getTimestamp());
    }
View Full Code Here

Examples of voldemort.versioning.ClockEntry

            srcPrimaryResolvingStoreClient.put(entry.getKey(), entry.getValue());
        }

        // generate a conflict on the master partition
        int masterNode = srcStoreInstance.getNodeIdForPartitionId(srcStoreInstance.getMasterPartitionId(conflictKey.getBytes("UTF-8")));
        VectorClock losingClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 0, 5)),
                                                  System.currentTimeMillis());
        VectorClock winningClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 1, 5)),
                                                   losingClock.getTimestamp() + 1);
        srcAdminClient.storeOps.putNodeKeyValue(PRIMARY_RESOLVING_STORE_NAME,
                                                new NodeValue<ByteArray, byte[]>(masterNode,
                                                                                 new ByteArray(conflictKey.getBytes("UTF-8")),
                                                                                 new Versioned<byte[]>("losing value".getBytes("UTF-8"),
View Full Code Here

Examples of voldemort.versioning.ClockEntry

            srcGloballyResolvingStoreClient.put(entry.getKey(), entry.getValue());
        }

        // generate a conflict on the primary and a secondary
        List<Integer> nodeList = srcStoreInstance.getReplicationNodeList(srcStoreInstance.getMasterPartitionId(conflictKey.getBytes("UTF-8")));
        VectorClock losingClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 0, 5)),
                                                  System.currentTimeMillis());
        VectorClock winningClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 1, 5)),
                                                   losingClock.getTimestamp() + 1);
        srcAdminClient.storeOps.putNodeKeyValue(GLOBALLY_RESOLVING_STORE_NAME,
                                                new NodeValue<ByteArray, byte[]>(nodeList.get(0),
                                                                                 new ByteArray(conflictKey.getBytes("UTF-8")),
                                                                                 new Versioned<byte[]>("losing value".getBytes("UTF-8"),
View Full Code Here

Examples of voldemort.versioning.ClockEntry

            srcGloballyResolvingStoreClient.put(entry.getKey(), entry.getValue());
        }

        // generate a conflict on the primary and a secondary
        List<Integer> nodeList = srcStoreInstance.getReplicationNodeList(srcStoreInstance.getMasterPartitionId(conflictKey.getBytes("UTF-8")));
        VectorClock losingClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 0, 5)),
                                                  System.currentTimeMillis());
        VectorClock winningClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 1, 5)),
                                                   losingClock.getTimestamp() + 1);
        srcAdminClient.storeOps.putNodeKeyValue(GLOBALLY_RESOLVING_STORE_NAME,
                                                new NodeValue<ByteArray, byte[]>(nodeList.get(0),
                                                                                 new ByteArray(conflictKey.getBytes("UTF-8")),
                                                                                 new Versioned<byte[]>("losing value".getBytes("UTF-8"),
View Full Code Here

Examples of voldemort.versioning.ClockEntry

        StoreRoutingPlan srcStoreInstance = new StoreRoutingPlan(srcCluster, nonResolvingStoreDef);

        // generate a conflict on the master partition
        int masterNode = srcStoreInstance.getNodeIdForPartitionId(srcStoreInstance.getMasterPartitionId(conflictKey.getBytes("UTF-8")));
        VectorClock losingClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 0, 5)),
                                                  System.currentTimeMillis());
        VectorClock winningClock = new VectorClock(Lists.newArrayList(new ClockEntry((short) 1, 5)),
                                                   losingClock.getTimestamp() + 1);
        srcAdminClient.storeOps.putNodeKeyValue(MULTIPLE_VERSIONS_STORE_NAME,
                                                new NodeValue<ByteArray, byte[]>(masterNode,
                                                                                 new ByteArray(conflictKey.getBytes("UTF-8")),
                                                                                 new Versioned<byte[]>("losing value".getBytes("UTF-8"),
View Full Code Here

Examples of voldemort.versioning.ClockEntry

        }
    }

    private VectorClock makeSuperClock(long time) {
        List<ClockEntry> clockEntries = new ArrayList<ClockEntry>();
        clockEntries.add(new ClockEntry((short) 0, time));
        clockEntries.add(new ClockEntry((short) 1, time));
        clockEntries.add(new ClockEntry((short) 2, time));
        return new VectorClock(clockEntries, time);
    }
View Full Code Here

Examples of voldemort.versioning.ClockEntry

    }

    public static VectorClock decodeClock(VProto.VectorClock encoded) {
        List<ClockEntry> entries = new ArrayList<ClockEntry>(encoded.getEntriesCount());
        for(VProto.ClockEntry entry: encoded.getEntriesList())
            entries.add(new ClockEntry((short) entry.getNodeId(), entry.getVersion()));
        return new VectorClock(entries, encoded.getTimestamp());
    }
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.