compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (2)

View Page History
In some cases, it may make sense to retry the operation, but this should be thought about carefully, as the cause of the timeout may be exacerbated. In the case of deciding to retry, doing this with a backoff or exponential backoff (see bulk loading below for an example) is advisable. This can be conceptually thought of as a pressure relief valve for intermittent resource contention.

h3. Timeout Instead of Blocking

In the case that the application code calling the client is very quickly creating a large number of asynch operations, one may also see timeouts immediately upon requesting operations. Creating of an asynch operation is really a matter of creating the object and putting it on a request queue. These are all local-to-the-system memory operations that require some amount of IO to be serviced.

Rather than allow the application to issue so many asynch operations that the JVM becomes overwhelmed and runs into an OOM condition, the default behavior of the client library is to start to immediately timeout asynch operations if the queue of operations to be sent to the server is overwhelmed.

If, for your application purposes, it'd be better to have some blocking when requesting these asynch operations because your application is issuing them at an extreme rate (example, bulk loading), that behavior can be configured like so:

{code}
List<URI> baselist = new ArrayList<URI>();
baselist.add(new URI("http://localhost:8091/pools"));

CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder();
cfb.setOpQueueMaxBlockTime(5000); // wait up to 5 seconds when trying to enqueue an operation

CouchbaseClient myclient = new CouchbaseClient(cfb.buildCouchbaseConnection(baselist, "default", "default", ""));
{code}

h2. Bulk Loading

{code}

Make sure you use this along with some tuning to be sure operations aren't immediately timed out if there are too many outstanding asynch operations.
{code}
List<URI> baselist = new ArrayList<URI>();
baselist.add(new URI("http://localhost:8091/pools"));

CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder();
cfb.setOpTimeout(10000); // wait up to 10 seconds for an operation to succeed
cfb.setOpQueueMaxBlockTime(5000); // wait up to 5 seconds when trying to enqueue an operation

CouchbaseClient myclient = new CouchbaseClient(cfb.buildCouchbaseConnection(baselist, "default", "default", ""));
{code}

This code sample originally appeared in [this gist|https://gist.github.com/2232909] by&nbsp;[Matt Ingenthron|~ingenthr].