Search in sources :

Example 36 with MessagingQos

use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.

the class IltConsumerTest method setupConsumerRuntime.

protected static void setupConsumerRuntime(boolean msgQosCompressed) throws DiscoveryException, JoynrIllegalStateException, InterruptedException {
    LOG.info("setupConsumerRuntime: Entering");
    final String configFileName = "ilt-consumer-test.settings";
    InputStream resourceStream;
    try {
        resourceStream = new FileInputStream("src/main/resources/" + configFileName);
    } catch (IOException e) {
        LOG.error("setupConsumerRuntime: Error", e);
        resourceStream = null;
    }
    Properties joynrConfig = new Properties();
    try {
        if (resourceStream != null) {
            LOG.info("setupConsumerRuntime: resources from " + configFileName);
            joynrConfig.load(resourceStream);
        }
    } catch (IOException ex) {
        LOG.info("setupConsumerRuntime: not load the configuration file: " + configFileName + ": " + ex);
    }
    joynrConfig.setProperty(MessagingPropertyKeys.PERSISTENCE_FILE, STATIC_PERSISTENCE_FILE);
    joynrConfig.setProperty(AbstractJoynrApplication.PROPERTY_JOYNR_DOMAIN_LOCAL, "inter_language_test_consumer_local_domain");
    consumerRuntime = getRuntime(joynrConfig);
    DiscoveryQos discoveryQos = new DiscoveryQos();
    discoveryQos.setDiscoveryTimeoutMs(10000);
    discoveryQos.setCacheMaxAgeMs(Long.MAX_VALUE);
    discoveryQos.setArbitrationStrategy(ArbitrationStrategy.HighestPriority);
    ProxyBuilder<TestInterfaceProxy> proxyBuilder = consumerRuntime.getProxyBuilder(providerDomain, TestInterfaceProxy.class);
    MessagingQos messagingQos = new MessagingQos(10000);
    messagingQos.setCompress(msgQosCompressed);
    LOG.info("setupConsumerRuntime: msgQosCompression = " + msgQosCompressed);
    testInterfaceProxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build(new ProxyCreatedCallback<TestInterfaceProxy>() {

        @Override
        public void onProxyCreationFinished(TestInterfaceProxy result) {
            LOG.info("proxy created");
            proxyCreated.release();
        }

        @Override
        public void onProxyCreationError(JoynrRuntimeException error) {
            LOG.info("error creating proxy");
        }
    });
    if (testInterfaceProxy == null) {
        LOG.info("setupConsumerRuntime: proxy = null");
    } else {
        LOG.info("setupConsumerRuntime: proxy is set != null");
    }
    // wait until proxy creation is finished or discovery timeout +
    // 1 second grace period have passed
    proxyCreated.tryAcquire(11000, TimeUnit.MILLISECONDS);
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) TestInterfaceProxy(joynr.interlanguagetest.TestInterfaceProxy) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) Properties(java.util.Properties) ProxyCreatedCallback(io.joynr.proxy.ProxyBuilder.ProxyCreatedCallback) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) FileInputStream(java.io.FileInputStream) DiscoveryQos(io.joynr.arbitration.DiscoveryQos)

Example 37 with MessagingQos

use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.

the class ConsumerApplication method createEchoProxy.

private EchoProxy createEchoProxy() {
    DiscoveryQos discoveryQos = new DiscoveryQos();
    discoveryQos.setDiscoveryTimeoutMs(100000);
    discoveryQos.setCacheMaxAgeMs(Long.MAX_VALUE);
    discoveryQos.setArbitrationStrategy(ArbitrationStrategy.HighestPriority);
    discoveryQos.setDiscoveryScope(invocationParameters.getDiscoveryScope());
    ProxyBuilder<EchoProxy> proxyBuilder = runtime.getProxyBuilder(invocationParameters.getDomainName(), EchoProxy.class);
    return // 1 hour
    proxyBuilder.setMessagingQos(new MessagingQos(3600000)).setDiscoveryQos(discoveryQos).build();
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) EchoProxy(joynr.tests.performance.EchoProxy) DiscoveryQos(io.joynr.arbitration.DiscoveryQos)

