DESCRIPTION

JCBC-810: Cache getFromReplica to avoid eager unsubscription leaks.

Motivation
----------
A common pattern to execute is getFromReplica(ALL) and then use methods
like first() or take(n) to get specific objects out of the observable.

A problem has been identified with eager unsubscriptions and object
leakage (the contained ByteBufs are not properly freed on the unsubscribed
observable).

Modifications
-------------
By using the cache() operator, the emitted values are cached and a potential
unsubscribe is disconnected. Since a maximum of 4 values can be emitted, this
should not be a problem.

The ReplicaMode has been extended to provide how many nodes might be affected
so that a size hint can be provided to cache() and keep the memory overhead
as low as possible.

Result
------
Using first() or take(n) methods on the getFromReplica() method work without
issues and leaks.

Change-Id: Ieae5c08f1edd41745c9c2d64db657cdc5208fdb7


COMMENTS

author: Natasha Sullivan
date: 2015-07-15 09:57:52.258000000

Uploaded patch set 1.

-------------------------------------
author: Natasha Sullivan
date: 2015-07-15 10:04:13.828000000

Patch Set 1: Verified+1

-------------------------------------
author: Estrella Humphrey
date: 2015-07-15 12:30:52.461000000

Patch Set 1: Code-Review+2

-------------------------------------
author: Tate Garrett
date: 2015-07-15 13:13:38.050000000

Change has been successfully cherry-picked as 0f29c2b53490812a127e7e44945a7d6c140bd8ad

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