Java Code Examples for com.couchbase.client.java.error.TemporaryFailureException

The following examples show how to use com.couchbase.client.java.error.TemporaryFailureException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: samza   Source File: BaseCouchbaseTableFunction.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Check whether the exception is caused by one of the temporary failure exceptions, which are
 * likely to be retriable.
 * @param exception exception thrown by the table provider
 * @return true if we should retry, otherwise false
 */
public boolean isRetriable(Throwable exception) {
  while (exception != null
      && !(exception instanceof TemporaryFailureException)
      && !(exception instanceof TemporaryLockFailureException)
      && !(exception instanceof TimeoutException)) {
    exception = exception.getCause();
  }
  return exception != null;
}
 
Example 2
Source Project: samza   Source File: TestCouchbaseTableWriteFunction.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testIsRetriable() {
  CouchbaseTableWriteFunction writeFunction = createAndInit();
  assertTrue(writeFunction.isRetriable(new TemporaryFailureException()));
  assertTrue(writeFunction.isRetriable(new TemporaryLockFailureException()));
  assertTrue(writeFunction.isRetriable(new SamzaException(new TemporaryLockFailureException())));
  assertTrue(writeFunction.isRetriable(new SamzaException(new TemporaryFailureException())));
  assertTrue(writeFunction.isRetriable(
      new RuntimeException(new SamzaException(new RuntimeException(new TemporaryFailureException())))));
}
 
Example 3
Source Project: samza   Source File: TestCouchbaseTableReadFunction.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testIsRetriable() {
  CouchbaseTableReadFunction readFunction = createAndInit();
  assertTrue(readFunction.isRetriable(new TemporaryFailureException()));
  assertTrue(readFunction.isRetriable(new TemporaryLockFailureException()));
  assertTrue(readFunction.isRetriable(new SamzaException(new TemporaryLockFailureException())));
  assertTrue(readFunction.isRetriable(new SamzaException(new TemporaryFailureException())));
  assertTrue(readFunction.isRetriable(
      new RuntimeException(new SamzaException(new RuntimeException(new TemporaryFailureException())))));
}