use of com.hazelcast.ringbuffer.impl.client.PortableReadResultSet in project hazelcast by hazelcast.
the class ReadManyOperationTest method whenEnoughItemsAvailableAndReturnPortable.
@Test
public void whenEnoughItemsAvailableAndReturnPortable() throws Exception {
long startSequence = ringbuffer.tailSequence() + 1;
ReadManyOperation op = new ReadManyOperation(ringbuffer.getName(), startSequence, 1, 3, null, true);
op.setNodeEngine(nodeEngine);
ringbuffer.add("item1");
ringbuffer.add("item2");
ringbuffer.add("item3");
ringbuffer.add("item4");
ringbuffer.add("item5");
assertFalse(op.shouldWait());
HeapData response = assertInstanceOf(HeapData.class, op.getResponse());
PortableReadResultSet readResultSet = serializationService.toObject(response);
assertEquals(startSequence + 3, op.sequence);
assertEquals(3, readResultSet.readCount());
assertEquals(3, readResultSet.getDataItems().size());
readResultSet.setSerializationService(serializationService);
assertIterableEquals(readResultSet, "item1", "item2", "item3");
}
use of com.hazelcast.ringbuffer.impl.client.PortableReadResultSet in project hazelcast by hazelcast.
the class ReadManyOperation method getResponse.
@Override
public Object getResponse() {
if (returnPortable) {
List<Data> items = new ArrayList<Data>(resultSet.size());
for (int k = 0; k < resultSet.size(); k++) {
items.add(resultSet.getDataItems()[k]);
}
PortableReadResultSet portableReadResultSet = new PortableReadResultSet(resultSet.readCount(), items);
return getNodeEngine().toData(portableReadResultSet);
}
return resultSet;
}
use of com.hazelcast.ringbuffer.impl.client.PortableReadResultSet in project hazelcast by hazelcast.
the class ClientRingbufferProxy method onInitialize.
@Override
protected void onInitialize() {
String partitionKey = StringPartitioningStrategy.getPartitionKey(name);
partitionId = getContext().getPartitionService().getPartitionId(partitionKey);
final SerializationService serializationService = getContext().getSerializationService();
readManyAsyncResponseDecoder = new ClientMessageDecoder() {
@Override
public PortableReadResultSet decodeClientMessage(ClientMessage clientMessage) {
final RingbufferReadManyCodec.ResponseParameters responseParameters = RingbufferReadManyCodec.decodeResponse(clientMessage);
PortableReadResultSet readResultSet = new PortableReadResultSet(responseParameters.readCount, responseParameters.items);
readResultSet.setSerializationService(serializationService);
return readResultSet;
}
};
}
Aggregations