Search in sources :

Example 31 with ProviderQos

use of joynr.types.ProviderQos in project joynr by bmwcarit.

the class IltProviderApplication method run.

@Override
public void run() {
    provider = new IltProvider();
    provider.addBroadcastFilter(new IltStringBroadcastFilter(jsonSerializer));
    ProviderQos providerQos = new ProviderQos();
    providerQos.setPriority(System.currentTimeMillis());
    runtime.registerProvider(localDomain, provider, providerQos);
    while (!shutDownRequested) {
        try {
            Thread.sleep(1000);
        } catch (Exception e) {
        // no handling
        }
    }
}
Also used : ProviderQos(joynr.types.ProviderQos) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException)

Example 32 with ProviderQos

use of joynr.types.ProviderQos in project joynr by bmwcarit.

the class EchoProviderApplication method run.

@Override
public void run() {
    provider = new EchoProviderImpl();
    ProviderQos providerQos = new ProviderQos();
    // Ensure that the most recent provider has got the highest priority
    providerQos.setPriority(System.currentTimeMillis());
    providerQos.setScope(invocationParams.getProviderScope());
    runtime.registerProvider(localDomain, provider, providerQos);
    // In this case the application appears to crash.
    try {
        // 24h
        Thread.sleep(24 * 60 * 60 * 1000);
    } catch (InterruptedException e) {
    // Can be ignored in this context
    }
}
Also used : ProviderQos(joynr.types.ProviderQos)

Example 33 with ProviderQos

use of joynr.types.ProviderQos 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 34 with ProviderQos

use of joynr.types.ProviderQos in project joynr by bmwcarit.

the class LocalDiscoveryTest method testRemoteGlobalDiscoveryEntries.

@SuppressWarnings("unchecked")
@Test
public void testRemoteGlobalDiscoveryEntries() {
    String testDomain = "testDomain";
    String interfaceName = testProxy.INTERFACE_NAME;
    final Collection<DiscoveryEntry> discoveryEntries = new HashSet<>();
    final List<GlobalDiscoveryEntry> globalDiscoveryEntries = new ArrayList<>();
    DiscoveryEntry discoveryEntry = new DiscoveryEntry(VersionUtil.getVersionFromAnnotation(testProxy.class), testDomain, interfaceName, "participantId", new ProviderQos(), System.currentTimeMillis(), System.currentTimeMillis() + 100000, "publicKeyId");
    discoveryEntries.add(discoveryEntry);
    globalDiscoveryEntries.add(CapabilityUtils.discoveryEntry2GlobalDiscoveryEntry(discoveryEntry, new MqttAddress()));
    when(globalDiscoveryEntryCacheMock.lookup(any(String[].class), eq(interfaceName), anyLong())).thenReturn(new HashSet<DiscoveryEntry>());
    Mockito.doAnswer(new Answer<Object>() {

        @SuppressWarnings("rawtypes")
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            Object[] arguments = invocation.getArguments();
            assert (arguments[0] instanceof Callback);
            ((Callback) arguments[0]).resolve((Object) globalDiscoveryEntries);
            return null;
        }
    }).when(globalCapabilitiesDirectoryClientMock).lookup(any(Callback.class), any(String[].class), eq(interfaceName), anyLong());
    ProxyBuilder<testProxy> proxyBuilder = runtime.getProxyBuilder(testDomain, testProxy.class);
    final Future<Void> future = new Future<Void>();
    DiscoveryQos discoveryQos = new DiscoveryQos();
    discoveryQos.setDiscoveryScope(DiscoveryScope.GLOBAL_ONLY);
    proxyBuilder.setDiscoveryQos(discoveryQos).build(new ProxyCreatedCallback<testProxy>() {

        @Override
        public void onProxyCreationFinished(testProxy result) {
            future.onSuccess(null);
        }

        @Override
        public void onProxyCreationError(JoynrRuntimeException error) {
            future.onFailure(error);
        }
    });
    try {
        future.get(5000);
        verify(joynrMessagingConnectorFactoryMock).create(anyString(), discoveryEntryWithMetaInfoArgumentCaptor.capture(), any(MessagingQos.class));
        assertDiscoveryEntryEqualsCaptured(discoveryEntry);
    } catch (Exception e) {
        Assert.fail("Unexpected exception from ProxyCreatedCallback: " + e);
    }
}
Also used : GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) MessagingQos(io.joynr.messaging.MessagingQos) HashSet(java.util.HashSet) MqttAddress(joynr.system.RoutingTypes.MqttAddress) DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) joynr.tests.testProxy(joynr.tests.testProxy) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Callback(io.joynr.proxy.Callback) ProxyCreatedCallback(io.joynr.proxy.ProxyBuilder.ProxyCreatedCallback) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Future(io.joynr.proxy.Future) ProviderQos(joynr.types.ProviderQos) Test(org.junit.Test)

