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);
}
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class ReplicatedMapPortableEntryEvent method readPortable.
public void readPortable(PortableReader reader) throws IOException {
eventType = EntryEventType.getByType(reader.readInt("e"));
uuid = reader.readUTF("u");
final ObjectDataInput in = reader.getRawDataInput();
key = in.readData();
value = in.readData();
oldValue = in.readData();
numberOfAffectedEntries = in.readInt();
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class ClientPartitionLostListenerTest method test_portableMapPartitionLostEvent_deserialization.
@Test
public void test_portableMapPartitionLostEvent_deserialization() throws IOException {
final Address source = new Address();
final PortablePartitionLostEvent event = new PortablePartitionLostEvent();
final PortableReader reader = mock(PortableReader.class);
final ObjectDataInput input = mock(ObjectDataInput.class);
when(reader.getRawDataInput()).thenReturn(input);
when(reader.readInt("p")).thenReturn(1);
when(reader.readInt("l")).thenReturn(2);
when(input.readObject()).thenReturn(source);
event.readPortable(reader);
assertEquals(1, event.getPartitionId());
assertEquals(2, event.getLostBackupCount());
assertEquals(source, event.getSource());
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class SerializationV1Portable method readPortable.
@Override
public void readPortable(PortableReader in) throws IOException {
this.aByte = in.readByte("1");
this.aBoolean = in.readBoolean("2");
this.character = in.readChar("3");
this.aShort = in.readShort("4");
this.integer = in.readInt("5");
this.aLong = in.readLong("6");
this.aFloat = in.readFloat("7");
this.aDouble = in.readDouble("8");
this.string = in.readUTF("9");
this.bytes = in.readByteArray("a1");
this.booleans = in.readBooleanArray("a2");
this.chars = in.readCharArray("a3");
this.shorts = in.readShortArray("a4");
this.ints = in.readIntArray("a5");
this.longs = in.readLongArray("a6");
this.floats = in.readFloatArray("a7");
this.doubles = in.readDoubleArray("a8");
this.strings = in.readUTFArray("a9");
this.innerPortable = in.readPortable("p");
ObjectDataInput rawDataInput = in.getRawDataInput();
boolean isNotNull = rawDataInput.readBoolean();
if (isNotNull) {
SerializationV1Dataserializable dataserializable = new SerializationV1Dataserializable();
dataserializable.readData(rawDataInput);
this.dataSerializable = dataserializable;
}
}
use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.
the class SerializationTest method testGlobalSerializer_withoutOverrideJavaSerializable.
@Test
public void testGlobalSerializer_withoutOverrideJavaSerializable() {
GlobalSerializerConfig globalSerializerConfig = new GlobalSerializerConfig();
globalSerializerConfig.setOverrideJavaSerialization(false);
final AtomicInteger writeCounter = new AtomicInteger();
final AtomicInteger readCounter = new AtomicInteger();
SerializationConfig serializationConfig = new SerializationConfig().setGlobalSerializerConfig(globalSerializerConfig.setImplementation(new StreamSerializer<Object>() {
@Override
public void write(ObjectDataOutput out, Object v) throws IOException {
writeCounter.incrementAndGet();
out.writeUTF(((DummyValue) v).s);
out.writeInt(((DummyValue) v).k);
}
@Override
public Object read(ObjectDataInput in) throws IOException {
readCounter.incrementAndGet();
return new DummyValue(in.readUTF(), in.readInt());
}
public int getTypeId() {
return 123;
}
public void destroy() {
}
}));
SerializationService ss1 = new DefaultSerializationServiceBuilder().setConfig(serializationConfig).build();
DummyValue value = new DummyValue("test", 111);
Data data1 = ss1.toData(value);
Data data2 = ss1.toData(new Foo());
Assert.assertNotNull(data1);
Assert.assertNotNull(data2);
assertEquals(1, writeCounter.get());
SerializationService ss2 = new DefaultSerializationServiceBuilder().setConfig(serializationConfig).build();
Object o1 = ss2.toObject(data1);
Object o2 = ss2.toObject(data2);
Assert.assertEquals(value, o1);
Assert.assertNotNull(o2);
assertEquals(1, readCounter.get());
}
Aggregations