use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class ReadManyOperation method shouldWait.
@Override
public boolean shouldWait() {
if (resultSet == null) {
resultSet = new ReadResultSetImpl(minSize, maxSize, getNodeEngine().getHazelcastInstance(), filter);
sequence = startSequence;
}
RingbufferContainer ringbuffer = getRingBufferContainer();
if (minSize == 0) {
if (!ringbuffer.shouldWait(sequence)) {
sequence = ringbuffer.readMany(sequence, resultSet);
}
return false;
}
if (resultSet.isMinSizeReached()) {
// enough items have been read, we are done.
return false;
}
if (ringbuffer.shouldWait(sequence)) {
// the sequence is not readable
return true;
}
sequence = ringbuffer.readMany(sequence, resultSet);
return !resultSet.isMinSizeReached();
}
use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class RingbufferReadManyMessageTask method encodeResponse.
@Override
protected ClientMessage encodeResponse(Object response) {
// we are not deserializing the whole content, only the enclosing portable. The actual items remain un
ReadResultSetImpl resultSet = nodeEngine.getSerializationService().toObject(response);
List<Data> items = new ArrayList<Data>(resultSet.size());
for (int k = 0; k < resultSet.size(); k++) {
items.add(resultSet.getDataItems()[k]);
}
return RingbufferReadManyCodec.encodeResponse(resultSet.readCount(), items);
}
use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class ReadManyOperationTest method whenOneAfterTail.
@Test
public void whenOneAfterTail() throws Exception {
ringbuffer.add("tail");
ReadManyOperation op = new ReadManyOperation(ringbuffer.getName(), ringbuffer.tailSequence() + 1, 1, 1, null);
op.setNodeEngine(nodeEngine);
// 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());
}
use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class ReadManyOperationTest method whenOneAfterTailAndBufferEmpty.
@Test
public void whenOneAfterTailAndBufferEmpty() throws Exception {
ReadManyOperation op = new ReadManyOperation(ringbuffer.getName(), ringbuffer.tailSequence() + 1, 1, 1, null);
op.setNodeEngine(nodeEngine);
// 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.size());
}
Aggregations