use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class ReadManyOperationTest method whenBelowMinimumAvailable.
@Test
public void whenBelowMinimumAvailable() {
long startSequence = ringbuffer.tailSequence() + 1;
ReadManyOperation op = getReadManyOperation(startSequence, 3, 3, null);
ringbuffer.add("item1");
ringbuffer.add("item2");
assertTrue(op.shouldWait());
ReadResultSetImpl response = getReadResultSet(op);
assertEquals(startSequence + 2, op.sequence);
assertEquals(asList("item1", "item2"), response);
assertEquals(2, response.getNextSequenceToReadFrom());
ringbuffer.add("item3");
assertFalse(op.shouldWait());
assertEquals(startSequence + 3, op.sequence);
assertEquals(asList("item1", "item2", "item3"), response);
assertEquals(3, response.getNextSequenceToReadFrom());
}
use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class ReadManyOperationTest method whenFilterProvidedAndAllItemsAvailable.
@Test
public void whenFilterProvidedAndAllItemsAvailable() {
long startSequence = ringbuffer.tailSequence() + 1;
IFunction<String, Boolean> filter = (IFunction<String, Boolean>) input -> input.startsWith("good");
ReadManyOperation op = getReadManyOperation(startSequence, 3, 3, filter);
ringbuffer.add("bad1");
ringbuffer.add("good1");
ringbuffer.add("bad2");
ringbuffer.add("good2");
ringbuffer.add("bad3");
ringbuffer.add("good3");
assertFalse(op.shouldWait());
ReadResultSetImpl response = getReadResultSet(op);
assertEquals(startSequence + 6, op.sequence);
assertEquals(asList("good1", "good2", "good3"), response);
assertEquals(6, response.getNextSequenceToReadFrom());
}
use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class ReadManyOperationTest method whenBeforeHead.
@Test
public void whenBeforeHead() throws Exception {
ringbuffer.add("item1");
ringbuffer.add("item2");
ringbuffer.add("item3");
ringbuffer.add("item4");
ringbuffer.add("item5");
ringbufferContainer.setHeadSequence(2);
ReadManyOperation op = getReadManyOperation(0, 1, 2, null);
// the start sequence is stale, but it will be clamped to current head
assertFalse(op.shouldWait());
op.run();
ReadResultSetImpl response = getReadResultSet(op);
assertEquals(2, response.readCount());
assertEquals(asList("item3", "item4"), response);
assertEquals(4, response.getNextSequenceToReadFrom());
assertEquals(2, response.size());
}
use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class ReadManyOperationTest method whenOneAfterTail.
@Test
public void whenOneAfterTail() {
ringbuffer.add("tail");
ReadManyOperation op = getReadManyOperation(ringbuffer.tailSequence() + 1, 1, 1, null);
// since there is an item, we don't need to wait
boolean shouldWait = op.shouldWait();
assertTrue(shouldWait);
ReadResultSetImpl response = getReadResultSet(op);
assertEquals(0, response.readCount());
assertEquals(0, response.getNextSequenceToReadFrom());
}
use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class ReadManyOperationTest method whenOneAfterTailAndBufferEmpty.
@Test
public void whenOneAfterTailAndBufferEmpty() {
ReadManyOperation op = getReadManyOperation(ringbuffer.tailSequence() + 1, 1, 1, null);
// since there is an item, we don't need to wait
boolean shouldWait = op.shouldWait();
assertTrue(shouldWait);
ReadResultSetImpl response = getReadResultSet(op);
assertEquals(0, response.readCount());
assertEquals(0, response.getNextSequenceToReadFrom());
assertEquals(0, response.size());
}
Aggregations