*/
package org.opendaylight.controller.blueprint;
+import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/** Implementation of the BlueprintContainerRestartService.
+/**
+ * Implementation of the BlueprintContainerRestartService.
*
* @author Thomas Pantelis
*/
}
private void restartContainerAndDependentsInternal(Bundle forBundle) {
+ // We use a LinkedHashSet to preserve insertion order as we walk the service usage hierarchy.
Set<Bundle> containerBundlesSet = new LinkedHashSet<>();
findDependentContainersRecursively(forBundle, containerBundlesSet);
containerBundles.subList(1, containerBundles.size()));
// Destroy the containers in reverse order with 'forBundle' last, ie bottom-up in the service tree.
- for(int i = containerBundles.size() - 1; i >= 0; i--) {
- Bundle bundle = containerBundles.get(i);
+ for(Bundle bundle: Lists.reverse(containerBundles)) {
blueprintExtenderService.destroyContainer(bundle, blueprintExtenderService.getContainer(bundle));
}
* @param containerBundles the current set of bundles containing blueprint containers
*/
private void findDependentContainersRecursively(Bundle bundle, Set<Bundle> containerBundles) {
- if(containerBundles.contains(bundle)) {
+ if(!containerBundles.add(bundle)) {
+ // Already seen this bundle...
return;
}
- containerBundles.add(bundle);
ServiceReference<?>[] references = bundle.getRegisteredServices();
if (references != null) {
for (ServiceReference<?> reference : references) {
}
private void registerManagedService(final String persistentId) {
- // Register a ManagedService so we git updates from the ConfigAdmin when the cfg file corresponding
+ // Register a ManagedService so we get updates from the ConfigAdmin when the cfg file corresponding
// to the persistentId changes.
ManagedService managedService = new ManagedService() {
private volatile boolean initialUpdate = true;
this.bundle = bundle;
}
- @SuppressWarnings({ })
public void init() {
LOG.debug("{}: init - registering NotificationListener {}", bundle.getSymbolicName(), notificationListener);
public void destroy() {
if(registration != null) {
+ LOG.debug("{}: destroy - closing ListenerRegistration {}", bundle.getSymbolicName(), notificationListener);
registration.close();
+ } else {
+ LOG.debug("{}: destroy - listener was not registered", bundle.getSymbolicName());
}
}
}
LOG.debug("{}: {}", propertyName, attr.getValue());
- if(!Boolean.TRUE.equals(Boolean.valueOf(attr.getValue()))) {
+ if(!Boolean.parseBoolean(attr.getValue())) {
return component;
}
public void destroy(Object instance) {
LOG.debug("{}: In destroy: instance: {}", logName(), instance);
- (( RoutedRpcRegistration<?>)instance).close();
+ ((RoutedRpcRegistration<?>)instance).close();
}
private String logName() {
}
@Override
- public Object convert(Object sourceObject, ReifiedType targetType) throws Exception {
+ public Object convert(Object sourceObject, ReifiedType targetType) {
return sourceObject;
}
}
private Bundle bundle;
private String interfaceName;
private RpcService implementation;
- private final List<RpcRegistration<RpcService>> rpcRegistrations = new ArrayList<>();;
+ private final List<RpcRegistration<RpcService>> rpcRegistrations = new ArrayList<>();
public void setRpcRegistry(RpcProviderRegistry rpcRegistry) {
this.rpcRegistry = rpcRegistry;
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("RpcServiceMetadata [id=").append(id).append(", interfaceName=").append(interfaceName)
- .append("]");
- return builder.toString();
+ return "RpcServiceMetadata [id=" + id + ", interfaceName=" + interfaceName + ", container=" + container + "]";
}
}
<cm:property-placeholder persistent-id="org.opendaylight.netty.threadgroup" update-strategy="none">
<cm:default-properties>
+ <!-- 0 means use the default number of threads -->
<cm:property name="global-boss-group-thread-count" value="0"/>
<cm:property name="global-worker-group-thread-count" value="0"/>
</cm:default-properties>
WaitingServiceTracker<ActorSystemProvider> tracker = WaitingServiceTracker.create(
ActorSystemProvider.class, bundleContext);
ActorSystemProvider delegate = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
- return new ForardingActorSystemProvider(delegate, tracker);
+ return new ForwardingActorSystemProvider(delegate, tracker);
}
public void setBundleContext(BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
- private static class ForardingActorSystemProvider extends ForwardingObject
+ private static class ForwardingActorSystemProvider extends ForwardingObject
implements ActorSystemProvider, AutoCloseable {
private final ActorSystemProvider delegate;
private final AutoCloseable closeable;
- ForardingActorSystemProvider(ActorSystemProvider delegate, AutoCloseable closeable) {
+ ForwardingActorSystemProvider(ActorSystemProvider delegate, AutoCloseable closeable) {
this.delegate = delegate;
this.closeable = closeable;
}
xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
odl:use-default-for-reference-types="true">
- <!-- Retrieves the RPC service for the ToasterService interface -->
+ <!-- Retrieves the RPC service for the ToasterService interface -->
<odl:rpc-service id="toasterService" interface="org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService"/>
<!-- Create the KitchenServiceImpl instance and inject the RPC service identified by "toasterService" -->
<!-- Register the KitchenServiceImpl to receive yang notifications -->
<odl:notification-listener ref="kitchenService"/>
- <!-- Advertise the KitchenServiceImpl with the OSGi registry with the type property set to "default" . The
+ <!-- Advertise the KitchenServiceImpl with the OSGi registry with the type property set to "default" . The
type property is optional but can be used to distinguish this implementation from any other potential
KitchenService implementations (if there were any). Clients consuming the KitchenService can pick the
desired implementation via the particular type.
-->
<service ref="kitchenService" interface="org.opendaylight.controller.sample.kitchen.api.KitchenService"
odl:type="default"/>
-</blueprint>
\ No newline at end of file
+</blueprint>