Example usage for io.netty.util ReferenceCountUtil releaseLater

List of usage examples for io.netty.util ReferenceCountUtil releaseLater

Introduction

In this page you can find the example usage for io.netty.util ReferenceCountUtil releaseLater.

Prototype

@Deprecated
public static <T> T releaseLater(T msg) 

Source Link

Document

Schedules the specified object to be released when the caller thread terminates.

Usage

From source file:com.couchbase.client.core.endpoint.kv.KeyValueHandlerTest.java

License:Apache License

@Test
public void shouldEncodeReplicaGetRequest() {
    String id = "replicakey";
    ReplicaGetRequest request = new ReplicaGetRequest(id, BUCKET, (short) 1);
    request.partition((short) 512);

    channel.writeOutbound(request);//from www.j a  va  2  s.c om
    BinaryMemcacheRequest outbound = (BinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals(id, new String(outbound.getKey(), CHARSET));
    assertEquals(id.length(), outbound.getKeyLength());
    assertEquals(id.length(), outbound.getTotalBodyLength());
    assertEquals(512, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_GET_REPLICA, outbound.getOpcode());
    assertEquals(0, outbound.getExtrasLength());
    ReferenceCountUtil.releaseLater(outbound);
}

From source file:com.couchbase.client.core.endpoint.kv.KeyValueHandlerTest.java

License:Apache License

@Test
public void shouldEncodeGetAndTouch() {
    GetRequest request = new GetRequest("key", "bucket", false, true, 10);
    request.partition((short) 1);

    channel.writeOutbound(request);//from  w  w  w  .ja v  a2  s .  c  o  m
    BinaryMemcacheRequest outbound = (BinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals("key".length() + 4, outbound.getTotalBodyLength());
    assertEquals(1, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_GET_AND_TOUCH, outbound.getOpcode());
    assertEquals(4, outbound.getExtrasLength());
    assertEquals(10, outbound.getExtras().readInt());
    ReferenceCountUtil.releaseLater(outbound);
}

From source file:com.couchbase.client.core.endpoint.kv.KeyValueHandlerTest.java

License:Apache License

@Test
public void shouldEncodeGetAndLock() {
    GetRequest request = new GetRequest("key", "bucket", true, false, 5);
    request.partition((short) 1024);

    channel.writeOutbound(request);/* w ww. j a va  2 s  .  c o  m*/
    BinaryMemcacheRequest outbound = (BinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals("key".length() + 4, outbound.getTotalBodyLength());
    assertEquals(1024, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_GET_AND_LOCK, outbound.getOpcode());
    assertEquals(4, outbound.getExtrasLength());
    assertEquals(5, outbound.getExtras().readInt());
    ReferenceCountUtil.releaseLater(outbound);
}

From source file:com.couchbase.client.core.endpoint.kv.KeyValueHandlerTest.java

License:Apache License

@Test
public void shouldEncodeGetBucketConfigRequest() {
    GetBucketConfigRequest request = new GetBucketConfigRequest("bucket", mock(InetAddress.class));

    channel.writeOutbound(request);//from  ww  w  . j  a  va  2 s.co m
    BinaryMemcacheRequest outbound = (BinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals(0, outbound.getReserved());
    assertEquals(0, outbound.getKeyLength());
    assertEquals(0, outbound.getTotalBodyLength());
    assertEquals(0, outbound.getExtrasLength());
    assertEquals(KeyValueHandler.OP_GET_BUCKET_CONFIG, outbound.getOpcode());
    ReferenceCountUtil.releaseLater(outbound);
}

From source file:com.couchbase.client.core.endpoint.kv.KeyValueHandlerTest.java

License:Apache License

@Test
public void shouldEncodeInsertRequest() {
    ByteBuf content = Unpooled.copiedBuffer("content", CharsetUtil.UTF_8);

    InsertRequest request = new InsertRequest("key", content.copy(), "bucket");
    request.partition((short) 512);
    channel.writeOutbound(request);//from   w  ww  .  j a  v a2 s  .com
    FullBinaryMemcacheRequest outbound = (FullBinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals(512, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_INSERT, outbound.getOpcode());
    assertEquals(8, outbound.getExtrasLength());
    assertEquals(0, outbound.getExtras().readInt());
    assertEquals(0, outbound.getExtras().readInt());
    assertEquals(18, outbound.getTotalBodyLength());
    assertEquals(0, outbound.getCAS());
    assertEquals("content", outbound.content().toString(CharsetUtil.UTF_8));
    ReferenceCountUtil.releaseLater(outbound);

    request = new InsertRequest("key", content.copy(), 10, 0, "bucket");
    request.partition((short) 512);
    channel.writeOutbound(request);
    outbound = (FullBinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals(512, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_INSERT, outbound.getOpcode());
    assertEquals(8, outbound.getExtrasLength());
    assertEquals(0, outbound.getExtras().readInt());
    assertEquals(10, outbound.getExtras().readInt());
    assertEquals(18, outbound.getTotalBodyLength());
    assertEquals("content", outbound.content().toString(CharsetUtil.UTF_8));
    ReferenceCountUtil.releaseLater(outbound);

    request = new InsertRequest("key", content.copy(), 0, 5, "bucket");
    request.partition((short) 512);
    channel.writeOutbound(request);
    outbound = (FullBinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals(512, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_INSERT, outbound.getOpcode());
    assertEquals(8, outbound.getExtrasLength());
    assertEquals(5, outbound.getExtras().readInt());
    assertEquals(0, outbound.getExtras().readInt());
    assertEquals(18, outbound.getTotalBodyLength());
    assertEquals("content", outbound.content().toString(CharsetUtil.UTF_8));
    ReferenceCountUtil.releaseLater(outbound);

    request = new InsertRequest("key", content.copy(), 30, 99, "bucket");
    request.partition((short) 512);
    channel.writeOutbound(request);
    outbound = (FullBinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals(512, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_INSERT, outbound.getOpcode());
    assertEquals(8, outbound.getExtrasLength());
    assertEquals(99, outbound.getExtras().readInt());
    assertEquals(30, outbound.getExtras().readInt());
    assertEquals(18, outbound.getTotalBodyLength());
    assertEquals("content", outbound.content().toString(CharsetUtil.UTF_8));
    ReferenceCountUtil.releaseLater(outbound);

    ReferenceCountUtil.release(content);
}

From source file:com.couchbase.client.core.endpoint.kv.KeyValueHandlerTest.java

License:Apache License

@Test
public void shouldEncodeUpsertRequest() {
    ByteBuf content = Unpooled.copiedBuffer("content", CharsetUtil.UTF_8);

    UpsertRequest request = new UpsertRequest("key", content.copy(), "bucket");
    request.partition((short) 512);
    channel.writeOutbound(request);/*from  w  w  w  .j a  v a 2s  . c om*/
    FullBinaryMemcacheRequest outbound = (FullBinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals(512, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_UPSERT, outbound.getOpcode());
    assertEquals(8, outbound.getExtrasLength());
    assertEquals(0, outbound.getExtras().readInt());
    assertEquals(0, outbound.getExtras().readInt());
    assertEquals(18, outbound.getTotalBodyLength());
    assertEquals(0, outbound.getCAS());
    assertEquals("content", outbound.content().toString(CharsetUtil.UTF_8));
    ReferenceCountUtil.releaseLater(outbound);

    request = new UpsertRequest("key", content.copy(), 10, 0, "bucket");
    request.partition((short) 512);
    channel.writeOutbound(request);
    outbound = (FullBinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals(512, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_UPSERT, outbound.getOpcode());
    assertEquals(8, outbound.getExtrasLength());
    assertEquals(0, outbound.getExtras().readInt());
    assertEquals(10, outbound.getExtras().readInt());
    assertEquals(18, outbound.getTotalBodyLength());
    assertEquals("content", outbound.content().toString(CharsetUtil.UTF_8));
    ReferenceCountUtil.releaseLater(outbound);

    request = new UpsertRequest("key", content.copy(), 0, 5, "bucket");
    request.partition((short) 512);
    channel.writeOutbound(request);
    outbound = (FullBinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals(512, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_UPSERT, outbound.getOpcode());
    assertEquals(8, outbound.getExtrasLength());
    assertEquals(5, outbound.getExtras().readInt());
    assertEquals(0, outbound.getExtras().readInt());
    assertEquals(18, outbound.getTotalBodyLength());
    assertEquals("content", outbound.content().toString(CharsetUtil.UTF_8));
    ReferenceCountUtil.releaseLater(outbound);

    request = new UpsertRequest("key", content.copy(), 30, 99, "bucket");
    request.partition((short) 512);
    channel.writeOutbound(request);
    outbound = (FullBinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals(512, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_UPSERT, outbound.getOpcode());
    assertEquals(8, outbound.getExtrasLength());
    assertEquals(99, outbound.getExtras().readInt());
    assertEquals(30, outbound.getExtras().readInt());
    assertEquals(18, outbound.getTotalBodyLength());
    assertEquals("content", outbound.content().toString(CharsetUtil.UTF_8));
    ReferenceCountUtil.releaseLater(outbound);

    ReferenceCountUtil.release(content);
}

From source file:com.couchbase.client.core.endpoint.kv.KeyValueHandlerTest.java

License:Apache License

@Test
public void shouldEncodeReplaceRequest() {
    ByteBuf content = Unpooled.copiedBuffer("content", CharsetUtil.UTF_8);

    ReplaceRequest request = new ReplaceRequest("key", content.copy(), "bucket");
    request.partition((short) 512);
    channel.writeOutbound(request);//w ww  .  java 2 s  .c  om
    FullBinaryMemcacheRequest outbound = (FullBinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals(512, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_REPLACE, outbound.getOpcode());
    assertEquals(8, outbound.getExtrasLength());
    assertEquals(0, outbound.getExtras().readInt());
    assertEquals(0, outbound.getExtras().readInt());
    assertEquals(18, outbound.getTotalBodyLength());
    assertEquals(0, outbound.getCAS());
    assertEquals("content", outbound.content().toString(CharsetUtil.UTF_8));
    ReferenceCountUtil.releaseLater(outbound);

    request = new ReplaceRequest("key", content.copy(), 0, 10, 0, "bucket");
    request.partition((short) 512);
    channel.writeOutbound(request);
    outbound = (FullBinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals(512, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_REPLACE, outbound.getOpcode());
    assertEquals(8, outbound.getExtrasLength());
    assertEquals(0, outbound.getExtras().readInt());
    assertEquals(10, outbound.getExtras().readInt());
    assertEquals(18, outbound.getTotalBodyLength());
    assertEquals("content", outbound.content().toString(CharsetUtil.UTF_8));
    ReferenceCountUtil.releaseLater(outbound);

    request = new ReplaceRequest("key", content.copy(), 0, 0, 5, "bucket");
    request.partition((short) 512);
    channel.writeOutbound(request);
    outbound = (FullBinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals(512, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_REPLACE, outbound.getOpcode());
    assertEquals(8, outbound.getExtrasLength());
    assertEquals(5, outbound.getExtras().readInt());
    assertEquals(0, outbound.getExtras().readInt());
    assertEquals(18, outbound.getTotalBodyLength());
    assertEquals("content", outbound.content().toString(CharsetUtil.UTF_8));
    ReferenceCountUtil.releaseLater(outbound);

    request = new ReplaceRequest("key", content.copy(), 0, 30, 99, "bucket");
    request.partition((short) 512);
    channel.writeOutbound(request);
    outbound = (FullBinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals(512, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_REPLACE, outbound.getOpcode());
    assertEquals(8, outbound.getExtrasLength());
    assertEquals(99, outbound.getExtras().readInt());
    assertEquals(30, outbound.getExtras().readInt());
    assertEquals(18, outbound.getTotalBodyLength());
    assertEquals("content", outbound.content().toString(CharsetUtil.UTF_8));
    ReferenceCountUtil.releaseLater(outbound);

    ReferenceCountUtil.release(content);
}

From source file:com.couchbase.client.core.endpoint.kv.KeyValueHandlerTest.java

License:Apache License

@Test
public void shouldEncodeReplaceWithCASRequest() {
    ByteBuf content = Unpooled.copiedBuffer("content", CharsetUtil.UTF_8);
    ReplaceRequest request = new ReplaceRequest("key", content.copy(), 4234234234L, 30, 99, "bucket");
    request.partition((short) 512);
    channel.writeOutbound(request);//  w  w  w. j ava  2s .  c  om
    FullBinaryMemcacheRequest outbound = (FullBinaryMemcacheRequest) channel.readOutbound();
    assertEquals(4234234234L, outbound.getCAS());
    ReferenceCountUtil.releaseLater(outbound);
    ReferenceCountUtil.release(content);
}

From source file:com.couchbase.client.core.endpoint.kv.KeyValueHandlerTest.java

License:Apache License

@Test
public void shouldEncodeRemoveRequest() {
    RemoveRequest request = new RemoveRequest("key", 234234234L, "bucket");
    request.partition((short) 1);

    channel.writeOutbound(request);/*from  www  .j a  va2s .  c om*/
    BinaryMemcacheRequest outbound = (BinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals("key".length(), outbound.getTotalBodyLength());
    assertEquals(1, outbound.getReserved());
    assertEquals(KeyValueHandler.OP_REMOVE, outbound.getOpcode());
    assertEquals(0, outbound.getExtrasLength());
    assertEquals(234234234L, outbound.getCAS());
    ReferenceCountUtil.releaseLater(outbound);
}

From source file:com.couchbase.client.core.endpoint.kv.KeyValueHandlerTest.java

License:Apache License

@Test
public void shouldEncodePositiveCounterRequest() {
    CounterRequest request = new CounterRequest("key", 5, 10, 15, "bucket");
    request.partition((short) 1);

    channel.writeOutbound(request);/*from   w w  w  .  j a  va 2s  .  c  o m*/
    BinaryMemcacheRequest outbound = (BinaryMemcacheRequest) channel.readOutbound();
    assertNotNull(outbound);
    assertEquals("key", new String(outbound.getKey(), CHARSET));
    assertEquals("key".length(), outbound.getKeyLength());
    assertEquals("key".length() + 20, outbound.getTotalBodyLength());
    assertEquals(20, outbound.getExtrasLength());
    assertEquals(10, outbound.getExtras().readLong());
    assertEquals(5, outbound.getExtras().readLong());
    assertEquals(15, outbound.getExtras().readInt());
    assertEquals(KeyValueHandler.OP_COUNTER_INCR, outbound.getOpcode());
    ReferenceCountUtil.releaseLater(outbound);
}