Search in sources :

Example 61 with ProviderQos

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

the class MyGpsProviderApplication method run.

@Override
public void run() {
    ProviderQos providerQos = new ProviderQos();
    provider = new MyGpsProvider();
    providerQos.setPriority(System.currentTimeMillis());
    runtime.registerProvider(localDomain, provider, providerQos);
    ConsoleReader console;
    try {
        console = new ConsoleReader();
        int key;
        while ((key = console.readCharacter()) != 'q') {
            switch(key) {
                case 'l':
                    provider.notifyLocationUpdate();
                    break;
                default:
                    LOG.info("\n\nUSAGE press\n" + " q\tto quit\n" + " l\tto update location\n");
                    break;
            }
        }
    } catch (IOException e) {
        LOG.error("error reading input from console", e);
    }
}
Also used : ConsoleReader(jline.console.ConsoleReader) IOException(java.io.IOException) ProviderQos(joynr.types.ProviderQos)

Example 62 with ProviderQos

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

the class CapabilitiesDirectoryLauncher method run.

@Override
public void run() {
    // LongPollingMessagingModule is only added in main(), since the servletMessagingModule will be used otherwise
    ProviderQos providerQos = new ProviderQos();
    runtime.registerProvider(localDomain, capabilitiesDirectoryProvider, providerQos);
}
Also used : ProviderQos(joynr.types.ProviderQos)

Example 63 with ProviderQos

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

the class JoynrAndroidLocationProviderApplication method registerProvider.

public void registerProvider(final String domain) {
    if (androidLocationProvider == null) {
        logToOutput("Creating new location provider.");
        androidLocationProvider = new AndroidLocationProvider(this.getApplicationContext(), output);
    }
    if (runtime != null) {
        logToOutput("Registering provider on domain \"" + domain + "\".");
        // registers the provider at the global capabilities directory
        ProviderQos providerQos = new ProviderQos();
        providerQos.setPriority(System.currentTimeMillis());
        runtime.registerProvider(domain, androidLocationProvider, providerQos);
    } else {
        logToOutput("Failed to bind service. Can not register provider\n");
    }
}
Also used : ProviderQos(joynr.types.ProviderQos)

Example 64 with ProviderQos

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

the class LocalCapabilitiesDirectoryTest method addLocalOnlyCapability.

@SuppressWarnings("unchecked")
@Test(timeout = 2000)
public void addLocalOnlyCapability() throws InterruptedException {
    ProviderQos providerQos = new ProviderQos();
    providerQos.setScope(ProviderScope.LOCAL);
    globalDiscoveryEntry = new GlobalDiscoveryEntry(new Version(47, 11), "test", TestInterface.INTERFACE_NAME, "participantId", providerQos, System.currentTimeMillis(), expiryDateMs, publicKeyId, channelAddressSerialized);
    localCapabilitiesDirectory.add(discoveryEntry);
    Thread.sleep(1000);
    verify(globalCapabilitiesClient, never()).add(any(Callback.class), any(GlobalDiscoveryEntry.class));
}
Also used : Callback(io.joynr.proxy.Callback) Version(joynr.types.Version) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ProviderQos(joynr.types.ProviderQos) Test(org.junit.Test)

Example 65 with ProviderQos

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

the class LocalCapabilitiesDirectoryTest method addGlobalCapFails_NextAddShallAddGlobalAgain.

@SuppressWarnings("unchecked")
@Test(timeout = 1000)
public void addGlobalCapFails_NextAddShallAddGlobalAgain() throws InterruptedException {
    ProviderQos providerQos = new ProviderQos();
    providerQos.setScope(ProviderScope.GLOBAL);
    String participantId = LocalCapabilitiesDirectoryTest.class.getName() + ".addLocalAndThanGlobalShallWork";
    String domain = "testDomain";
    final DiscoveryEntry discoveryEntry = new DiscoveryEntry(new Version(47, 11), domain, TestInterface.INTERFACE_NAME, participantId, providerQos, System.currentTimeMillis(), expiryDateMs, publicKeyId);
    globalDiscoveryEntry = new GlobalDiscoveryEntry(new Version(47, 11), domain, TestInterface.INTERFACE_NAME, participantId, providerQos, System.currentTimeMillis(), expiryDateMs, publicKeyId, channelAddressSerialized);
    Mockito.doAnswer(createAddAnswerWithError()).when(globalCapabilitiesClient).add(any(Callback.class), eq(globalDiscoveryEntry));
    Promise<DeferredVoid> promise = localCapabilitiesDirectory.add(discoveryEntry);
    promise.then(new PromiseListener() {

        @Override
        public void onFulfillment(Object... values) {
            verify(globalDiscoveryEntryCacheMock, never()).add(eq(globalDiscoveryEntry));
            verify(globalCapabilitiesClient).add(any(Callback.class), eq(globalDiscoveryEntry));
            reset(globalCapabilitiesClient);
            localCapabilitiesDirectory.add(discoveryEntry);
            verify(globalCapabilitiesClient, timeout(200)).add(any(Callback.class), eq(globalDiscoveryEntry));
        }

        @Override
        public void onRejection(JoynrException error) {
        }
    });
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) PromiseListener(io.joynr.provider.PromiseListener) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) JoynrException(io.joynr.exceptions.JoynrException) Matchers.anyString(org.mockito.Matchers.anyString) DeferredVoid(io.joynr.provider.DeferredVoid) Callback(io.joynr.proxy.Callback) Version(joynr.types.Version) ProviderQos(joynr.types.ProviderQos) 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