Example 35 with ProviderQos

use of joynr.types.ProviderQos in project joynr by bmwcarit.

the class LocalDiscoveryTest method testLocalDiscoveryEntries.

@Test
public void testLocalDiscoveryEntries() {
    String testDomain = "testDomain";
    String interfaceName = testProxy.INTERFACE_NAME;
    Collection<DiscoveryEntry> discoveryEntries = new HashSet<>();
    DiscoveryEntry discoveryEntry = new DiscoveryEntry(VersionUtil.getVersionFromAnnotation(testProxy.class), testDomain, interfaceName, "participantId", new ProviderQos(), System.currentTimeMillis(), System.currentTimeMillis() + 100000, "publicKeyId");
    discoveryEntries.add(discoveryEntry);
    when(localDiscoveryEntryStoreMock.lookup(any(String[].class), eq(interfaceName))).thenReturn(discoveryEntries);
    ProxyBuilder<testProxy> proxyBuilder = runtime.getProxyBuilder(testDomain, testProxy.class);
    final Future<Void> future = new Future<Void>();
    DiscoveryQos discoveryQos = new DiscoveryQos();
    discoveryQos.setDiscoveryScope(DiscoveryScope.LOCAL_ONLY);
    proxyBuilder.setDiscoveryQos(discoveryQos).build(new ProxyCreatedCallback<testProxy>() {

        @Override
        public void onProxyCreationFinished(testProxy result) {
            future.onSuccess(null);
        }

        @Override
        public void onProxyCreationError(JoynrRuntimeException error) {
            future.onFailure(error);
        }
    });
    try {
        future.get(5000);
        verify(joynrMessagingConnectorFactoryMock).create(anyString(), discoveryEntryWithMetaInfoArgumentCaptor.capture(), any(MessagingQos.class));
        assertDiscoveryEntryEqualsCaptured(discoveryEntry);
    } catch (Exception e) {
        Assert.fail("Unexpected exception from ProxyCreatedCallback: " + e);
    }
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) joynr.tests.testProxy(joynr.tests.testProxy) Matchers.anyString(org.mockito.Matchers.anyString) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) MessagingQos(io.joynr.messaging.MessagingQos) Future(io.joynr.proxy.Future) ProviderQos(joynr.types.ProviderQos) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ProviderQos (joynr.types.ProviderQos)69 Version (joynr.types.Version)43 Test (org.junit.Test)37 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)27 DiscoveryEntry (joynr.types.DiscoveryEntry)25 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)24 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)21 Matchers.anyString (org.mockito.Matchers.anyString)16 ArrayList (java.util.ArrayList)15 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)13 Before (org.junit.Before)13 Callback (io.joynr.proxy.Callback)12 HashSet (java.util.HashSet)11 MqttAddress (joynr.system.RoutingTypes.MqttAddress)10 InvocationOnMock (org.mockito.invocation.InvocationOnMock)10 Address (joynr.system.RoutingTypes.Address)9 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)8 MessagingQos (io.joynr.messaging.MessagingQos)8 Properties (java.util.Properties)8 DiscoveryException (io.joynr.exceptions.DiscoveryException)7