Follow-up patch to address comments in
https://git.opendaylight.org/gerrit/#/c/36476/ and
https://git.opendaylight.org/gerrit/#/c/36485/.
Change-Id: Ic4e9c4957a3440c8772fe814a3f4732c054b3271
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
*/
package org.opendaylight.controller.blueprint;
*/
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 com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/** Implementation of the BlueprintContainerRestartService.
+/**
+ * Implementation of the BlueprintContainerRestartService.
*
* @author Thomas Pantelis
*/
*
* @author Thomas Pantelis
*/
}
private void restartContainerAndDependentsInternal(Bundle forBundle) {
}
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);
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.
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));
}
blueprintExtenderService.destroyContainer(bundle, blueprintExtenderService.getContainer(bundle));
}
* @param containerBundles the current set of bundles containing blueprint containers
*/
private void findDependentContainersRecursively(Bundle bundle, Set<Bundle> containerBundles) {
* @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...
- containerBundles.add(bundle);
ServiceReference<?>[] references = bundle.getRegisteredServices();
if (references != null) {
for (ServiceReference<?> reference : references) {
ServiceReference<?>[] references = bundle.getRegisteredServices();
if (references != null) {
for (ServiceReference<?> reference : references) {
}
private void registerManagedService(final String persistentId) {
}
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;
// to the persistentId changes.
ManagedService managedService = new ManagedService() {
private volatile boolean initialUpdate = true;
public void init() {
LOG.debug("{}: init - registering NotificationListener {}", bundle.getSymbolicName(), notificationListener);
public void init() {
LOG.debug("{}: init - registering NotificationListener {}", bundle.getSymbolicName(), notificationListener);
public void destroy() {
if(registration != null) {
public void destroy() {
if(registration != null) {
+ LOG.debug("{}: destroy - closing ListenerRegistration {}", bundle.getSymbolicName(), notificationListener);
+ } else {
+ LOG.debug("{}: destroy - listener was not registered", bundle.getSymbolicName());
LOG.debug("{}: {}", propertyName, attr.getValue());
LOG.debug("{}: {}", propertyName, attr.getValue());
- if(!Boolean.TRUE.equals(Boolean.valueOf(attr.getValue()))) {
+ if(!Boolean.parseBoolean(attr.getValue())) {
public void destroy(Object instance) {
LOG.debug("{}: In destroy: instance: {}", logName(), instance);
public void destroy(Object instance) {
LOG.debug("{}: In destroy: instance: {}", logName(), instance);
- (( RoutedRpcRegistration<?>)instance).close();
+ ((RoutedRpcRegistration<?>)instance).close();
}
private String logName() {
}
private String logName() {
- public Object convert(Object sourceObject, ReifiedType targetType) throws Exception {
+ public Object convert(Object sourceObject, ReifiedType targetType) {
private Bundle bundle;
private String interfaceName;
private RpcService implementation;
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;
public void setRpcRegistry(RpcProviderRegistry rpcRegistry) {
this.rpcRegistry = rpcRegistry;
@Override
public String toString() {
@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>
<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>
<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);
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;
}
}
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;
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;
}
this.delegate = delegate;
this.closeable = closeable;
}
xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
odl:use-default-for-reference-types="true">
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" -->
<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"/>
<!-- 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"/>
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