Search in sources :

Example 51 with Message

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

the class MessageBatchTest method testGetMatchingMessages.

public void testGetMatchingMessages() {
    List<Message> msgs = createMessages();
    MessageBatch batch = new MessageBatch(msgs);
    Collection<Message> matching = batch.getMatchingMessages(UDP_ID, false);
    assert matching.size() == batch.size();
    assert batch.size() == msgs.size();
    matching = batch.getMatchingMessages(FD_ID, true);
    assert matching.size() == 1;
    assert batch.size() == msgs.size() - 1;
    int size = batch.size();
    matching = batch.getMatchingMessages(UDP_ID, true);
    assert matching.size() == size;
    assert batch.isEmpty();
}
Also used : MessageBatch(org.jgroups.util.MessageBatch) Message(org.jgroups.Message)

Example 52 with Message

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

the class MessageBatchTest method testIterator8.

public void testIterator8() {
    List<Message> msgs = createMessages();
    MessageBatch batch = new MessageBatch(msgs);
    int index = 0;
    for (Iterator<Message> it = batch.iterator(); it.hasNext(); ) {
        it.next();
        if (index == 1 || index == 2 || index == 3 || index == 10 || index == msgs.size() - 1)
            it.remove();
        index++;
    }
    System.out.println("batch = " + batch);
    int count = 0;
    for (Message ignored : batch) count++;
    assert count == msgs.size() - 5;
}
Also used : MessageBatch(org.jgroups.util.MessageBatch) Message(org.jgroups.Message)

Example 53 with Message

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

the class MessageBatchTest method testIsEmpty2.

public void testIsEmpty2() {
    List<Message> msgs = createMessages();
    MessageBatch batch = new MessageBatch(msgs);
    batch.add(new Message());
    assert !batch.isEmpty();
    batch.clear();
    assert batch.isEmpty();
    msgs.forEach(batch::add);
    System.out.println("batch = " + batch);
    for (Iterator<Message> it = batch.iterator(); it.hasNext(); ) {
        it.next();
        it.remove();
    }
    System.out.println("batch = " + batch);
    assert batch.isEmpty();
}
Also used : MessageBatch(org.jgroups.util.MessageBatch) Message(org.jgroups.Message)

Example 54 with Message

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

the class MessageBatchTest method testIterator3.

/**
 * Test removal via iterator
 */
public void testIterator3() {
    List<Message> msgs = createMessages();
    MessageBatch batch = new MessageBatch(msgs);
    for (Message msg : batch) if (msg.getHeader(UNICAST3_ID) != null)
        batch.remove(msg);
    System.out.println("batch = " + batch);
    assert batch.size() == 3;
}
Also used : MessageBatch(org.jgroups.util.MessageBatch) Message(org.jgroups.Message)

Example 55 with Message

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

the class MessageBatchTest method testIterator.

public void testIterator() {
    List<Message> msgs = createMessages();
    MessageBatch batch = new MessageBatch(msgs);
    int index = 0, count = 0;
    for (Message msg : batch) {
        Message tmp = msgs.get(index++);
        count++;
        assert msg == tmp;
    }
    assert count == msgs.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