Search in sources :

Example 26 with BufferObjectDataInput

use of com.hazelcast.internal.nio.BufferObjectDataInput in project hazelcast by hazelcast.

the class BufferPoolTest method returnInputBuffer_whenOverflowing.

@Test
public void returnInputBuffer_whenOverflowing() {
    for (int k = 0; k < BufferPoolImpl.MAX_POOLED_ITEMS; k++) {
        bufferPool.returnInputBuffer(mock(BufferObjectDataInput.class));
    }
    BufferObjectDataInput in = mock(BufferObjectDataInput.class);
    bufferPool.returnInputBuffer(in);
    assertEquals(BufferPoolImpl.MAX_POOLED_ITEMS, bufferPool.inputQueue.size());
}
Also used : BufferObjectDataInput(com.hazelcast.internal.nio.BufferObjectDataInput) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 27 with BufferObjectDataInput

use of com.hazelcast.internal.nio.BufferObjectDataInput 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);
    }
}
Also used : BufferObjectDataOutput(com.hazelcast.internal.nio.BufferObjectDataOutput) Constructor(java.lang.reflect.Constructor) BufferObjectDataInput(com.hazelcast.internal.nio.BufferObjectDataInput)

Example 28 with BufferObjectDataInput

use of com.hazelcast.internal.nio.BufferObjectDataInput in project hazelcast by hazelcast.

the class RingbufferContainerSerializationTest method clone.

private RingbufferContainer clone(RingbufferContainer original) {
    BufferObjectDataOutput out = serializationService.createObjectDataOutput(100000);
    try {
        out.writeObject(original);
        byte[] bytes = out.toByteArray();
        sleepMillis(CLOCK_DIFFERENCE_MS);
        BufferObjectDataInput in = serializationService.createObjectDataInput(bytes);
        RingbufferContainer clone = in.readObject();
        return clone;
    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        closeResource(out);
    }
}
Also used : BufferObjectDataOutput(com.hazelcast.internal.nio.BufferObjectDataOutput) IOException(java.io.IOException) BufferObjectDataInput(com.hazelcast.internal.nio.BufferObjectDataInput)

Aggregations

BufferObjectDataInput (com.hazelcast.internal.nio.BufferObjectDataInput)28 QuickTest (com.hazelcast.test.annotation.QuickTest)12 Test (org.junit.Test)12 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)11 Data (com.hazelcast.internal.serialization.Data)10 BufferObjectDataOutput (com.hazelcast.internal.nio.BufferObjectDataOutput)6 HeapData (com.hazelcast.internal.serialization.impl.HeapData)5 IOException (java.io.IOException)5 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)3 ClassDefinition (com.hazelcast.nio.serialization.ClassDefinition)3 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)2 SerializationUtil.createSerializerAdapter (com.hazelcast.internal.serialization.impl.SerializationUtil.createSerializerAdapter)2 SerializationUtil.isNullData (com.hazelcast.internal.serialization.impl.SerializationUtil.isNullData)2 BufferPool (com.hazelcast.internal.serialization.impl.bufferpool.BufferPool)2 CompactStreamSerializerAdapter (com.hazelcast.internal.serialization.impl.compact.CompactStreamSerializerAdapter)2 CompactWithSchemaStreamSerializerAdapter (com.hazelcast.internal.serialization.impl.compact.CompactWithSchemaStreamSerializerAdapter)2 HazelcastSerializationException (com.hazelcast.nio.serialization.HazelcastSerializationException)2 HazelcastException (com.hazelcast.core.HazelcastException)1 IOUtil.readData (com.hazelcast.internal.nio.IOUtil.readData)1 IOUtil.writeData (com.hazelcast.internal.nio.IOUtil.writeData)1