List of usage examples for io.netty.util ReferenceCountUtil releaseLater
@Deprecated public static <T> T releaseLater(T msg)
From source file:com.couchbase.client.core.cluster.KeyValueMessageTest.java
License:Apache License
@Test public void shouldReplaceWithMatchingCAS() throws Exception { final String key = "replace-key-cas-match"; final String content = "replace content"; ReplaceRequest insert = new ReplaceRequest(key, Unpooled.copiedBuffer(content, CharsetUtil.UTF_8), bucket());/*from w w w. j av a 2 s .c om*/ ReplaceResponse response = cluster().<ReplaceResponse>send(insert).toBlocking().single(); assertEquals(ResponseStatus.NOT_EXISTS, response.status()); ReferenceCountUtil.releaseLater(response.content()); assertNull(response.mutationToken()); UpsertRequest upsert = new UpsertRequest(key, Unpooled.copiedBuffer("insert content", CharsetUtil.UTF_8), bucket()); response = cluster().<UpsertResponse>send(upsert) .flatMap(new Func1<UpsertResponse, Observable<ReplaceResponse>>() { @Override public Observable<ReplaceResponse> call(UpsertResponse response) { ReferenceCountUtil.releaseLater(response.content()); return cluster().send(new ReplaceRequest(key, Unpooled.copiedBuffer(content, CharsetUtil.UTF_8), response.cas(), bucket())); } }).toBlocking().single(); ReferenceCountUtil.releaseLater(response.content()); assertEquals(ResponseStatus.SUCCESS, response.status()); assertValidMetadata(response.mutationToken()); }
From source file:com.couchbase.client.core.cluster.KeyValueMessageTest.java
License:Apache License
@Test public void shouldRemoveDocumentWithoutCAS() throws Exception { String key = "remove-key"; String content = "Hello World!"; UpsertRequest upsert = new UpsertRequest(key, Unpooled.copiedBuffer(content, CharsetUtil.UTF_8), bucket()); UpsertResponse upsertResponse = cluster().<UpsertResponse>send(upsert).toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, upsertResponse.status()); ReferenceCountUtil.releaseLater(upsertResponse.content()); assertValidMetadata(upsertResponse.mutationToken()); RemoveRequest remove = new RemoveRequest(key, bucket()); RemoveResponse response = cluster().<RemoveResponse>send(remove).toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, response.status()); assertTrue(response.cas() != 0);/* ww w . j ava2 s . com*/ ReferenceCountUtil.releaseLater(response.content()); assertValidMetadata(response.mutationToken()); assertMetadataSequence(upsertResponse.mutationToken(), response.mutationToken()); GetRequest get = new GetRequest(key, bucket()); GetResponse getResponse = cluster().<GetResponse>send(get).toBlocking().single(); assertEquals(ResponseStatus.NOT_EXISTS, getResponse.status()); ReferenceCountUtil.releaseLater(getResponse.content()); }
From source file:com.couchbase.client.core.cluster.KeyValueMessageTest.java
License:Apache License
@Test public void shouldRemoveDocumentWithCAS() throws Exception { String key = "remove-key-cas"; String content = "Hello World!"; UpsertRequest upsert = new UpsertRequest(key, Unpooled.copiedBuffer(content, CharsetUtil.UTF_8), bucket()); UpsertResponse upsertResponse = cluster().<UpsertResponse>send(upsert).toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, upsertResponse.status()); ReferenceCountUtil.releaseLater(upsertResponse.content()); assertValidMetadata(upsertResponse.mutationToken()); RemoveRequest remove = new RemoveRequest(key, 1233443, bucket()); RemoveResponse response = cluster().<RemoveResponse>send(remove).toBlocking().single(); assertEquals(ResponseStatus.EXISTS, response.status()); ReferenceCountUtil.releaseLater(response.content()); assertNull(response.mutationToken()); remove = new RemoveRequest(key, upsertResponse.cas(), bucket()); response = cluster().<RemoveResponse>send(remove).toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, response.status()); assertTrue(response.cas() != 0);//from w w w .ja v a 2s. c om ReferenceCountUtil.releaseLater(response.content()); assertValidMetadata(response.mutationToken()); assertMetadataSequence(upsertResponse.mutationToken(), response.mutationToken()); }
From source file:com.couchbase.client.core.cluster.KeyValueMessageTest.java
License:Apache License
@Test public void shouldGetAndTouch() throws Exception { String key = "get-and-touch"; UpsertRequest request = new UpsertRequest(key, Unpooled.copiedBuffer("content", CharsetUtil.UTF_8), 3, 0, bucket());/*from w w w. j a v a2s .c o m*/ UpsertResponse response = cluster().<UpsertResponse>send(request).toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, response.status()); ReferenceCountUtil.releaseLater(response.content()); Thread.sleep(2000); GetResponse getResponse = cluster().<GetResponse>send(new GetRequest(key, bucket(), false, true, 3)) .toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, getResponse.status()); assertEquals("content", getResponse.content().toString(CharsetUtil.UTF_8)); ReferenceCountUtil.releaseLater(getResponse.content()); Thread.sleep(2000); getResponse = cluster().<GetResponse>send(new GetRequest(key, bucket(), false, true, 3)).toBlocking() .single(); assertEquals(ResponseStatus.SUCCESS, getResponse.status()); assertEquals("content", getResponse.content().toString(CharsetUtil.UTF_8)); ReferenceCountUtil.releaseLater(getResponse.content()); }
From source file:com.couchbase.client.core.cluster.KeyValueMessageTest.java
License:Apache License
@Test public void shouldGetAndLock() throws Exception { String key = "get-and-lock"; UpsertRequest request = new UpsertRequest(key, Unpooled.copiedBuffer("content", CharsetUtil.UTF_8), bucket());/*www . ja va 2 s . c om*/ UpsertResponse response = cluster().<UpsertResponse>send(request).toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, response.status()); ReferenceCountUtil.releaseLater(response.content()); GetResponse getResponse = cluster().<GetResponse>send(new GetRequest(key, bucket(), true, false, 2)) .toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, getResponse.status()); assertEquals("content", getResponse.content().toString(CharsetUtil.UTF_8)); ReferenceCountUtil.releaseLater(getResponse.content()); request = new UpsertRequest(key, Unpooled.copiedBuffer("content", CharsetUtil.UTF_8), bucket()); response = cluster().<UpsertResponse>send(request).toBlocking().single(); assertEquals(ResponseStatus.EXISTS, response.status()); ReferenceCountUtil.releaseLater(response.content()); GetResponse secondLockResponse = (GetResponse) cluster().send(new GetRequest(key, bucket(), true, false, 2)) .toBlocking().single(); assertEquals(ResponseStatus.TEMPORARY_FAILURE, secondLockResponse.status()); ReferenceCountUtil.releaseLater(secondLockResponse.content()); Thread.sleep(3000); request = new UpsertRequest(key, Unpooled.copiedBuffer("content", CharsetUtil.UTF_8), bucket()); response = cluster().<UpsertResponse>send(request).toBlocking().single(); ReferenceCountUtil.releaseLater(response.content()); assertEquals(ResponseStatus.SUCCESS, response.status()); }
From source file:com.couchbase.client.core.cluster.KeyValueMessageTest.java
License:Apache License
/** * Verificiation for MB-15727.// w w w .j a va 2s. c o m * * This test is ignored in versions lower than 4.5 since thats the version where it has been fixed. */ @Test public void shouldGetAndLockWithAppend() throws Exception { assumeMinimumVersionCompatible(4, 5); String key = "get-and-lock-append"; UpsertRequest request = new UpsertRequest(key, Unpooled.copiedBuffer("foo", CharsetUtil.UTF_8), bucket()); UpsertResponse response = cluster().<UpsertResponse>send(request).toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, response.status()); ReferenceCountUtil.releaseLater(response.content()); GetResponse getResponse = cluster().<GetResponse>send(new GetRequest(key, bucket(), true, false, 2)) .toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, getResponse.status()); assertEquals("foo", getResponse.content().toString(CharsetUtil.UTF_8)); ReferenceCountUtil.releaseLater(getResponse.content()); AppendResponse appendResponse = cluster().<AppendResponse>send(new AppendRequest(key, getResponse.cas(), Unpooled.copiedBuffer("bar", CharsetUtil.UTF_8), bucket())).toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, getResponse.status()); assertTrue(getResponse.cas() != appendResponse.cas()); ReferenceCountUtil.releaseLater(appendResponse.content()); getResponse = cluster().<GetResponse>send(new GetRequest(key, bucket(), false, false, 0)).toBlocking() .single(); assertEquals(ResponseStatus.SUCCESS, getResponse.status()); assertEquals("foobar", getResponse.content().toString(CharsetUtil.UTF_8)); ReferenceCountUtil.releaseLater(getResponse.content()); }
From source file:com.couchbase.client.core.cluster.KeyValueMessageTest.java
License:Apache License
@Test public void shouldTouch() throws Exception { String key = "touch"; UpsertRequest request = new UpsertRequest(key, Unpooled.copiedBuffer("content", CharsetUtil.UTF_8), 3, 0, bucket());/*from ww w . java 2s .co m*/ UpsertResponse response = cluster().<UpsertResponse>send(request).toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, response.status()); ReferenceCountUtil.releaseLater(response.content()); Thread.sleep(2000); TouchResponse touchResponse = cluster().<TouchResponse>send(new TouchRequest(key, 3, bucket())).toBlocking() .single(); assertEquals(ResponseStatus.SUCCESS, touchResponse.status()); ReferenceCountUtil.releaseLater(touchResponse.content()); Thread.sleep(2000); GetResponse getResponse = cluster().<GetResponse>send(new GetRequest(key, bucket())).toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, getResponse.status()); assertEquals("content", getResponse.content().toString(CharsetUtil.UTF_8)); ReferenceCountUtil.releaseLater(getResponse.content()); }
From source file:com.couchbase.client.core.cluster.KeyValueMessageTest.java
License:Apache License
@Test public void shouldUnlock() throws Exception { String key = "unlock"; UpsertRequest request = new UpsertRequest(key, Unpooled.copiedBuffer("content", CharsetUtil.UTF_8), bucket());//from w w w. j av a2s. c o m UpsertResponse response = cluster().<UpsertResponse>send(request).toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, response.status()); ReferenceCountUtil.releaseLater(response.content()); GetResponse getResponse = cluster().<GetResponse>send(new GetRequest(key, bucket(), true, false, 15)) .toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, getResponse.status()); assertEquals("content", getResponse.content().toString(CharsetUtil.UTF_8)); ReferenceCountUtil.releaseLater(getResponse.content()); request = new UpsertRequest(key, Unpooled.copiedBuffer("content", CharsetUtil.UTF_8), bucket()); response = cluster().<UpsertResponse>send(request).toBlocking().single(); assertEquals(ResponseStatus.EXISTS, response.status()); ReferenceCountUtil.releaseLater(response.content()); UnlockRequest unlockRequest = new UnlockRequest(key, getResponse.cas(), bucket()); UnlockResponse unlockResponse = cluster().<UnlockResponse>send(unlockRequest).toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, unlockResponse.status()); ReferenceCountUtil.releaseLater(unlockResponse.content()); request = new UpsertRequest(key, Unpooled.copiedBuffer("content", CharsetUtil.UTF_8), bucket()); response = cluster().<UpsertResponse>send(request).toBlocking().single(); assertEquals(ResponseStatus.SUCCESS, response.status()); ReferenceCountUtil.releaseLater(response.content()); }
From source file:com.couchbase.client.core.cluster.KeyValueMessageTest.java
License:Apache License
@Test public void shouldHandleSpecialKeyChars() { String key = "AVERY READY INDEX"; String content = "Hello World!"; UpsertRequest upsert = new UpsertRequest(key, Unpooled.copiedBuffer(content, CharsetUtil.UTF_8), bucket()); UpsertResponse response = cluster().<UpsertResponse>send(upsert).toBlocking().single(); ReferenceCountUtil.releaseLater(response.content()); GetRequest request = new GetRequest(key, bucket()); GetResponse getResponse = cluster().<GetResponse>send(request).toBlocking().single(); assertEquals(content, getResponse.content().toString(CharsetUtil.UTF_8)); ReferenceCountUtil.releaseLater(getResponse.content()); }
From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java
License:Apache License
@Before public void prepareData() { UpsertRequest upsert = new UpsertRequest(testSubKey, Unpooled.copiedBuffer(jsonContent, CharsetUtil.UTF_8), bucket(), true);//from w w w . ja va2 s . c om UpsertResponse response = cluster().<UpsertResponse>send(upsert).toBlocking().single(); ReferenceCountUtil.releaseLater(response.content()); assertTrue("Couldn't insert " + testSubKey, response.status().isSuccess()); upsert = new UpsertRequest(testArrayRoot, Unpooled.copiedBuffer(jsonArrayContent, CharsetUtil.UTF_8), bucket(), true); response = cluster().<UpsertResponse>send(upsert).toBlocking().single(); ReferenceCountUtil.releaseLater(response.content()); assertTrue("Couldn't insert " + testArrayRoot, response.status().isSuccess()); upsert = new UpsertRequest(testComplexSubArray, Unpooled.copiedBuffer(jsonComplexSubArrayContent, CharsetUtil.UTF_8), bucket(), true); response = cluster().<UpsertResponse>send(upsert).toBlocking().single(); ReferenceCountUtil.releaseLater(response.content()); assertTrue("Couldn't insert " + testComplexSubArray, response.status().isSuccess()); }