Search in sources :

Example 6 with MutableDigest

use of org.jgroups.util.MutableDigest in project JGroups by belaban.

the class DigestTest method testConflictingMerge.

public void testConflictingMerge() {
    MutableDigest new_d = new MutableDigest(members);
    new_d.set(a1, 450, 501);
    new_d.set(a3, 28, 35);
    md = new MutableDigest(d);
    md.merge(new_d);
    Assert.assertEquals(md.capacity(), 3);
    Assert.assertEquals(md.get(a1)[0], 500);
    Assert.assertEquals(md.get(a1)[1], 501);
    Assert.assertEquals(md.get(a2)[0], 26);
    Assert.assertEquals(md.get(a2)[1], 26);
    Assert.assertEquals(md.get(a3)[0], 28);
    Assert.assertEquals(md.get(a3)[1], 35);
}
Also used : MutableDigest(org.jgroups.util.MutableDigest)

Example 7 with MutableDigest

use of org.jgroups.util.MutableDigest in project JGroups by belaban.

the class DigestTest method beforeMethod.

@BeforeMethod
void beforeMethod() {
    d = new Digest(members, new long[] { 500, 501, 26, 26, 25, 33 });
    md = new MutableDigest(members);
}
Also used : MutableDigest(org.jgroups.util.MutableDigest) Digest(org.jgroups.util.Digest) MutableDigest(org.jgroups.util.MutableDigest) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 8 with MutableDigest

use of org.jgroups.util.MutableDigest in project JGroups by belaban.

the class DigestTest method testNonConflictingMerge.

public void testNonConflictingMerge() {
    Address ip1 = Util.createRandomAddress("x"), ip2 = Util.createRandomAddress("y");
    View tmp_view = View.create(a1, 1, a1, a2, a3, ip1, ip2);
    MutableDigest cons_d = new MutableDigest(tmp_view.getMembersRaw());
    cons_d.set(ip1, 10, 10);
    cons_d.set(ip2, 20, 20);
    cons_d.merge(d);
    Assert.assertEquals(cons_d.capacity(), 5);
    Assert.assertEquals(cons_d.get(ip1)[0], 10);
    Assert.assertEquals(cons_d.get(ip2)[0], 20);
    Assert.assertEquals(cons_d.get(a1)[0], 500);
    Assert.assertEquals(cons_d.get(a2)[0], 26);
    Assert.assertEquals(cons_d.get(a3)[0], 25);
    Assert.assertEquals(cons_d.get(ip1)[1], 10);
    Assert.assertEquals(cons_d.get(ip2)[1], 20);
    Assert.assertEquals(cons_d.get(a1)[1], 501);
    Assert.assertEquals(cons_d.get(a2)[1], 26);
    Assert.assertEquals(cons_d.get(a3)[1], 33);
}
Also used : Address(org.jgroups.Address) MutableDigest(org.jgroups.util.MutableDigest) View(org.jgroups.View)

Example 9 with MutableDigest

use of org.jgroups.util.MutableDigest in project JGroups by belaban.

the class DigestTest method testSetHighestDeliveredAndSeenSeqnoAt.

public void testSetHighestDeliveredAndSeenSeqnoAt() {
    md = new MutableDigest(d);
    Assert.assertEquals(md.get(a1)[0], 500);
    Assert.assertEquals(md.get(a1)[1], 501);
    md.set(a1, 10, 20);
    Assert.assertEquals(md.get(a1)[0], 10);
    Assert.assertEquals(md.get(a1)[1], 20);
}
Also used : MutableDigest(org.jgroups.util.MutableDigest)

Example 10 with MutableDigest

use of org.jgroups.util.MutableDigest in project JGroups by belaban.

the class SequencerMergeTest method getDigest.

protected static Digest getDigest(final View view, JChannel... channels) {
    MutableDigest digest = new MutableDigest(view.getMembersRaw());
    for (JChannel ch : channels) {
        Protocol nak = ch.getProtocolStack().findProtocol(NAKACK2.class);
        Digest tmp = (Digest) nak.down(new Event(Event.GET_DIGEST, ch.getAddress()));
        if (tmp != null)
            digest.set(tmp);
    }
    return digest;
}
Also used : MutableDigest(org.jgroups.util.MutableDigest) Digest(org.jgroups.util.Digest) MutableDigest(org.jgroups.util.MutableDigest) Protocol(org.jgroups.stack.Protocol)

Aggregations

MutableDigest (org.jgroups.util.MutableDigest)18 Digest (org.jgroups.util.Digest)4 NAKACK2 (org.jgroups.protocols.pbcast.NAKACK2)3 Address (org.jgroups.Address)2 GMS (org.jgroups.protocols.pbcast.GMS)2 Protocol (org.jgroups.stack.Protocol)2 ArrayList (java.util.ArrayList)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Condition (java.util.concurrent.locks.Condition)1 Lock (java.util.concurrent.locks.Lock)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 View (org.jgroups.View)1 NakAckHeader2 (org.jgroups.protocols.pbcast.NakAckHeader2)1 MessageBatch (org.jgroups.util.MessageBatch)1 BeforeMethod (org.testng.annotations.BeforeMethod)1