use of com.hazelcast.internal.nio.BufferObjectDataOutput in project hazelcast by hazelcast.
the class PortableSerializer method write.
@Override
public void write(ObjectDataOutput out, Object o) throws IOException {
if (o instanceof Portable) {
Portable p = (Portable) o;
if (!(out instanceof BufferObjectDataOutput)) {
throw new IllegalArgumentException("ObjectDataOutput must be instance of BufferObjectDataOutput!");
}
if (p.getClassId() == 0) {
throw new IllegalArgumentException("Portable class ID cannot be zero!");
}
out.writeInt(p.getFactoryId());
out.writeInt(p.getClassId());
writeInternal((BufferObjectDataOutput) out, p);
return;
}
if (o instanceof PortableGenericRecord) {
writePortableGenericRecord(out, (PortableGenericRecord) o);
return;
}
throw new IllegalArgumentException("PortableSerializer can only write Portable and PortableGenericRecord");
}
use of com.hazelcast.internal.nio.BufferObjectDataOutput in project hazelcast by hazelcast.
the class CompactStreamSerializer method write.
// ========================== WRITE =============================//
@Override
public void write(ObjectDataOutput out, Object o) throws IOException {
assert out instanceof BufferObjectDataOutput;
BufferObjectDataOutput bufferObjectDataOutput = (BufferObjectDataOutput) out;
write(bufferObjectDataOutput, o, false);
}
use of com.hazelcast.internal.nio.BufferObjectDataOutput in project hazelcast by hazelcast.
the class AbstractSerializationServiceTest method testWriteObject_serializerFail.
@Test(expected = HazelcastSerializationException.class)
public void testWriteObject_serializerFail() throws Exception {
abstractSerializationService.register(StringBuffer.class, new StringBufferSerializer(true));
BufferObjectDataOutput out = abstractSerializationService.createObjectDataOutput();
abstractSerializationService.writeObject(out, new StringBuffer());
}
use of com.hazelcast.internal.nio.BufferObjectDataOutput in project hazelcast by hazelcast.
the class BufferPoolTest method takeOutputBuffer_whenPooledInstanceWithVersionSetIsReturned.
@Test
public void takeOutputBuffer_whenPooledInstanceWithVersionSetIsReturned() {
BufferObjectDataOutput found1 = bufferPool.takeOutputBuffer();
assertEquals(Version.UNKNOWN, found1.getVersion());
found1.setVersion(Versions.CURRENT_CLUSTER_VERSION);
bufferPool.returnOutputBuffer(found1);
BufferObjectDataOutput found2 = bufferPool.takeOutputBuffer();
assertEquals(Version.UNKNOWN, found2.getVersion());
}
use of com.hazelcast.internal.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