Search in sources :

Example 1 with Mesos4xxException

use of com.hubspot.mesos.rx.java.Mesos4xxException in project Singularity by HubSpot.

the class SingularityMesosSchedulerClientTest method itCheckAndReconnectThrowsException.

@Test
public void itCheckAndReconnectThrowsException() {
    Mesos4xxException exception = new Mesos4xxException(new Object(), new MesosClientErrorContext(403, "Framework not subscribed", new ArrayList<>()));
    doAnswer((InvocationOnMock invocation) -> {
        ((Runnable) invocation.getArguments()[0]).run();
        return null;
    }).when(executorService).execute(any(Runnable.class));
    client.checkAndReconnect(exception).join();
    verify(scheduler, times(1)).onUncaughtException(any());
}
Also used : MesosClientErrorContext(com.hubspot.mesos.rx.java.MesosClientErrorContext) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ArrayList(java.util.ArrayList) Mesos4xxException(com.hubspot.mesos.rx.java.Mesos4xxException) Test(org.junit.jupiter.api.Test)

Example 2 with Mesos4xxException

use of com.hubspot.mesos.rx.java.Mesos4xxException in project Singularity by HubSpot.

the class SingularityMesosSchedulerClient method checkAndReconnect.

public CompletableFuture<Void> checkAndReconnect(Throwable t) {
    LOG.error("Exception calling mesos ({} so far)", failedMesosCalls.incrementAndGet(), t);
    String message = t.getMessage();
    if (t instanceof Mesos4xxException && message.contains("403")) {
        return CompletableFuture.runAsync(() -> scheduler.onUncaughtException(new PrematureChannelClosureException()), executorService);
    }
    return CompletableFuture.completedFuture(null);
}
Also used : Mesos4xxException(com.hubspot.mesos.rx.java.Mesos4xxException) ByteString(com.google.protobuf.ByteString) PrematureChannelClosureException(io.netty.handler.codec.PrematureChannelClosureException)

Aggregations

Mesos4xxException (com.hubspot.mesos.rx.java.Mesos4xxException)2 ByteString (com.google.protobuf.ByteString)1 MesosClientErrorContext (com.hubspot.mesos.rx.java.MesosClientErrorContext)1 PrematureChannelClosureException (io.netty.handler.codec.PrematureChannelClosureException)1 ArrayList (java.util.ArrayList)1 Test (org.junit.jupiter.api.Test)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1