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>
@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){
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;
}
}