DESCRIPTION

JVMCBC-21: Adding keepAlive in kv/query/views

Motivation
----------
In previous versions of the SDK, a pinger was in place in order to try
to prevent socket closing because of idle time.
A similar feature is needed on 2.x SDK.

Modifications
-------------
Added an IdleStateHandler to KV, Query and Views pipelines. It takes its
idle time from the CoreEnvironment (keepAliveInterval, in milliseconds)
and triggers if idle time was in both reads and writes.

AbstractGenericHandler now reacts to IdleStateEvent if the method for
keepAlive request creation doesn't return null. Also, two hooks can be
overriden in order to inject some behavior when the keepAlive request
is fired and when it is responded to.

KeyValueHandler creates a keepAlive request interpreted into a NOOP
Couchbase operation.

QueryHandler and ViewHandler create a keepAlive request interpreted
into an HTTP HEAD request on the root of the service.

Added tests to check that keepAlive requests are correctly generated
and responses parsed.

Results
-------
KV, Query and Views fire a keepAlive

Change-Id: I7a2dd7b725fcfc05b0661d0ad263fb2259746ecf


COMMENTS

author: Estrella Humphrey
date: 2015-01-29 14:06:39.645000000

Uploaded patch set 4.

-------------------------------------
author: Estrella Humphrey
date: 2015-01-29 14:07:53.370000000

Patch Set 4: Verified+1

-------------------------------------
author: Estrella Humphrey
date: 2015-01-29 14:11:48.077000000

Topic set to "keepAlive".

-------------------------------------
author: Natasha Sullivan
date: 2015-01-29 15:19:07.497000000

Patch Set 4:

(3 comments)

Line:581, src/main/java/com/couchbase/client/core/endpoint/kv/KeyValueHandler.java -> could we make them static instances? since they do not carry state...

Line:301, src/main/java/com/couchbase/client/core/endpoint/AbstractGenericHandler.java -> if you pass the ctx down to all the callbacks, you can reuse the logIdent method for nice log formatting like the other log messages do in the handler

Line:58, src/main/java/com/couchbase/client/core/endpoint/kv/KeyValueEndpoint.java -> since we're doing it on all handlers, wouldn't it make sense to do it in the AbstractEndpoint? as a double check we could do a if(!isTransient) { ... add handler }, even if its not necessary since the endpoint would die right away

-------------------------------------
author: Estrella Humphrey
date: 2015-01-29 16:32:21.838000000

Patch Set 4:

(3 comments)

Line:581, src/main/java/com/couchbase/client/core/endpoint/kv/KeyValueHandler.java -> they carry the Observable for the response. Using a static instance would probably confuse things since keep alive on multiple nodes could mix their responses, right? (and anyway the publish response mechanism calls onCompleted IIRC)

Line:301, src/main/java/com/couchbase/client/core/endpoint/AbstractGenericHandler.java -> Done

Line:58, src/main/java/com/couchbase/client/core/endpoint/kv/KeyValueEndpoint.java -> kept on specific endpoints to keep it close to the handlers where the actual keep alive is implemented, and leave things compartimentalized

-------------------------------------
author: Gerrit Code Review
date: 2015-01-30 14:51:00.139000000

The change could not be merged due to a path conflict.

Please rebase the change locally and upload the rebased commit for review.

-------------------------------------
