use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.
the class LocalCapabilitiesDirectoryImpl method lookup.
@Override
public Promise<Lookup1Deferred> lookup(String[] domains, String interfaceName, joynr.types.DiscoveryQos discoveryQos) {
final Lookup1Deferred deferred = new Lookup1Deferred();
CapabilitiesCallback callback = new CapabilitiesCallback() {
@Override
public void processCapabilitiesReceived(@CheckForNull Collection<DiscoveryEntryWithMetaInfo> capabilities) {
if (capabilities == null) {
deferred.reject(new ProviderRuntimeException("Received capablities collection was null"));
} else {
deferred.resolve(capabilities.toArray(new DiscoveryEntryWithMetaInfo[capabilities.size()]));
}
}
@Override
public void onError(Throwable e) {
deferred.reject(new ProviderRuntimeException(e.toString()));
}
};
DiscoveryScope discoveryScope = DiscoveryScope.valueOf(discoveryQos.getDiscoveryScope().name());
lookup(domains, interfaceName, new DiscoveryQos(discoveryQos.getDiscoveryTimeout(), defaultDiscoveryRetryInterval, ArbitrationStrategy.NotSet, discoveryQos.getCacheMaxAge(), discoveryScope), callback);
return new Promise<>(deferred);
}
use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.
the class LocalCapabilitiesDirectoryImpl method registerGlobal.
private void registerGlobal(final DiscoveryEntry discoveryEntry, final DeferredVoid deferred) {
synchronized (globalAddressLock) {
try {
globalAddress = globalAddressProvider.get();
} catch (Exception e) {
logger.debug("error getting global address", e);
globalAddress = null;
}
if (globalAddress == null) {
queuedDiscoveryEntries.add(new QueuedDiscoveryEntry(discoveryEntry, deferred));
globalAddressProvider.registerGlobalAddressesReadyListener(this);
return;
}
}
final GlobalDiscoveryEntry globalDiscoveryEntry = CapabilityUtils.discoveryEntry2GlobalDiscoveryEntry(discoveryEntry, globalAddress);
if (globalDiscoveryEntry != null) {
logger.info("starting global registration for " + globalDiscoveryEntry.getDomain() + " : " + globalDiscoveryEntry.getInterfaceName());
globalCapabilitiesDirectoryClient.add(new Callback<Void>() {
@Override
public void onSuccess(Void nothing) {
logger.info("global registration for " + globalDiscoveryEntry.getDomain() + " : " + globalDiscoveryEntry.getInterfaceName() + " completed");
deferred.resolve();
globalDiscoveryEntryCache.add(CapabilityUtils.discoveryEntry2GlobalDiscoveryEntry(discoveryEntry, globalAddress));
}
@Override
public void onFailure(JoynrRuntimeException exception) {
deferred.reject(new ProviderRuntimeException(exception.toString()));
}
}, globalDiscoveryEntry);
}
}
Aggregations