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