use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class DataInputOutputTest method testDataStreams.
private void testDataStreams(Object object, ByteOrder byteOrder, boolean allowUnsafe) throws IOException {
InternalSerializationService ss = createSerializationServiceBuilder().setUseNativeByteOrder(false).setAllowUnsafe(allowUnsafe).setByteOrder(byteOrder).build();
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectDataOutput out = createObjectDataOutputStream(bout, ss);
out.writeObject(object);
byte[] data1 = bout.toByteArray();
ObjectDataOutput out2 = ss.createObjectDataOutput(1024);
out2.writeObject(object);
byte[] data2 = out2.toByteArray();
assertEquals(data1.length, data2.length);
assertTrue(Arrays.equals(data1, data2));
final ByteArrayInputStream bin = new ByteArrayInputStream(data2);
final ObjectDataInput in = createObjectDataInputStream(bin, ss);
final Object object1 = in.readObject();
final ObjectDataInput in2 = ss.createObjectDataInput(data1);
final Object object2 = in2.readObject();
Assert.assertEquals(object, object1);
Assert.assertEquals(object, object2);
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class OperationPacketFilter method filterOperation.
private Action filterOperation(Packet packet, Address endpoint) {
try {
ObjectDataInput input = serializationService.createObjectDataInput(packet);
byte header = input.readByte();
boolean identified = (header & 1) != 0;
if (identified) {
boolean compressed = (header & 1 << 2) != 0;
int factory = compressed ? input.readByte() : input.readInt();
int type = compressed ? input.readByte() : input.readInt();
return filterOperation(endpoint, factory, type);
}
} catch (IOException e) {
throw new HazelcastException(e);
}
return Action.ALLOW;
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class TransferableJobProcessInformation method readPortable.
@Override
public void readPortable(PortableReader reader) throws IOException {
processedRecords = reader.readInt("processedRecords");
ObjectDataInput in = reader.getRawDataInput();
partitionStates = in.readObject();
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class PortableCollection method readPortable.
@Override
public void readPortable(PortableReader reader) throws IOException {
boolean list = reader.readBoolean("l");
int size = reader.readInt("s");
if (size == -1) {
return;
}
if (list) {
collection = new ArrayList<Data>(size);
} else {
collection = new HashSet<Data>(size);
}
final ObjectDataInput in = reader.getRawDataInput();
for (int i = 0; i < size; i++) {
Data data = in.readData();
collection.add(data);
}
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class PortableReadResultSet method readPortable.
@Override
public void readPortable(PortableReader reader) throws IOException {
readCount = reader.readInt("readCount");
// reading the items.
int size = reader.readInt("count");
this.items = new ArrayList<Data>(size);
ObjectDataInput rawDataInput = reader.getRawDataInput();
for (int k = 0; k < size; k++) {
Data item = rawDataInput.readData();
items.add(item);
}
}
Aggregations