Address comments in prior patches 62/37662/5
authorTom Pantelis <tpanteli@brocade.com>
Thu, 14 Apr 2016 15:56:01 +0000 (11:56 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Mon, 25 Apr 2016 15:08:08 +0000 (15:08 +0000)
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>
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/BlueprintContainerRestartServiceImpl.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/ComponentProcessor.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/NotificationListenerBean.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/OpendaylightNamespaceHandler.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RoutedRpcMetadata.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RoutedRpcRegistrationConverter.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RpcImplementationBean.java
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RpcServiceMetadata.java
opendaylight/config/netty-threadgroup-config/src/main/resources/org/opendaylight/blueprint/netty-threadgroup.xml
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/ActorSystemProviderModule.java
opendaylight/md-sal/samples/toaster-consumer/src/main/resources/org/opendaylight/blueprint/toaster-consumer.xml

index 3e04f213495c2cc37c52b19fdf4348e524a9b2bb..107ea39c1c6c8f4753d38dd07db6da74775b9cf5 100644 (file)
@@ -7,6 +7,7 @@
  */
 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;
@@ -20,7 +21,8 @@ import org.osgi.framework.ServiceReference;
 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
  */
@@ -49,6 +51,7 @@ class BlueprintContainerRestartServiceImpl implements AutoCloseable, BlueprintCo
     }
 
     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);
 
@@ -58,8 +61,7 @@ class BlueprintContainerRestartServiceImpl implements AutoCloseable, BlueprintCo
                 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));
         }
 
@@ -81,11 +83,11 @@ class BlueprintContainerRestartServiceImpl implements AutoCloseable, BlueprintCo
      * @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...
             return;
         }
 
             return;
         }
 
-        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) {
index bae06b1ea6335e9ef5daecd81756fc7590250b84..a4b63aa4277b0f3cdef52f1bf248cb9090903ff6 100644 (file)
@@ -128,7 +128,7 @@ public class ComponentProcessor implements ComponentDefinitionRegistryProcessor
     }
 
     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;
index bdef13f59c88f3f3a2bfe8bb225f238e520720db..c0931f32c2f0198beade03d2101cac3ca77c828a 100644 (file)
@@ -40,7 +40,6 @@ public class NotificationListenerBean {
         this.bundle = bundle;
     }
 
         this.bundle = bundle;
     }
 
-    @SuppressWarnings({ })
     public void init() {
         LOG.debug("{}: init - registering NotificationListener {}", bundle.getSymbolicName(), notificationListener);
 
     public void init() {
         LOG.debug("{}: init - registering NotificationListener {}", bundle.getSymbolicName(), notificationListener);
 
@@ -49,7 +48,10 @@ public class NotificationListenerBean {
 
     public void destroy() {
         if(registration != null) {
 
     public void destroy() {
         if(registration != null) {
+            LOG.debug("{}: destroy - closing ListenerRegistration {}", bundle.getSymbolicName(), notificationListener);
             registration.close();
             registration.close();
+        } else {
+            LOG.debug("{}: destroy - listener was not registered", bundle.getSymbolicName());
         }
     }
 }
         }
     }
 }
index 297c3d448466478ec948587807ff8e4d3976687f..80417e8bd076fb39fd8b7db1a02090bf5ae8567c 100644 (file)
@@ -181,7 +181,7 @@ public class OpendaylightNamespaceHandler implements NamespaceHandler {
 
         LOG.debug("{}: {}", propertyName, attr.getValue());
 
 
         LOG.debug("{}: {}", propertyName, attr.getValue());
 
-        if(!Boolean.TRUE.equals(Boolean.valueOf(attr.getValue()))) {
+        if(!Boolean.parseBoolean(attr.getValue())) {
             return component;
         }
 
             return component;
         }
 
index 4b71d92e57be3b5b03b4f6460cb6061609c577a2..7bf559ea4cca3bf7a169db89725a24c8872203c0 100644 (file)
@@ -105,7 +105,7 @@ class RoutedRpcMetadata implements ComponentFactoryMetadata {
     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() {
index acc6a01d4ae7b55208dd95d280d83dd8f33cfda4..7daf7febf6493ca5bfe0c03d95ad86134a72eb05 100644 (file)
@@ -28,7 +28,7 @@ public class RoutedRpcRegistrationConverter implements Converter {
     }
 
     @Override
     }
 
     @Override
-    public Object convert(Object sourceObject, ReifiedType targetType) throws Exception {
+    public Object convert(Object sourceObject, ReifiedType targetType) {
         return sourceObject;
     }
 }
         return sourceObject;
     }
 }
index b81f833b12873dded8a0bc01fb7a620bd03a94b7..1ab78db9cd5e862b8b99384af0a61d02b7677312 100644 (file)
@@ -33,7 +33,7 @@ public class RpcImplementationBean {
     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;
index b48d04245b68c2b00079cf66c1864568919e2662..7fc077d2870fa417b09168402044f610db6af2f7 100644 (file)
@@ -92,9 +92,6 @@ class RpcServiceMetadata implements ComponentFactoryMetadata {
 
     @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 + "]";
     }
 }
     }
 }
index f9ad6a4da3d41c13396684e2ff1aba78bf3550e2..527b04303a2b75ca36c74c79936752f07ee1411d 100644 (file)
@@ -6,6 +6,7 @@
 
   <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>
index 8c2e8d05463684107460ae347ea9d235e1d71c80..511f5dfdee7067f989c9d4077873794368f10f75 100644 (file)
@@ -43,19 +43,19 @@ public class ActorSystemProviderModule extends AbstractActorSystemProviderModule
         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;
         }
index 6b9bf35463d3b9033447bb6ad0e5c7c06662ec4f..16e8f98d6a9128e1113ee585cc02fa05c5e86a15 100644 (file)
@@ -3,7 +3,7 @@
            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
+</blueprint>