Search in sources :

Example 46 with Message

use of org.jgroups.Message in project JGroups by belaban.

the class MessageTest method testFlags3.

public static void testFlags3() {
    Message msg = new Message();
    assert !msg.isFlagSet(Message.Flag.OOB);
    msg.setFlag(Message.Flag.OOB);
    assert msg.isFlagSet(Message.Flag.OOB);
    msg.setFlag(Message.Flag.OOB);
    assert msg.isFlagSet(Message.Flag.OOB);
}
Also used : Message(org.jgroups.Message)

Example 47 with Message

use of org.jgroups.Message in project JGroups by belaban.

the class MessageTest method testFlags2.

public static void testFlags2() {
    Message m1 = new Message();
    m1.setFlag(Message.Flag.OOB);
    assert m1.isFlagSet(Message.Flag.OOB);
    assert Message.isFlagSet(m1.getFlags(), Message.Flag.OOB);
    assert !(m1.isFlagSet(Message.Flag.DONT_BUNDLE));
    assert !Message.isFlagSet(m1.getFlags(), Message.Flag.DONT_BUNDLE);
}
Also used : Message(org.jgroups.Message)

Example 48 with Message

use of org.jgroups.Message in project JGroups by belaban.

the class RSVPTest method testSynchronousUnicastSend.

public void testSynchronousUnicastSend() throws Exception {
    // test with a unicast message:
    short value = (short) Math.abs((short) Util.random(10000));
    Message msg = new Message(channels[1].getAddress(), value).setFlag(Message.Flag.RSVP);
    DISCARD discard = channels[0].getProtocolStack().findProtocol(DISCARD.class);
    discard.setDropDownUnicasts(1);
    long start = System.currentTimeMillis();
    channels[0].send(msg);
    long diff = System.currentTimeMillis() - start;
    System.out.println("sending took " + diff + " ms");
    // UNICAST3 retransmission will resend the message *not* RSVP
    for (int i = 0; i < 20; i++) {
        if (receivers[1].getValue() == value)
            break;
        Util.sleep(500);
    }
    long tmp_value = receivers[1].getValue();
    assert tmp_value == value : "value is " + tmp_value + ", but should be " + value;
}
Also used : Message(org.jgroups.Message)

Example 49 with Message

use of org.jgroups.Message in project JGroups by belaban.

the class RSVPTest method testAsyncLostRSVPMessages.

/**
 * Tests that async RSVP tasks that are lost are removed after timeout ms
 */
public void testAsyncLostRSVPMessages() throws Exception {
    // test with a multicast message:
    short value = (short) Math.abs((short) Util.random(10000));
    Message msg = new Message(null, value).setFlag(Message.Flag.RSVP_NB);
    DISCARD discard = channels[0].getProtocolStack().findProtocol(DISCARD.class);
    discard.setDiscardAll(true);
    RSVP rsvp = channels[0].getProtocolStack().findProtocol(RSVP.class);
    rsvp.setValue("timeout", 2000).setValue("resend_interval", 200);
    channels[0].send(msg);
    assert rsvp.getPendingRsvpRequests() == 1;
    for (int i = 0; i < 10; i++) {
        if (rsvp.getPendingRsvpRequests() == 0)
            break;
        Util.sleep(1000);
    }
    assert rsvp.getPendingRsvpRequests() == 0;
}
Also used : Message(org.jgroups.Message)

Example 50 with Message

use of org.jgroups.Message in project JGroups by belaban.

the class MessageBatchTest method testRemove.

public void testRemove() {
    List<Message> msgs = createMessages();
    MessageBatch batch = new MessageBatch(msgs);
    int prev_size = batch.size();
    remove(batch, 1, 4);
    System.out.println("batch = " + batch);
    assert batch.size() == prev_size - 2;
    batch.clear();
    System.out.println("batch = " + batch);
    assert batch.isEmpty();
    msgs.forEach(batch::add);
    System.out.println("batch = " + batch);
    assert batch.size() == prev_size;
    assert batch.capacity() == prev_size;
}
Also used : MessageBatch(org.jgroups.util.MessageBatch) Message(org.jgroups.Message)

Aggregations

Message (org.jgroups.Message)246 Address (org.jgroups.Address)50 MessageBatch (org.jgroups.util.MessageBatch)37 BytesMessage (org.jgroups.BytesMessage)31 NioMessage (org.jgroups.NioMessage)14 ObjectMessage (org.jgroups.ObjectMessage)14 EmptyMessage (org.jgroups.EmptyMessage)12 Test (org.testng.annotations.Test)12 Event (org.jgroups.Event)11 ToaHeader (org.jgroups.protocols.tom.ToaHeader)11 Test (org.junit.Test)11 IOException (java.io.IOException)8 JChannel (org.jgroups.JChannel)8 MessageID (org.jgroups.protocols.tom.MessageID)8 DistributionMessage (org.apache.geode.distributed.internal.DistributionMessage)7 JoinRequestMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinRequestMessage)7 JoinResponseMessage (org.apache.geode.distributed.internal.membership.gms.messages.JoinResponseMessage)7 TimeoutException (java.util.concurrent.TimeoutException)6 Collectors (java.util.stream.Collectors)6 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)6