Package org.sdnplatform.sync.internal.version

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


                   !getVersioned(1, 1, 2).equals(getVersioned(2, 1, 1, 2)));

        // Should work for array types too!
        assertEquals("Equal arrays are not equal!",
                     new Versioned<byte[]>(new byte[] { 1 },
                                           new VectorClock(now)),
                     new Versioned<byte[]>(new byte[] { 1 },
                                           new VectorClock(now)));
    }
View Full Code Here


     *
     * @param nodes The sequence of nodes
     * @return A VectorClock initialized with the given sequence of events
     */
    public static VectorClock getClock(int... nodes) {
        VectorClock clock = new VectorClock();
        return increment(clock, nodes);
    }
View Full Code Here

     *
     * @param nodes The sequence of nodes
     * @return A VectorClock initialized with the given sequence of events
     */
    public static VectorClock getClockT(long timestamp, int... nodes) {
        VectorClock clock = new VectorClock(timestamp);
        return incrementT(timestamp, clock, nodes);
    }
View Full Code Here

    private volatile VectorClock version;
    private volatile T value;

    public Versioned(T object) {
        this(object, new VectorClock());
    }
View Full Code Here

        this(object, new VectorClock());
    }

    public Versioned(T object,
                     IVersion version) {
        this.version = version == null ? new VectorClock() : (VectorClock) version;
        this.value = object;
    }
View Full Code Here

    public Versioned<T> cloneVersioned() {
        return new Versioned<T>(this.getValue(), this.version.clone());
    }

    public static <S> Versioned<S> value(S s) {
        return new Versioned<S>(s, new VectorClock());
    }
View Full Code Here

    public static <S> Versioned<S> value(S s, IVersion v) {
        return new Versioned<S>(s, v);
    }

    public static <S> Versioned<S> emptyVersioned() {
        return new Versioned<S>(null, new VectorClock(0));
    }
View Full Code Here

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

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

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

        // put initial version
View Full Code Here

TOP

Related Classes of org.sdnplatform.sync.internal.version.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.