use of com.hazelcast.nio.BufferObjectDataOutput in project hazelcast by hazelcast.
the class RingbufferContainerSerializationTest method clone.
private RingbufferContainer clone(RingbufferContainer original) {
BufferObjectDataOutput out = serializationService.createObjectDataOutput(100000);
BufferObjectDataInput in = null;
try {
out.writeObject(original);
byte[] bytes = out.toByteArray();
sleepMillis(CLOCK_DIFFERENCE_MS);
in = serializationService.createObjectDataInput(bytes);
RingbufferContainer clone = in.readObject();
return clone;
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
closeResource(out);
closeResource(in);
}
}
use of com.hazelcast.nio.BufferObjectDataOutput in project hazelcast by hazelcast.
the class PartitionTableViewTest method test_writeAndReadData.
@Test
public void test_writeAndReadData() throws Exception {
InternalSerializationService serializationService = new DefaultSerializationServiceBuilder().build();
PartitionTableView table1 = createRandomPartitionTable();
BufferObjectDataOutput out = serializationService.createObjectDataOutput();
PartitionTableView.writeData(table1, out);
BufferObjectDataInput in = serializationService.createObjectDataInput(out.toByteArray());
PartitionTableView table2 = PartitionTableView.readData(in);
assertEquals(table1, table2);
assertEquals(table1.hashCode(), table2.hashCode());
}
use of com.hazelcast.nio.BufferObjectDataOutput in project hazelcast by hazelcast.
the class OperationSerializationTest method copy.
private Operation copy(Operation op) {
try {
BufferObjectDataOutput out = serializationService.createObjectDataOutput(1000);
op.writeData(out);
BufferObjectDataInput in = serializationService.createObjectDataInput(out.toByteArray());
Constructor constructor = op.getClass().getConstructor();
constructor.setAccessible(true);
Operation copiedOperation = (Operation) constructor.newInstance();
copiedOperation.readData(in);
return copiedOperation;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations