Search in sources :

Example 66 with ProviderRuntimeException

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);
}
Also used : Promise(io.joynr.provider.Promise) DiscoveryScope(io.joynr.arbitration.DiscoveryScope) CheckForNull(javax.annotation.CheckForNull) Collection(java.util.Collection) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) DiscoveryQos(io.joynr.arbitration.DiscoveryQos)

Example 67 with ProviderRuntimeException

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);
    }
}
Also used : GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) DeferredVoid(io.joynr.provider.DeferredVoid) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) DiscoveryException(io.joynr.exceptions.DiscoveryException) ApplicationException(joynr.exceptions.ApplicationException) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException)

Aggregations

ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)67 Promise (io.joynr.provider.Promise)27 ApplicationException (joynr.exceptions.ApplicationException)23 Test (org.junit.Test)21 MapStringString (joynr.interlanguagetest.namedTypeCollection2.MapStringString)19 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)13 DiscoveryException (io.joynr.exceptions.DiscoveryException)10 DeferredVoid (io.joynr.provider.DeferredVoid)10 JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)8 JoynrTimeoutException (io.joynr.exceptions.JoynrTimeoutException)8 JoynrWaitExpiredException (io.joynr.exceptions.JoynrWaitExpiredException)8 joynr.tests.testProxy (joynr.tests.testProxy)8 ExtendedExtendedBaseStruct (joynr.interlanguagetest.namedTypeCollection2.ExtendedExtendedBaseStruct)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 JoynrException (io.joynr.exceptions.JoynrException)4 ExtendedBaseStruct (joynr.interlanguagetest.namedTypeCollection2.ExtendedBaseStruct)4 JoynrVersion (io.joynr.JoynrVersion)3 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)3 Deferred (io.joynr.provider.Deferred)3 PromiseListener (io.joynr.provider.PromiseListener)3