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);
}
}
}
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);
}
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();
}
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);
}
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();
}
Aggregations