use of org.jgroups.protocols.RingBufferBundlerLockless in project JGroups by belaban.
the class RingBundlerTestLockless method testSendToMultipleDestinations.
public void testSendToMultipleDestinations() throws Exception {
RingBufferBundlerLockless bundler = new RingBufferBundlerLockless(16);
RingBundlerTest.MockTransport transport = new RingBundlerTest.MockTransport();
bundler.init(transport);
for (int i = 0; i < 6; i++) bundler.send(new EmptyMessage(null));
int cnt = bundler.size();
assert cnt == 6;
bundler._readMessages();
System.out.println("bundler = " + bundler);
assert bundler.readIndex() == 6;
assert bundler.writeIndex() == 6;
assert bundler.size() == 0;
assert transport.map.get(null) == 1;
transport.map.clear();
for (Message msg : create(10000, null, a, a, a, b, c, d, d, a, null, null, a)) bundler.send(msg);
System.out.println("bundler = " + bundler);
cnt = bundler.size();
assert cnt == 12;
assert bundler.readIndex() == 6;
assert bundler.writeIndex() == 2;
bundler._readMessages();
assert bundler.readIndex() == 2;
assert bundler.writeIndex() == 2;
assert bundler.size() == 0;
Stream.of(null, a, b, c, d).forEach(msg -> {
assert transport.map.get(msg) == 1;
});
}
use of org.jgroups.protocols.RingBufferBundlerLockless in project JGroups by belaban.
the class RingBundlerTestLockless method testSimpleSend.
public void testSimpleSend() throws Exception {
RingBufferBundlerLockless bundler = new RingBufferBundlerLockless(16);
RingBundlerTest.MockTransport transport = new RingBundlerTest.MockTransport();
bundler.init(transport);
final CountDownLatch latch = new CountDownLatch(1);
Sender[] senders = new Sender[20];
for (int i = 0; i < senders.length; i++) {
senders[i] = new Sender(latch, bundler);
senders[i].start();
}
latch.countDown();
for (Sender sender : senders) sender.join();
System.out.println("bundler = " + bundler);
bundler._readMessages();
System.out.println("bundler = " + bundler);
}
Aggregations