Example 38 with MessagingQos

use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.

the class ConsumerRestEndpoint method callProducer.

private void callProducer(String domain, StringBuffer result) {
    try {
        DiscoveryQos discoveryQos = new DiscoveryQos();
        // 2 Minutes
        discoveryQos.setDiscoveryTimeoutMs(120000);
        SystemIntegrationTestSync proxy = serviceLocator.get(SystemIntegrationTestSync.class, domain, new MessagingQos(), discoveryQos);
        Integer additionResult = proxy.add(1, 1);
        if (additionResult != 2) {
            throw new IllegalArgumentException("1 + 1 should be 2, got: " + additionResult);
        }
        result.append("SIT RESULT success: JEE consumer -> ").append(domain);
    } catch (Exception e) {
        result.append("SIT RESULT error: JEE consumer -> ").append(domain).append("\nException: ").append(e.toString());
        addStacktrace(e, result);
    }
    result.append("\n");
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) IOException(java.io.IOException) SystemIntegrationTestSync(joynr.test.SystemIntegrationTestSync)

Example 39 with MessagingQos

use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.

the class JeeJoynrServiceLocatorTest method testGetWithTtl.

@Test
public void testGetWithTtl() {
    MyServiceSync result = subject.get(MyServiceSync.class, "local", 10000L);
    assertNotNull(result);
    String callResult = result.callMe("one");
    assertNotNull(callResult);
    assertEquals("two", callResult);
    verify(myJoynrProxy).callMe("one");
    ArgumentCaptor<MessagingQos> messagingQosCaptor = ArgumentCaptor.forClass(MessagingQos.class);
    verify(proxyBuilder).setMessagingQos(messagingQosCaptor.capture());
    MessagingQos messagingQosParam = messagingQosCaptor.getValue();
    assertEquals(10000L, messagingQosParam.getRoundTripTtl_ms());
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) Matchers.anyString(org.mockito.Matchers.anyString) MyServiceSync(joynr.jeeintegration.servicelocator.MyServiceSync) Test(org.junit.Test)

Example 40 with MessagingQos

use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.

the class JeeJoynrServiceLocatorTest method testGetWithMessagingAndDiscoveryQos.

@Test
public void testGetWithMessagingAndDiscoveryQos() {
    MessagingQos messagingQos = new MessagingQos();
    DiscoveryQos discoveryQos = new DiscoveryQos();
    MyServiceSync result = subject.get(MyServiceSync.class, "local", messagingQos, discoveryQos);
    assertNotNull(result);
    String callResult = result.callMe("one");
    assertNotNull(callResult);
    assertEquals("two", callResult);
    verify(myJoynrProxy).callMe("one");
    verify(proxyBuilder).setMessagingQos(messagingQos);
    verify(proxyBuilder).setDiscoveryQos(discoveryQos);
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) Matchers.anyString(org.mockito.Matchers.anyString) MyServiceSync(joynr.jeeintegration.servicelocator.MyServiceSync) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) Test(org.junit.Test)

Aggregations

MessagingQos (io.joynr.messaging.MessagingQos)55 Test (org.junit.Test)23 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)19 MutableMessage (joynr.MutableMessage)15 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)11 Matchers.anyString (org.mockito.Matchers.anyString)11 OnChangeSubscriptionQos (joynr.OnChangeSubscriptionQos)9 SubscriptionRequest (joynr.SubscriptionRequest)9 Before (org.junit.Before)8 Properties (java.util.Properties)6 ImmutableMessage (joynr.ImmutableMessage)6 Request (joynr.Request)6 Injector (com.google.inject.Injector)5 BroadcastSubscriptionRequest (joynr.BroadcastSubscriptionRequest)5 MulticastSubscriptionRequest (joynr.MulticastSubscriptionRequest)5 joynr.tests.testProxy (joynr.tests.testProxy)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 AbstractModule (com.google.inject.AbstractModule)4 IOException (java.io.IOException)4 OneWayRequest (joynr.OneWayRequest)4