use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class ReadManyOperationTest method whenBeforeTail.
@Test
public void whenBeforeTail() throws Exception {
ringbuffer.add("item1");
ringbuffer.add("item2");
ringbuffer.add("item3");
ReadManyOperation op = getReadManyOperation(ringbuffer.tailSequence() - 1, 1, 1, null);
// since there is an item, we don't need to wait
boolean shouldWait = op.shouldWait();
assertFalse(shouldWait);
op.run();
ReadResultSetImpl response = getReadResultSet(op);
assertEquals(asList("item2"), response);
assertEquals(1, response.readCount());
assertEquals(2, response.getNextSequenceToReadFrom());
assertEquals(1, response.size());
}
use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class ReadManyOperationTest method whenAtHead.
@Test
public void whenAtHead() throws Exception {
ringbuffer.add("item1");
ringbuffer.add("item2");
ringbuffer.add("item3");
ReadManyOperation op = getReadManyOperation(ringbuffer.headSequence(), 1, 1, null);
op.setNodeEngine(nodeEngine);
// since there is an item, we don't need to wait
boolean shouldWait = op.shouldWait();
assertFalse(shouldWait);
op.run();
ReadResultSetImpl response = getReadResultSet(op);
assertEquals(asList("item1"), response);
assertEquals(1, response.readCount());
assertEquals(1, response.getNextSequenceToReadFrom());
assertEquals(1, response.size());
}
use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class ClientCacheProxy method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
eventJournalReadResponseDecoder = message -> {
final CacheEventJournalReadCodec.ResponseParameters params = CacheEventJournalReadCodec.decodeResponse(message);
final ReadResultSetImpl resultSet = new ReadResultSetImpl<>(params.readCount, params.items, params.itemSeqs, params.nextSeq);
resultSet.setSerializationService(getSerializationService());
return resultSet;
};
eventJournalSubscribeResponseDecoder = message -> {
final ResponseParameters resp = CacheEventJournalSubscribeCodec.decodeResponse(message);
return new EventJournalInitialSubscriberState(resp.oldestSequence, resp.newestSequence);
};
}
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
final ReadResultSetImpl resultSet = nodeEngine.getSerializationService().toObject(response);
final List<Data> items = new ArrayList<Data>(resultSet.size());
final long[] seqs = new long[resultSet.size()];
final Data[] dataItems = resultSet.getDataItems();
for (int k = 0; k < resultSet.size(); k++) {
items.add(dataItems[k]);
seqs[k] = resultSet.getSequence(k);
}
return RingbufferReadManyCodec.encodeResponse(resultSet.readCount(), items, seqs, resultSet.getNextSequenceToReadFrom());
}
use of com.hazelcast.ringbuffer.impl.ReadResultSetImpl in project hazelcast by hazelcast.
the class ClientRingbufferProxy method onInitialize.
@Override
protected void onInitialize() {
String partitionKey = StringPartitioningStrategy.getPartitionKey(name);
partitionId = getContext().getPartitionService().getPartitionId(partitionKey);
readManyAsyncResponseDecoder = clientMessage -> {
final RingbufferReadManyCodec.ResponseParameters params = RingbufferReadManyCodec.decodeResponse(clientMessage);
final ReadResultSetImpl readResultSet = new ReadResultSetImpl(params.readCount, params.items, params.itemSeqs, params.nextSeq);
readResultSet.setSerializationService(getSerializationService());
return readResultSet;
};
}
Aggregations