Search in sources :

Example 6 with ObjectDataInput

use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.

the class PortableEntryEvent method readPortable.

@Override
public void readPortable(PortableReader reader) throws IOException {
    eventType = EntryEventType.getByType(reader.readInt("e"));
    uuid = reader.readUTF("u");
    numberOfAffectedEntries = reader.readInt("n");
    ObjectDataInput in = reader.getRawDataInput();
    key = in.readData();
    value = in.readData();
    oldValue = in.readData();
    mergingValue = in.readData();
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput)

Example 7 with ObjectDataInput

use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.

the class PortablePartitionLostEvent method readPortable.

@Override
public void readPortable(PortableReader reader) throws IOException {
    partitionId = reader.readInt("p");
    lostBackupCount = reader.readInt("l");
    final ObjectDataInput in = reader.getRawDataInput();
    source = in.readObject();
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput)

Example 8 with ObjectDataInput

use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.

the class RawDataPortable method readPortable.

@Override
public void readPortable(PortableReader reader) throws IOException {
    l = reader.readLong("l");
    c = reader.readCharArray("c");
    p = reader.readPortable("p");
    final ObjectDataInput input = reader.getRawDataInput();
    k = input.readInt();
    s = input.readUTF();
    sds = input.readObject();
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput)

Example 9 with ObjectDataInput

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);
}
Also used : ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput) ByteArrayInputStream(java.io.ByteArrayInputStream) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectDataInput(com.hazelcast.nio.ObjectDataInput)

Example 10 with ObjectDataInput

use of com.hazelcast.nio.ObjectDataInput in project hazelcast by hazelcast.

the class InvalidRawDataPortable2 method readPortable.

@Override
public void readPortable(PortableReader reader) throws IOException {
    c = reader.readCharArray("c");
    final ObjectDataInput input = reader.getRawDataInput();
    k = input.readInt();
    l = reader.readLong("l");
    s = input.readUTF();
    p = reader.readPortable("p");
    sds = input.readObject();
}
Also used : ObjectDataInput(com.hazelcast.nio.ObjectDataInput)

Aggregations

ObjectDataInput (com.hazelcast.nio.ObjectDataInput)80 Test (org.junit.Test)35 QuickTest (com.hazelcast.test.annotation.QuickTest)32 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)24 BufferObjectDataInput (com.hazelcast.internal.nio.BufferObjectDataInput)17 FieldKind (com.hazelcast.nio.serialization.FieldKind)16 IOException (java.io.IOException)13 ObjectDataOutput (com.hazelcast.nio.ObjectDataOutput)12 Nullable (javax.annotation.Nullable)9 GlobalSerializerConfig (com.hazelcast.config.GlobalSerializerConfig)7 SerializationConfig (com.hazelcast.config.SerializationConfig)6 StreamSerializer (com.hazelcast.nio.serialization.StreamSerializer)6 Data (com.hazelcast.nio.serialization.Data)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 Data (com.hazelcast.internal.serialization.Data)3 SerializationService (com.hazelcast.internal.serialization.SerializationService)3 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)3 HeapData (com.hazelcast.internal.serialization.impl.HeapData)3 SerializationService (com.hazelcast.spi.serialization.SerializationService)3 SerializerConfig (com.hazelcast.config.SerializerConfig)2