Search in sources :

Example 1 with BlockingTimeoutException

use of com.palantir.lock.remoting.BlockingTimeoutException in project atlasdb by palantir.

the class ConjureTimelockResourceTest method handlesBlockingTimeout.

@Test
public void handlesBlockingTimeout() {
    when(resource.leaderTime(AUTH_HEADER, NAMESPACE)).thenThrow(new BlockingTimeoutException(""));
    assertQosExceptionThrownBy(resource.leaderTime(AUTH_HEADER, NAMESPACE), new AssertVisitor() {

        @Override
        public Void visit(QosException.Throttle exception) {
            assertThat(exception.getRetryAfter()).contains(Duration.ZERO);
            return null;
        }
    });
}
Also used : QosException(com.palantir.conjure.java.api.errors.QosException) BlockingTimeoutException(com.palantir.lock.remoting.BlockingTimeoutException) Test(org.junit.Test)

Example 2 with BlockingTimeoutException

use of com.palantir.lock.remoting.BlockingTimeoutException in project atlasdb by palantir.

the class MultiClientConjureTimelockResourceTest method requestHandlesExceptionAndThrowsIfAnyQueryFails.

@Test
public void requestHandlesExceptionAndThrowsIfAnyQueryFails() {
    String throwingClient = "alpha";
    Set<Namespace> namespaces = ImmutableSet.of(Namespace.of(throwingClient), Namespace.of("beta"));
    when(getServiceForClient(throwingClient).leaderTime()).thenThrow(new BlockingTimeoutException(""));
    assertThatThrownBy(() -> Futures.getUnchecked(resource.leaderTimes(AUTH_HEADER, namespaces))).hasCauseInstanceOf(Throttle.class);
}
Also used : BlockingTimeoutException(com.palantir.lock.remoting.BlockingTimeoutException) Namespace(com.palantir.atlasdb.timelock.api.Namespace) Test(org.junit.Test)

Example 3 with BlockingTimeoutException

use of com.palantir.lock.remoting.BlockingTimeoutException in project atlasdb by palantir.

the class ConjureTimelockResourceTest method jerseyPropagatesExceptions.

@Test
public void jerseyPropagatesExceptions() {
    when(resource.leaderTime(AUTH_HEADER, NAMESPACE)).thenThrow(new BlockingTimeoutException(""));
    assertQosExceptionThrownBy(Futures.submitAsync(() -> Futures.immediateFuture(service.leaderTime(AUTH_HEADER, NAMESPACE)), MoreExecutors.directExecutor()), new AssertVisitor() {

        @Override
        public Void visit(QosException.Throttle exception) {
            assertThat(exception.getRetryAfter()).contains(Duration.ZERO);
            return null;
        }
    });
}
Also used : QosException(com.palantir.conjure.java.api.errors.QosException) BlockingTimeoutException(com.palantir.lock.remoting.BlockingTimeoutException) Test(org.junit.Test)

Aggregations

BlockingTimeoutException (com.palantir.lock.remoting.BlockingTimeoutException)3 Test (org.junit.Test)3 QosException (com.palantir.conjure.java.api.errors.QosException)2 Namespace (com.palantir.atlasdb.timelock.api.Namespace)1