use of org.jgroups.util.MessageBatch in project JGroups by belaban.
the class MessageBatchTest method testTotalSize.
public void testTotalSize() {
List<Message> msgs = createMessages();
MessageBatch batch = new MessageBatch(msgs);
long total_size = 0;
for (Message msg : msgs) total_size += msg.size();
System.out.println("total size=" + batch.totalSize());
assert batch.totalSize() == total_size;
}
use of org.jgroups.util.MessageBatch in project JGroups by belaban.
the class MessageBatchTest method testStream.
public void testStream() {
List<Message> msgs = createMessages();
MessageBatch batch = new MessageBatch(msgs);
long num_msgs = batch.stream().filter(msg -> msg.getHeader(UNICAST3_ID) != null).peek(msg -> System.out.printf("msg = %s, hdrs=%s\n", msg, msg.printHeaders())).count();
System.out.println("num_msgs = " + num_msgs);
assert num_msgs == 10;
List<Message> list = batch.stream().collect(Collectors.toList());
assert list.size() == batch.size();
int total_size = batch.stream().map(Message::getLength).reduce(0, (l, r) -> l + r);
assert total_size == 0;
List<Long> msg_sizes = batch.stream().map(Message::size).collect(Collectors.toList());
System.out.println("msg_sizes = " + msg_sizes);
assert msg_sizes.size() == batch.stream().count();
}
use of org.jgroups.util.MessageBatch in project JGroups by belaban.
the class MessageBatchTest method testReplace2.
public void testReplace2() {
List<Message> msgs = createMessages();
MessageBatch batch = new MessageBatch(msgs);
final Message MSG = new Message();
batch.replace(MSG, null);
// MSG was *not* found and therefore *not* nulled
assert batch.size() == msgs.size();
batch.replace(get(batch, 5), null);
assert batch.size() == msgs.size() - 1;
}
use of org.jgroups.util.MessageBatch in project JGroups by belaban.
the class MessageBatchTest method testSize2.
public void testSize2() {
List<Message> msgs = createMessages();
MessageBatch batch = new MessageBatch(msgs);
assert batch.size() == msgs.size();
remove(batch, 2, 3, 10);
assert batch.size() == msgs.size() - 3;
}
use of org.jgroups.util.MessageBatch in project JGroups by belaban.
the class MessageBatchTest method testIterator4.
public void testIterator4() {
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;
}
Aggregations