Fix issue on shutdown. 58/24358/1
authorAlexis de Talhouët <adetalhouet@inocybe.com>
Tue, 21 Jul 2015 19:44:01 +0000 (15:44 -0400)
committerAlexis de Talhouët <adetalhouet@inocybe.com>
Tue, 21 Jul 2015 19:44:01 +0000 (15:44 -0400)
On shutdown, former behaviour was deleting ccap and qos from the operational datastore directly.
But at no point those were initialized. So if no action was perfomed by the user, we could see the attached log.

I think all we need is the close the ListenerRegistration and eveything will be deleted on the operational datastore.

associated logs: https://gist.github.com/23396b108c1742b9299b

Change-Id: I1816387787deb7e441a55df3dd58c9ccaf892d4e
Signed-off-by: Alexis de Talhouët <adetalhouet@inocybe.com>
packetcable-policy-server/src/main/java/org/opendaylight/controller/packetcable/provider/PacketcableProvider.java
packetcable-policy-server/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/packetcable/packetcable/policy/server/impl/rev140131/PacketcableProviderModule.java

index 08854e6009036ccb2bc79909ca2cb91cf57714e4..6f68360d5b2459e3af00a86d8a5845e1fd259956 100644 (file)
@@ -87,14 +87,6 @@ public class PacketcableProvider implements DataChangeListener, AutoCloseable {
     @Override
     public void close() throws ExecutionException, InterruptedException {
         executor.shutdown();
-        if (dataBroker != null) {
-            // remove our config datastore instances
-            final AsyncReadWriteTransaction<InstanceIdentifier<?>, ?> tx = dataBroker.newReadWriteTransaction();
-            tx.delete(LogicalDatastoreType.CONFIGURATION, ccapIID);
-            tx.delete(LogicalDatastoreType.CONFIGURATION, qosIID);
-            // TODO - commit() below has been deprecated
-            tx.commit().get();
-        }
     }
 
     public InetAddress getInetAddress(final String subId){
index 51212bacaab7eaa6d2ce157d497459e61a832ef0..1d6275ba72cc5d4649fabd405f8c96bd17e25c11 100644 (file)
@@ -39,9 +39,25 @@ public class PacketcableProviderModule extends org.opendaylight.yang.gen.v1.urn.
                 dataBrokerService.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
                         PacketcableProvider.qosIID, provider, DataBroker.DataChangeScope.SUBTREE );
 
-
         logger.info("PacketCableProvider Registered with DataBroker");
-        return provider;
+
+        AutoCloseable close = new AutoCloseable() {
+
+            @Override
+            public void close() throws Exception {
+                if (ccapDataChangeListenerRegistration != null) {
+                    ccapDataChangeListenerRegistration.close();
+                }
+                if (qosDataChangeListenerRegistration != null) {
+                    qosDataChangeListenerRegistration.close();
+                }
+                if (provider != null) {
+                    provider.close();
+                }
+            }
+        };
+
+        return close;
     }
 
 }