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);
}
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;
}
}
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++;
}
}
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]);
}
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);
}
Aggregations