Decouple config and netconf subsystems.
[controller.git] / opendaylight / netconf / sal-netconf-connector / src / main / java / org / opendaylight / controller / sal / connect / netconf / sal / NetconfDeviceTopologyAdapter.java
@@ -56,7 +56,7 @@ import org.slf4j.LoggerFactory;
 
 final class NetconfDeviceTopologyAdapter implements AutoCloseable {
 
-    public static final Logger logger = LoggerFactory.getLogger(NetconfDeviceTopologyAdapter.class);
+    private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceTopologyAdapter.class);
     public static final Function<Entry<QName, FailureReason>, UnavailableCapability> UNAVAILABLE_CAPABILITY_TRANSFORMER = new Function<Entry<QName, FailureReason>, UnavailableCapability>() {
         @Override
         public UnavailableCapability apply(final Entry<QName, FailureReason> input) {
@@ -85,13 +85,14 @@ final class NetconfDeviceTopologyAdapter implements AutoCloseable {
         this.txChain = Preconditions.checkNotNull(dataService).createTransactionChain(new TransactionChainListener() {
             @Override
             public void onTransactionChainFailed(TransactionChain<?, ?> chain, AsyncTransaction<?, ?> transaction, Throwable cause) {
-                logger.error("{}: TransactionChain({}) {} FAILED!", id, chain, transaction.getIdentifier(), cause);
+                LOG.error("{}: TransactionChain({}) {} FAILED!", id, chain,
+                        transaction.getIdentifier(), cause);
                 throw new IllegalStateException(id + "  TransactionChain(" + chain + ") not committed correctly", cause);
             }
 
             @Override
             public void onTransactionChainSuccessful(TransactionChain<?, ?> chain) {
-                logger.trace("{}: TransactionChain({}) {} SUCCESSFUL", id, chain);
+                LOG.trace("{}: TransactionChain({}) SUCCESSFUL", id, chain);
             }
         });
 
@@ -101,7 +102,7 @@ final class NetconfDeviceTopologyAdapter implements AutoCloseable {
         initDeviceData();
     }
 
-     private void initDeviceData() {
+    private void initDeviceData() {
         final WriteTransaction writeTx = txChain.newWriteOnlyTransaction();
 
         createNetworkTopologyIfNotPresent(writeTx);
@@ -115,13 +116,21 @@ final class NetconfDeviceTopologyAdapter implements AutoCloseable {
         nodeBuilder.addAugmentation(NetconfNode.class, netconfNodeBuilder.build());
         Node node = nodeBuilder.build();
 
-        logger.trace("{}: Init device state transaction {} putting if absent operational data started.", id, writeTx.getIdentifier());
+        LOG.trace(
+                "{}: Init device state transaction {} putting if absent operational data started.",
+                id, writeTx.getIdentifier());
         writeTx.put(LogicalDatastoreType.OPERATIONAL, path, node);
-        logger.trace("{}: Init device state transaction {} putting operational data ended.", id, writeTx.getIdentifier());
+        LOG.trace(
+                "{}: Init device state transaction {} putting operational data ended.",
+                id, writeTx.getIdentifier());
 
-        logger.trace("{}: Init device state transaction {} putting if absent config data started.", id, writeTx.getIdentifier());
+        LOG.trace(
+                "{}: Init device state transaction {} putting if absent config data started.",
+                id, writeTx.getIdentifier());
         writeTx.put(LogicalDatastoreType.CONFIGURATION, path, getNodeWithId(id));
-        logger.trace("{}: Init device state transaction {} putting config data ended.", id, writeTx.getIdentifier());
+        LOG.trace(
+                "{}: Init device state transaction {} putting config data ended.",
+                id, writeTx.getIdentifier());
 
         commitTransaction(writeTx, "init");
     }
@@ -130,9 +139,13 @@ final class NetconfDeviceTopologyAdapter implements AutoCloseable {
         final Node data = buildDataForNetconfNode(up, capabilities);
 
         final WriteTransaction writeTx = txChain.newWriteOnlyTransaction();
-        logger.trace("{}: Update device state transaction {} merging operational data started.", id, writeTx.getIdentifier());
+        LOG.trace(
+                "{}: Update device state transaction {} merging operational data started.",
+                id, writeTx.getIdentifier());
         writeTx.put(LogicalDatastoreType.OPERATIONAL, id.getTopologyBindingPath(), data);
-        logger.trace("{}: Update device state transaction {} merging operational data ended.", id, writeTx.getIdentifier());
+        LOG.trace(
+                "{}: Update device state transaction {} merging operational data ended.",
+                id, writeTx.getIdentifier());
 
         commitTransaction(writeTx, "update");
     }
@@ -144,9 +157,13 @@ final class NetconfDeviceTopologyAdapter implements AutoCloseable {
         final Node data = getNodeIdBuilder(id).addAugmentation(NetconfNode.class, netconfNode).build();
 
         final WriteTransaction writeTx = txChain.newWriteOnlyTransaction();
-        logger.trace("{}: Setting device state as failed {} putting operational data started.", id, writeTx.getIdentifier());
+        LOG.trace(
+                "{}: Setting device state as failed {} putting operational data started.",
+                id, writeTx.getIdentifier());
         writeTx.put(LogicalDatastoreType.OPERATIONAL, id.getTopologyBindingPath(), data);
-        logger.trace("{}: Setting device state as failed {} putting operational data ended.", id, writeTx.getIdentifier());
+        LOG.trace(
+                "{}: Setting device state as failed {} putting operational data ended.",
+                id, writeTx.getIdentifier());
 
         commitTransaction(writeTx, "update-failed-device");
     }
@@ -177,10 +194,14 @@ final class NetconfDeviceTopologyAdapter implements AutoCloseable {
     public void removeDeviceConfiguration() {
         final WriteTransaction writeTx = txChain.newWriteOnlyTransaction();
 
-        logger.trace("{}: Close device state transaction {} removing all data started.", id, writeTx.getIdentifier());
+        LOG.trace(
+                "{}: Close device state transaction {} removing all data started.",
+                id, writeTx.getIdentifier());
         writeTx.delete(LogicalDatastoreType.CONFIGURATION, id.getTopologyBindingPath());
         writeTx.delete(LogicalDatastoreType.OPERATIONAL, id.getTopologyBindingPath());
-        logger.trace("{}: Close device state transaction {} removing all data ended.", id, writeTx.getIdentifier());
+        LOG.trace(
+                "{}: Close device state transaction {} removing all data ended.",
+                id, writeTx.getIdentifier());
 
         commitTransaction(writeTx, "close");
     }
@@ -188,29 +209,34 @@ final class NetconfDeviceTopologyAdapter implements AutoCloseable {
     private void createNetworkTopologyIfNotPresent(final WriteTransaction writeTx) {
 
         final NetworkTopology networkTopology = new NetworkTopologyBuilder().build();
-        logger.trace("{}: Merging {} container to ensure its presence", id, networkTopology.QNAME, writeTx.getIdentifier());
+        LOG.trace("{}: Merging {} container to ensure its presence", id,
+                networkTopology.QNAME, writeTx.getIdentifier());
         writeTx.merge(LogicalDatastoreType.CONFIGURATION, networkTopologyPath, networkTopology);
         writeTx.merge(LogicalDatastoreType.OPERATIONAL, networkTopologyPath, networkTopology);
 
         final Topology topology = new TopologyBuilder().setTopologyId(new TopologyId(TopologyNetconf.QNAME.getLocalName())).build();
-        logger.trace("{}: Merging {} container to ensure its presence", id, topology.QNAME, writeTx.getIdentifier());
+        LOG.trace("{}: Merging {} container to ensure its presence", id,
+                topology.QNAME, writeTx.getIdentifier());
         writeTx.merge(LogicalDatastoreType.CONFIGURATION, topologyListPath, topology);
         writeTx.merge(LogicalDatastoreType.OPERATIONAL, topologyListPath, topology);
     }
 
     private void commitTransaction(final WriteTransaction transaction, final String txType) {
-        logger.trace("{}: Committing Transaction {}:{}", id, txType, transaction.getIdentifier());
+        LOG.trace("{}: Committing Transaction {}:{}", id, txType,
+                transaction.getIdentifier());
         final CheckedFuture<Void, TransactionCommitFailedException> result = transaction.submit();
 
         Futures.addCallback(result, new FutureCallback<Void>() {
             @Override
             public void onSuccess(final Void result) {
-                logger.trace("{}: Transaction({}) {} SUCCESSFUL", id, txType, transaction.getIdentifier());
+                LOG.trace("{}: Transaction({}) {} SUCCESSFUL", id, txType,
+                        transaction.getIdentifier());
             }
 
             @Override
             public void onFailure(final Throwable t) {
-                logger.error("{}: Transaction({}) {} FAILED!", id, txType, transaction.getIdentifier(), t);
+                LOG.error("{}: Transaction({}) {} FAILED!", id, txType,
+                        transaction.getIdentifier(), t);
                 throw new IllegalStateException(id + "  Transaction(" + txType + ") not committed correctly", t);
             }
         });