Search in sources :

Example 71 with JoynrRuntimeException

use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.

the class BounceProxySystemPropertyLoader method loadProperties.

/**
 * Loads all properties for the bounce proxy that have to be set as system
 * properties (see
 * {@link BounceProxyPropertyKeys#bounceProxySystemPropertyKeys}) or in the
 * file {@value #CONTROLLED_BOUNCE_PROXY_SYSTEM_PROPERTIES}. System
 * properties have precedence over the file.
 *
 * @return
 *   all properties for the bounce proxy that have to be set as
 *   system properties
 * @throws JoynrRuntimeException
 *   if not all of the properties were set so that bounce proxy
 *   won't be able to start up correctly
 */
public static Properties loadProperties() {
    Properties properties = new Properties();
    for (String key : BounceProxyPropertyKeys.getPropertyKeysForSystemProperties()) {
        String value = System.getProperty(key);
        if (value == null) {
            value = loadPropertyFromFile(key);
            if (value == null) {
                throw new JoynrRuntimeException("No value for system property '" + key + "' set. Unable to start Bounce Proxy");
            }
        }
        properties.put(key, value);
    }
    return properties;
}
Also used : Properties(java.util.Properties) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException)

Example 72 with JoynrRuntimeException

use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.

the class StaticCapabilitiesProvisioning method addEntriesFromJson.

private void addEntriesFromJson(String provisionedCapabilitiesJsonFilename, ObjectMapper objectMapper, String localChannelId) {
    String provisionedCapabilitiesJsonString = resourceContentProvider.readFromFileOrResourceOrUrl(provisionedCapabilitiesJsonFilename);
    logger.trace("Statically provisioned capabilities JSON read: {}", provisionedCapabilitiesJsonString);
    List<GlobalDiscoveryEntry> newEntries = null;
    try {
        newEntries = objectMapper.readValue(provisionedCapabilitiesJsonString, new TypeReference<List<GlobalDiscoveryEntry>>() {
        });
        for (GlobalDiscoveryEntry globalDiscoveryEntry : newEntries) {
            globalDiscoveryEntry.setLastSeenDateMs(System.currentTimeMillis());
            Address address = CapabilityUtils.getAddressFromGlobalDiscoveryEntry(globalDiscoveryEntry);
            substituteInProcessAddressIfLocal(objectMapper, localChannelId, globalDiscoveryEntry, address);
            discoveryEntries.add(globalDiscoveryEntry);
        }
    } catch (IOException e) {
        String message = format("Unable to load provisioned capabilities. Invalid JSON value: %s", provisionedCapabilitiesJsonString);
        throw new JoynrRuntimeException(message, e);
    }
}
Also used : ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) InProcessAddress(io.joynr.messaging.inprocess.InProcessAddress) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) TypeReference(com.fasterxml.jackson.core.type.TypeReference) IOException(java.io.IOException) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException)

Example 73 with JoynrRuntimeException

use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.

the class LocalCapabilitiesDirectoryTest method createAddAnswerWithError.

private Answer<Future<Void>> createAddAnswerWithError() {
    return new Answer<Future<Void>>() {

        @SuppressWarnings("unchecked")
        @Override
        public Future<Void> answer(InvocationOnMock invocation) throws Throwable {
            Future<Void> result = new Future<Void>();
            Object[] args = invocation.getArguments();
            ((Callback<Void>) args[0]).onFailure(new JoynrRuntimeException("Simulating a JoynrRuntimeException on callback"));
            result.onSuccess(null);
            return result;
        }
    };
}
Also used : Mockito.doAnswer(org.mockito.Mockito.doAnswer) Answer(org.mockito.stubbing.Answer) Callback(io.joynr.proxy.Callback) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Future(io.joynr.proxy.Future) DeferredVoid(io.joynr.provider.DeferredVoid) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException)

Example 74 with JoynrRuntimeException

use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.

the class LocalDomainAccessControllerImpl method unsubscribeFromAceChanges.

