Search in sources :

Example 1 with JoynrTimeoutException

use of io.joynr.exceptions.JoynrTimeoutException in project joynr by bmwcarit.

the class ReplyCallerDirectory method removeExpiredReplyCaller.

private void removeExpiredReplyCaller(String requestReplyId) {
    ReplyCaller outstandingReplyCaller = remove(requestReplyId);
    if (outstandingReplyCaller == null) {
        // this happens, when a reply was already received and the replyCaller has been removed.
        return;
    }
    logger.debug("Replycaller with requestReplyId {} was removed because TTL expired", requestReplyId);
    // notify the caller that the request has expired now
    outstandingReplyCaller.error(new JoynrTimeoutException(System.currentTimeMillis()));
}
Also used : JoynrTimeoutException(io.joynr.exceptions.JoynrTimeoutException)

Example 2 with JoynrTimeoutException

use of io.joynr.exceptions.JoynrTimeoutException in project joynr by bmwcarit.

the class AbstractProviderProxyEnd2EndTest method asyncMethodCallWithTtlExpiring.

@Ignore
@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void asyncMethodCallWithTtlExpiring() throws DiscoveryException, JoynrIllegalStateException, InterruptedException, ApplicationException {
    ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
    long ttl = 2000L;
    MessagingQos testMessagingQos = new MessagingQos(ttl);
    DiscoveryQos testDiscoveryQos = new DiscoveryQos(30000, ArbitrationStrategy.HighestPriority, Long.MAX_VALUE);
    testProxy proxyShortTll = proxyBuilder.setMessagingQos(testMessagingQos).setDiscoveryQos(testDiscoveryQos).build();
    // the provider waits ttl before responding, causing a ttl
    boolean timeoutExceptionThrown = false;
    // the ttl parameter tells the provider to wait this long before
    // replying, thereby forcing a ttl exception
    Future<String> waitTooLongFuture = proxyShortTll.waitTooLong(callback, ttl * 2);
    try {
        // should never have to wait
        waitTooLongFuture.get(10 * ttl);
    // this long
    // the JoynWaitExpiredException should not be thrown.
    } catch (JoynrWaitExpiredException e) {
        timeoutExceptionThrown = false;
    } catch (JoynrTimeoutException e) {
        timeoutExceptionThrown = true;
    }
    assertEquals(true, timeoutExceptionThrown);
    assertEquals(RequestStatusCode.ERROR, waitTooLongFuture.getStatus().getCode());
    verify(callback).onFailure(any(JoynrRuntimeException.class));
    verifyNoMoreInteractions(callback);
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) JoynrTimeoutException(io.joynr.exceptions.JoynrTimeoutException) joynr.tests.testProxy(joynr.tests.testProxy) JoynrWaitExpiredException(io.joynr.exceptions.JoynrWaitExpiredException) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with JoynrTimeoutException

use of io.joynr.exceptions.JoynrTimeoutException in project joynr by bmwcarit.

the class SerializationTest method serializeReplyWithJoynrTimeoutException.

@Test
public void serializeReplyWithJoynrTimeoutException() throws IOException {
    JoynrTimeoutException error = new JoynrTimeoutException(42);
    Reply reply = new Reply(UUID.randomUUID().toString(), error);
    String writeValueAsString = objectMapper.writeValueAsString(reply);
    System.out.println(writeValueAsString);
    Reply receivedReply = objectMapper.readValue(writeValueAsString, Reply.class);
    Assert.assertEquals(reply, receivedReply);
}
Also used : JoynrTimeoutException(io.joynr.exceptions.JoynrTimeoutException) Reply(joynr.Reply) Test(org.junit.Test)

Aggregations

JoynrTimeoutException (io.joynr.exceptions.JoynrTimeoutException)3 Test (org.junit.Test)2 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)1 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)1 JoynrWaitExpiredException (io.joynr.exceptions.JoynrWaitExpiredException)1 MessagingQos (io.joynr.messaging.MessagingQos)1 Reply (joynr.Reply)1 joynr.tests.testProxy (joynr.tests.testProxy)1 Ignore (org.junit.Ignore)1