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 3e04f21..107ea39 100644 (file)
@@ -7,6 +7,7 @@
  */
 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;
@@ -20,7 +21,8 @@ import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/** Implementation of the BlueprintContainerRestartService.
+/**
+ * Implementation of the BlueprintContainerRestartService.
  *
  * @author Thomas Pantelis
  */
@@ -49,6 +51,7 @@ class BlueprintContainerRestartServiceImpl implements AutoCloseable, BlueprintCo
     }
 
     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);
 
@@ -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.
-        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));
         }
 
@@ -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) {
-        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) {
index bae06b1..a4b63aa 100644 (file)
@@ -128,7 +128,7 @@ public class ComponentProcessor implements ComponentDefinitionRegistryProcessor
     }
 
     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;
index bdef13f..c0931f3 100644 (file)
@@ -40,7 +40,6 @@ public class NotificationListenerBean {
         this.bundle = bundle;
     }
 
-    @SuppressWarnings({ })
     public void init() {
         LOG.debug("{}: init - registering NotificationListener {}", bundle.getSymbolicName(), notificationListener);
 
@@ -49,7 +48,10 @@ public class NotificationListenerBean {
 
     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());
         }
     }
 }
index 297c3d4..80417e8 100644 (file)
@@ -181,7 +181,7 @@ public class OpendaylightNamespaceHandler implements NamespaceHandler {
 
         LOG.debug("{}: {}", propertyName, attr.getValue());
 
-        if(!Boolean.TRUE.equals(Boolean.valueOf(attr.getValue()))) {
+        if(!Boolean.parseBoolean(attr.getValue())) {
             return component;
         }
 
index 4b71d92..7bf559e 100644 (file)
@@ -105,7 +105,7 @@ class RoutedRpcMetadata implements ComponentFactoryMetadata {
     public void destroy(Object instance) {
         LOG.debug("{}: In destroy: instance: {}", logName(), instance);
 
-        (( RoutedRpcRegistration<?>)instance).close();
+        ((RoutedRpcRegistration<?>)instance).close();
     }
 
     private String logName() {
index acc6a01..7daf7fe 100644 (file)
@@ -28,7 +28,7 @@ public class RoutedRpcRegistrationConverter implements Converter {
     }
 
     @Override
-    public Object convert(Object sourceObject, ReifiedType targetType) throws Exception {
+    public Object convert(Object sourceObject, ReifiedType targetType) {
         return sourceObject;
     }
 }
index b81f833..1ab78db 100644 (file)
@@ -33,7 +33,7 @@ public class RpcImplementationBean {
     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;
index b48d042..7fc077d 100644 (file)
@@ -92,9 +92,6 @@ class RpcServiceMetadata implements ComponentFactoryMetadata {
 
     @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 f9ad6a4..527b043 100644 (file)
@@ -6,6 +6,7 @@
 
   <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>
index 8c2e8d0..511f5df 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);
-        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;
         }
index 6b9bf35..16e8f98 100644 (file)
@@ -3,7 +3,7 @@
            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>

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.