@Override
public void unsubscribeFromAceChanges(String domain, String interfaceName) {
    UserDomainInterfaceOperationKey subscriptionKey = new UserDomainInterfaceOperationKey(null, domain, interfaceName, null);
    AceSubscription subscriptions = subscriptionsMap.get(subscriptionKey);
    if (subscriptions != null) {
        try {
            globalDomainAccessControllerClient.unsubscribeFromMasterAccessControlEntryChangedBroadcast(subscriptions.getMasterSubscriptionId());
            globalDomainAccessControllerClient.unsubscribeFromMediatorAccessControlEntryChangedBroadcast(subscriptions.getMediatorSubscriptionId());
            globalDomainAccessControllerClient.unsubscribeFromOwnerAccessControlEntryChangedBroadcast(subscriptions.getOwnerSubscriptionId());
        } catch (JoynrRuntimeException | InterruptedException | ApplicationException e) {
            LOG.warn("unsubscribe from AceChanges failed due to the following error: {}", e.getMessage());
            return;
        }
    } else {
        /*
             * This can be the case, when no consumer request has been performed during the lifetime of the provider
             */
        LOG.debug("Subscription for ace subscription for interface '{}' domain '{}' not found", interfaceName, domain);
    }
}
Also used : ApplicationException(joynr.exceptions.ApplicationException) UserDomainInterfaceOperationKey(io.joynr.accesscontrol.primarykey.UserDomainInterfaceOperationKey) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException)

Example 75 with JoynrRuntimeException

use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.

the class LocalCapabilitiesDirectoryImpl method shutdown.

@Override
public void shutdown(boolean unregisterAllRegisteredCapabilities) {
    freshnessUpdateScheduler.shutdownNow();
    if (unregisterAllRegisteredCapabilities) {
        Set<DiscoveryEntry> allDiscoveryEntries = localDiscoveryEntryStore.getAllDiscoveryEntries();
        List<DiscoveryEntry> discoveryEntries = new ArrayList<>(allDiscoveryEntries.size());
        for (DiscoveryEntry capabilityEntry : allDiscoveryEntries) {
            if (capabilityEntry.getQos().getScope() == ProviderScope.GLOBAL) {
                discoveryEntries.add(capabilityEntry);
            }
        }
        if (discoveryEntries.size() > 0) {
            try {
                Function<? super DiscoveryEntry, String> transfomerFct = new Function<DiscoveryEntry, String>() {

                    @Override
                    public String apply(DiscoveryEntry input) {
                        return input != null ? input.getParticipantId() : null;
                    }
                };
                Callback<Void> callback = new Callback<Void>() {

                    @Override
                    public void onFailure(JoynrRuntimeException error) {
                    }

                    @Override
                    public void onSuccess(Void result) {
                    }
                };
                globalCapabilitiesDirectoryClient.remove(callback, Lists.newArrayList(Collections2.transform(discoveryEntries, transfomerFct)));
            } catch (DiscoveryException e) {
                logger.debug("error removing discovery entries", e);
            }
        }
    }
}
Also used : Function(com.google.common.base.Function) DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) Callback(io.joynr.proxy.Callback) ArrayList(java.util.ArrayList) DeferredVoid(io.joynr.provider.DeferredVoid) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) DiscoveryException(io.joynr.exceptions.DiscoveryException)

Aggregations

JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)76 Test (org.junit.Test)41 ApplicationException (joynr.exceptions.ApplicationException)18 joynr.tests.testProxy (joynr.tests.testProxy)16 MessagingQos (io.joynr.messaging.MessagingQos)14 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)13 Callback (io.joynr.proxy.Callback)9 Future (io.joynr.proxy.Future)9 ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)9 IOException (java.io.IOException)8 Semaphore (java.util.concurrent.Semaphore)8 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)8 InvocationOnMock (org.mockito.invocation.InvocationOnMock)8 DiscoveryException (io.joynr.exceptions.DiscoveryException)7 JoynrException (io.joynr.exceptions.JoynrException)7 DeferredVoid (io.joynr.provider.DeferredVoid)7 HashSet (java.util.HashSet)7 ProviderQos (joynr.types.ProviderQos)7 JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)5 ProxyCreatedCallback (io.joynr.proxy.ProxyBuilder.ProxyCreatedCallback)5