DESCRIPTION

JCBC-554: Provide retry/backoff utility wrapper

Motivation
----------
Exponential retry and backoff is an useful pattern and it makes sense
to provide an utility class to the SDK users to do that.

Modifications
-------------
Added a Retry utility class that allows to describe a retry pattern by
wrapping the source.
An alternative is to directly use Observable.retryWhen with the new
RetryWhenFunction.

Both approaches take a RetryWithDelayHandler, a class that allows to
describe the retry pattern (max attempts, retry delay and how it grows,
exceptions that can be retried or on the contrary cancel retry cycle).

Added CannotRetryException to denote when a retry attempt failed. It
should always have the Exception that triggered the latest retry as its
cause.

Classes in the util.retry package are marked as Public but Experimental.

Added various unit tests to check the retry behavior.

Result
------
Users can more easily apply a retry pattern to their Observables, either
by calling a wrapping function or passing a RetryWhenFunction to their
Observable's retryWhen operation.

Change-Id: I6d51d834d9f4e1ea101da98d2b1c8ea9369f6c0a


COMMENTS

author: Estrella Humphrey
date: 2015-03-27 10:34:01.436000000

Uploaded patch set 5: Patch Set 4 was rebased.

-------------------------------------
author: Natasha Sullivan
date: 2015-03-27 10:49:11.780000000

Patch Set 5:

(8 comments)

Line:29, src/main/java/com/couchbase/client/java/error/CannotRetryException.java -> this is then not true anymore

Line:46, src/main/java/com/couchbase/client/java/util/retry/RetryBuilder.java -> make final and pass in through the private constructor, one less thing floating around

Line:76, src/main/java/com/couchbase/client/java/util/retry/RetryBuilder.java -> what about unless

Line:84, src/main/java/com/couchbase/client/java/util/retry/RetryBuilder.java -> what about if

Line:91, src/main/java/com/couchbase/client/java/util/retry/RetryBuilder.java -> what about delay

Line:97, src/main/java/com/couchbase/client/java/util/retry/RetryBuilder.java -> what about on

Line:96, src/main/java/com/couchbase/client/java/util/retry/RetryWithDelayHandler.java -> not needed anymore?

Line:107, src/main/java/com/couchbase/client/java/util/retry/RetryWithDelayHandler.java -> forward unretryable error immediately

-------------------------------------
author: Natasha Sullivan
date: 2015-03-27 10:55:04.548000000

Patch Set 5:

(2 comments)

Line:77, src/main/java/com/couchbase/client/java/util/retry/RetryBuilder.java -> also maybe support Collection?

Line:85, src/main/java/com/couchbase/client/java/util/retry/RetryBuilder.java -> also maybe support Collection?

-------------------------------------
author: Tate Garrett
date: 2015-03-27 12:31:25.327000000

Change has been successfully cherry-picked as 86f4fed4d7d9cb38205c54bf1cf016801ea10b1d

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