Search in sources :

Example 21 with DiscoveryQos

use of io.joynr.arbitration.DiscoveryQos in project joynr by bmwcarit.

the class ConsumerApplication method run.

@SuppressWarnings("checkstyle:methodlength")
@Override
public void run() {
    DiscoveryQos discoveryQos = new DiscoveryQos();
    discoveryQos.setDiscoveryTimeoutMs(10000);
    discoveryQos.setCacheMaxAgeMs(Long.MAX_VALUE);
    discoveryQos.setArbitrationStrategy(ArbitrationStrategy.HighestPriority);
    ProxyBuilder<SystemIntegrationTestProxy> proxyBuilder = runtime.getProxyBuilder(providerDomain, SystemIntegrationTestProxy.class);
    boolean success = false;
    try {
        systemIntegrationTestProxy = proxyBuilder.setMessagingQos(new MessagingQos(10000)).setDiscoveryQos(discoveryQos).build(new ProxyCreatedCallback<SystemIntegrationTestProxy>() {

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

            @Override
            public void onProxyCreationError(JoynrRuntimeException error) {
                LOG.error("error creating proxy");
            }
        });
        try {
            if (proxyCreated.tryAcquire(11000, TimeUnit.MILLISECONDS) == false) {
                throw new DiscoveryException("proxy not created in time");
            }
        } catch (InterruptedException e) {
            throw new DiscoveryException("proxy not created in time");
        }
        try {
            int addendA = 3333333;
            int addendB = 4444444;
            Integer sum = systemIntegrationTestProxy.add(addendA, addendB);
            if (sum != null && sum == (addendA + addendB)) {
                LOG.info("SIT RESULT success: Java consumer -> " + providerDomain + " (" + addendA + " + " + addendB + " =  " + sum + ")");
                success = true;
            }
        } catch (Exception e) {
        // fallthrough
        }
    } catch (DiscoveryException | JoynrCommunicationException e) {
    // fallthrough
    }
    if (!success) {
        LOG.info("SIT RESULT error: Java consumer -> " + providerDomain);
    }
    System.exit((success) ? 0 : 1);
}
Also used : SystemIntegrationTestProxy(joynr.test.SystemIntegrationTestProxy) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) JoynrCommunicationException(io.joynr.exceptions.JoynrCommunicationException) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) DiscoveryException(io.joynr.exceptions.DiscoveryException) IOException(java.io.IOException) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) JoynrCommunicationException(io.joynr.exceptions.JoynrCommunicationException) MessagingQos(io.joynr.messaging.MessagingQos) ProxyCreatedCallback(io.joynr.proxy.ProxyBuilder.ProxyCreatedCallback) DiscoveryException(io.joynr.exceptions.DiscoveryException) SuppressWarnings(edu.umd.cs.findbugs.annotations.SuppressWarnings)

Example 22 with DiscoveryQos

use of io.joynr.arbitration.DiscoveryQos 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 23 with DiscoveryQos

use of io.joynr.arbitration.DiscoveryQos 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 24 with DiscoveryQos

use of io.joynr.arbitration.DiscoveryQos in project joynr by bmwcarit.

the class ShortCircuitTest method setup.

@Before
public void setup() throws Exception {
    Module runtimeModule = Modules.override(new CCInProcessRuntimeModule()).with(new TestGlobalAddressModule());
    Properties joynrConfig = new Properties();
    DummyJoynrApplication application = (DummyJoynrApplication) new JoynrInjectorFactory(joynrConfig, runtimeModule).createApplication(DummyJoynrApplication.class);
    runtime = application.getRuntime();
    DiscoveryQos discoveryQos = new DiscoveryQos(CONST_DEFAULT_TEST_TIMEOUT, ArbitrationStrategy.HighestPriority, DiscoveryQos.NO_MAX_AGE, DiscoveryScope.LOCAL_ONLY);
    ProxyBuilder<EchoProxy> proxyBuilder = runtime.getProxyBuilder(DOMAIN, EchoProxy.class).setDiscoveryQos(discoveryQos);
    echoProxy = proxyBuilder.build();
    EchoProvider echoProvider = new EchoProviderImpl();
    ProviderQos providerQos = new ProviderQos();
    providerQos.setPriority(System.currentTimeMillis());
    providerQos.setScope(ProviderScope.LOCAL);
    runtime.registerProvider(DOMAIN, echoProvider, providerQos);
    // warmup
    for (int i = 0; i < 100; i++) {
        echoProxy.echoString("warmup");
        echoProxy.echoByteArray(new Byte[1]);
    }
}
Also used : TestGlobalAddressModule(io.joynr.messaging.routing.TestGlobalAddressModule) DummyJoynrApplication(io.joynr.integration.util.DummyJoynrApplication) EchoProvider(joynr.tests.performance.EchoProvider) Properties(java.util.Properties) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) JoynrInjectorFactory(io.joynr.runtime.JoynrInjectorFactory) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) Module(com.google.inject.Module) TestGlobalAddressModule(io.joynr.messaging.routing.TestGlobalAddressModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) AbstractModule(com.google.inject.AbstractModule) EchoProxy(joynr.tests.performance.EchoProxy) ProviderQos(joynr.types.ProviderQos) Before(org.junit.Before)

Example 25 with DiscoveryQos

use of io.joynr.arbitration.DiscoveryQos 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)

Aggregations

DiscoveryQos (io.joynr.arbitration.DiscoveryQos)46 MessagingQos (io.joynr.messaging.MessagingQos)23 Test (org.junit.Test)23 ProviderQos (joynr.types.ProviderQos)20 Matchers.anyString (org.mockito.Matchers.anyString)19 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)16 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)14 DiscoveryEntry (joynr.types.DiscoveryEntry)14 Callback (io.joynr.proxy.Callback)11 joynr.tests.testProxy (joynr.tests.testProxy)11 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)10 Properties (java.util.Properties)9 Version (joynr.types.Version)9 ArrayList (java.util.ArrayList)8 Before (org.junit.Before)8 InvocationOnMock (org.mockito.invocation.InvocationOnMock)6 Future (io.joynr.proxy.Future)5 ProxyCreatedCallback (io.joynr.proxy.ProxyBuilder.ProxyCreatedCallback)5 HashSet (java.util.HashSet)5 IOException (java.io.IOException)4