Search in sources :

Example 1 with BufferObjectDataOutput

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

the class MulticastService method send.

public void send(JoinMessage joinMessage) {
    if (!running) {
        return;
    }
    final BufferObjectDataOutput out = sendOutput;
    synchronized (sendLock) {
        try {
            out.writeByte(Packet.VERSION);
            out.writeObject(joinMessage);
            datagramPacketSend.setData(out.toByteArray());
            multicastSocket.send(datagramPacketSend);
            out.clear();
        } catch (IOException e) {
            logger.warning("You probably have too long Hazelcast configuration!", e);
        }
    }
}
Also used : BufferObjectDataOutput(com.hazelcast.nio.BufferObjectDataOutput) IOException(java.io.IOException)

Example 2 with BufferObjectDataOutput

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

the class BufferPoolTest method takeOutputBuffer_whenNestedInstance.

@Test
public void takeOutputBuffer_whenNestedInstance() {
    BufferObjectDataOutput found1 = bufferPool.takeOutputBuffer();
    BufferObjectDataOutput found2 = bufferPool.takeOutputBuffer();
    assertNotSame(found1, found2);
}
Also used : BufferObjectDataOutput(com.hazelcast.nio.BufferObjectDataOutput) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with BufferObjectDataOutput

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

the class BufferPoolTest method returnOutputBuffer_whenOverflowing.

@Test
public void returnOutputBuffer_whenOverflowing() throws IOException {
    for (int k = 0; k < BufferPoolImpl.MAX_POOLED_ITEMS; k++) {
        bufferPool.returnOutputBuffer(mock(BufferObjectDataOutput.class));
    }
    BufferObjectDataOutput out = mock(BufferObjectDataOutput.class);
    bufferPool.returnOutputBuffer(out);
    assertEquals(BufferPoolImpl.MAX_POOLED_ITEMS, bufferPool.outputQueue.size());
    // we need to make sure that the out was closed since we are not going to pool it.
    verify(out, times(1)).close();
}
Also used : BufferObjectDataOutput(com.hazelcast.nio.BufferObjectDataOutput) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with BufferObjectDataOutput

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

the class BufferPoolTest method takeOutputBuffer_whenPooledInstance.

// ======================= out ==========================================
@Test
public void takeOutputBuffer_whenPooledInstance() {
    BufferObjectDataOutput found1 = bufferPool.takeOutputBuffer();
    bufferPool.returnOutputBuffer(found1);
    BufferObjectDataOutput found2 = bufferPool.takeOutputBuffer();
    assertSame(found1, found2);
}
Also used : BufferObjectDataOutput(com.hazelcast.nio.BufferObjectDataOutput) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 5 with BufferObjectDataOutput

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

the class BufferPoolTest method returnOutputBuffer.

@Test
public void returnOutputBuffer() {
    BufferObjectDataOutput out = mock(BufferObjectDataOutput.class);
    bufferPool.returnOutputBuffer(out);
    // lets see if the item was pushed on the queue
    assertEquals(1, bufferPool.outputQueue.size());
    // we need to make sure clear was called
    verify(out, times(1)).clear();
}
Also used : BufferObjectDataOutput(com.hazelcast.nio.BufferObjectDataOutput) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

BufferObjectDataOutput (com.hazelcast.nio.BufferObjectDataOutput)13 QuickTest (com.hazelcast.test.annotation.QuickTest)8 Test (org.junit.Test)8 ParallelTest (com.hazelcast.test.annotation.ParallelTest)7 BufferObjectDataInput (com.hazelcast.nio.BufferObjectDataInput)6 IOException (java.io.IOException)3 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)2 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)2 SerializationUtil.createSerializerAdapter (com.hazelcast.internal.serialization.impl.SerializationUtil.createSerializerAdapter)1 BufferPool (com.hazelcast.internal.serialization.impl.bufferpool.BufferPool)1 CustomSerializationTest (com.hazelcast.nio.serialization.CustomSerializationTest)1 BackupAwareOperation (com.hazelcast.spi.BackupAwareOperation)1 Operation (com.hazelcast.spi.Operation)1 Constructor (java.lang.reflect.Constructor)1