Search in sources :

Example 31 with GlobalDiscoveryEntry

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

the class CapabilitiesUtilsTest method testConvertGlobalDiscoveryEntryToDiscoveryEntryWithMetaInfo.

@Test
public void testConvertGlobalDiscoveryEntryToDiscoveryEntryWithMetaInfo() {
    boolean isLocal = false;
    DiscoveryEntry discoveryEntry = new DiscoveryEntry(new Version(42, 23), "testDomain", "testInterfaceName", "testParticipantId", new ProviderQos(), 4711l, 4712l, "testPublicKeyId");
    GlobalDiscoveryEntry globalDiscoveryEntry = CapabilityUtils.discoveryEntry2GlobalDiscoveryEntry(discoveryEntry, new MqttAddress());
    DiscoveryEntryWithMetaInfo convertedEntry = CapabilityUtils.convertToDiscoveryEntryWithMetaInfo(isLocal, discoveryEntry);
    compareDiscoveryEntries(isLocal, discoveryEntry, convertedEntry);
    DiscoveryEntryWithMetaInfo convertedGlobalEntry = CapabilityUtils.convertToDiscoveryEntryWithMetaInfo(isLocal, globalDiscoveryEntry);
    compareDiscoveryEntries(isLocal, globalDiscoveryEntry, convertedGlobalEntry);
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) Version(joynr.types.Version) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) ProviderQos(joynr.types.ProviderQos) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Test(org.junit.Test)

Example 32 with GlobalDiscoveryEntry

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

the class DiscoveryEntryStoreInMemory method lookup.

@Override
@CheckForNull
public DiscoveryEntry lookup(String participantId, long cacheMaxAge) {
    synchronized (storeLock) {
        String discoveryEntryId = participantIdToCapabilityMapping.get(participantId);
        if (discoveryEntryId == null) {
            return null;
        }
        DiscoveryEntry discoveryEntry = capabilityKeyToCapabilityMapping.get(discoveryEntryId);
        logger.debug("Capability for participantId {} found: {}", participantId, discoveryEntry);
        if (discoveryEntry instanceof GlobalDiscoveryEntry && !checkAge(registeredCapabilitiesTime.get(discoveryEntryId), cacheMaxAge)) {
            return null;
        }
        return discoveryEntry;
    }
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) CheckForNull(javax.annotation.CheckForNull)

Example 33 with GlobalDiscoveryEntry

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

the class CapabilitiesDirectoryTest method assertDiscoveryEntriesEqual.

private void assertDiscoveryEntriesEqual(GlobalDiscoveryEntry[] expectedDiscoveryEntries, GlobalDiscoveryEntry[] passedDiscoveryEntries) {
    int i = 0;
    for (GlobalDiscoveryEntry expectedGlobalDiscoveryEntry : expectedDiscoveryEntries) {
        GlobalDiscoveryEntry passedDiscoveryEntry = passedDiscoveryEntries[i];
        assertEquals(expectedGlobalDiscoveryEntry.getDomain(), passedDiscoveryEntry.getDomain());
        assertEquals(expectedGlobalDiscoveryEntry.getInterfaceName(), passedDiscoveryEntry.getInterfaceName());
        assertEquals(expectedGlobalDiscoveryEntry.getAddress(), passedDiscoveryEntry.getAddress());
        assertEquals(expectedGlobalDiscoveryEntry.getParticipantId(), passedDiscoveryEntry.getParticipantId());
        assertEquals(expectedGlobalDiscoveryEntry.getQos(), passedDiscoveryEntry.getQos());
        i++;
    }
}
Also used : GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry)

Example 34 with GlobalDiscoveryEntry

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

the class CapabilitiesDirectoryTest method registerProviderAndRequestChannels.

@Test
public void registerProviderAndRequestChannels() throws Exception {
    capabilitiesDirectory.add(disoveryEntry1);
    PromiseKeeper lookupCapInfo1 = new PromiseKeeper();
    capabilitiesDirectory.lookup(new String[] { domain }, interface1).then(lookupCapInfo1);
    lookupCapInfo1.waitForSettlement();
    assertDiscoveryEntriesEqual(new GlobalDiscoveryEntry[] { disoveryEntry1 }, (GlobalDiscoveryEntry[]) lookupCapInfo1.getValues()[0]);
}
Also used : GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) PromiseKeeper(io.joynr.provider.PromiseKeeper) Test(org.junit.Test)

Example 35 with GlobalDiscoveryEntry

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

the class CapabilitiesDirectoryImpl method lookup.

@Override
public Promise<Lookup1Deferred> lookup(final String[] domains, final String interfaceName) {
    Lookup1Deferred deferred = new Lookup1Deferred();
    logger.debug("Searching channels for domains: {} interfaceName: {}", domains, interfaceName);
    Collection<DiscoveryEntry> discoveryEntries = discoveryEntryStore.lookup(domains, interfaceName);
    GlobalDiscoveryEntry[] globalDiscoveryEntries = new GlobalDiscoveryEntry[discoveryEntries.size()];
    int index = 0;
    for (DiscoveryEntry discoveryEntry : discoveryEntries) {
        // entries from persisted store are of type GlobalDiscoveryEntryPersisted.
        // Copy required or else _typeName will be incorrect
        globalDiscoveryEntries[index] = new GlobalDiscoveryEntry((GlobalDiscoveryEntry) discoveryEntry);
        index++;
    }
    deferred.resolve(globalDiscoveryEntries);
    return new Promise<Lookup1Deferred>(deferred);
}
Also used : Promise(io.joynr.provider.Promise) DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry)

Aggregations

GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)45 Test (org.junit.Test)28 DiscoveryEntry (joynr.types.DiscoveryEntry)21 ProviderQos (joynr.types.ProviderQos)20 Version (joynr.types.Version)19 Callback (io.joynr.proxy.Callback)15 Matchers.anyString (org.mockito.Matchers.anyString)14 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)12 ArrayList (java.util.ArrayList)12 MqttAddress (joynr.system.RoutingTypes.MqttAddress)9 DeferredVoid (io.joynr.provider.DeferredVoid)8 Address (joynr.system.RoutingTypes.Address)6 InvocationOnMock (org.mockito.invocation.InvocationOnMock)6 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)5 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)5 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)5 List (java.util.List)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 MessagingQos (io.joynr.messaging.MessagingQos)3 Promise (io.joynr.provider.Promise)3