Decouple config and netconf subsystems.
[controller.git] / opendaylight / netconf / sal-netconf-connector / src / main / java / org / opendaylight / controller / sal / connect / netconf / NetconfDevice.java
@@ -66,7 +66,7 @@ import org.slf4j.LoggerFactory;
  */
 public final class NetconfDevice implements RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> {
 
-    private static final Logger logger = LoggerFactory.getLogger(NetconfDevice.class);
+    private static final Logger LOG = LoggerFactory.getLogger(NetconfDevice.class);
 
     /**
      * Initial schema context contains schemas for netconf monitoring and netconf notifications
@@ -83,7 +83,7 @@ public final class NetconfDevice implements RemoteDevice<NetconfSessionPreferenc
                             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.$YangModuleInfoImpl.getInstance()));
             INIT_SCHEMA_CTX = moduleInfoBackedContext.tryToCreateSchemaContext().get();
         } catch (final RuntimeException e) {
-            logger.error("Unable to prepare schema context for netconf initialization", e);
+            LOG.error("Unable to prepare schema context for netconf initialization", e);
             throw new ExceptionInInitializerError(e);
         }
     }
@@ -143,14 +143,14 @@ public final class NetconfDevice implements RemoteDevice<NetconfSessionPreferenc
         // Yang models are being downloaded in this method and it would cause a
         // deadlock if we used the netty thread
         // http://netty.io/wiki/thread-model.html
-        logger.debug("{}: Session to remote device established with {}", id, remoteSessionCapabilities);
+        LOG.debug("{}: Session to remote device established with {}", id, remoteSessionCapabilities);
 
         final NetconfDeviceRpc initRpc = getRpcForInitialization(listener);
         final DeviceSourcesResolver task = new DeviceSourcesResolver(remoteSessionCapabilities, id, stateSchemasResolver, initRpc);
         final ListenableFuture<DeviceSources> sourceResolverFuture = processingExecutor.submit(task);
 
-        if(shouldListenOnSchemaChange(remoteSessionCapabilities)) {
-           registerToBaseNetconfStream(initRpc, listener);
+        if (shouldListenOnSchemaChange(remoteSessionCapabilities)) {
+            registerToBaseNetconfStream(initRpc, listener);
         }
 
         final FutureCallback<DeviceSources> resolvedSourceCallback = new FutureCallback<DeviceSources>() {
@@ -166,7 +166,7 @@ public final class NetconfDevice implements RemoteDevice<NetconfSessionPreferenc
 
             @Override
             public void onFailure(final Throwable t) {
-                logger.warn("{}: Unexpected error resolving device sources: {}", id, t);
+                LOG.warn("{}: Unexpected error resolving device sources: {}", id, t);
                 handleSalInitializationFailure(t, listener);
             }
         };
@@ -177,14 +177,14 @@ public final class NetconfDevice implements RemoteDevice<NetconfSessionPreferenc
     private void registerToBaseNetconfStream(final NetconfDeviceRpc deviceRpc, final NetconfDeviceCommunicator listener) {
        // TODO check whether the model describing create subscription is present in schema
         // Perhaps add a default schema context to support create-subscription if the model was not provided (same as what we do for base netconf operations in transformer)
-       final CheckedFuture<DOMRpcResult, DOMRpcException> rpcResultListenableFuture =
+        final CheckedFuture<DOMRpcResult, DOMRpcException> rpcResultListenableFuture =
                 deviceRpc.invokeRpc(NetconfMessageTransformUtil.toPath(NetconfMessageTransformUtil.CREATE_SUBSCRIPTION_RPC_QNAME), NetconfMessageTransformUtil.CREATE_SUBSCRIPTION_RPC_CONTENT);
 
         final NotificationHandler.NotificationFilter filter = new NotificationHandler.NotificationFilter() {
             @Override
             public Optional<DOMNotification> filterNotification(final DOMNotification notification) {
                 if (isCapabilityChanged(notification)) {
-                    logger.info("{}: Schemas change detected, reconnecting", id);
+                    LOG.info("{}: Schemas change detected, reconnecting", id);
                     // Only disconnect is enough, the reconnecting nature of the connector will take care of reconnecting
                     listener.disconnect();
                     return Optional.absent();
@@ -205,7 +205,7 @@ public final class NetconfDevice implements RemoteDevice<NetconfSessionPreferenc
 
             @Override
             public void onFailure(final Throwable t) {
-                logger.warn("Unable to subscribe to base notification stream. Schemas will not be reloaded on the fly", t);
+                LOG.warn("Unable to subscribe to base notification stream. Schemas will not be reloaded on the fly", t);
             }
         });
     }
@@ -223,11 +223,11 @@ public final class NetconfDevice implements RemoteDevice<NetconfSessionPreferenc
         salFacade.onDeviceConnected(result, remoteSessionCapabilities, deviceRpc);
         notificationHandler.onRemoteSchemaUp(messageTransformer);
 
-        logger.info("{}: Netconf connector initialized successfully", id);
+        LOG.info("{}: Netconf connector initialized successfully", id);
     }
 
     private void handleSalInitializationFailure(final Throwable t, final RemoteDeviceCommunicator<NetconfMessage> listener) {
-        logger.error("{}: Initialization in sal failed, disconnecting from device", id, t);
+        LOG.error("{}: Initialization in sal failed, disconnecting from device", id, t);
         listener.close();
         onRemoteSessionDown();
         resetMessageTransformer();
@@ -325,16 +325,16 @@ public final class NetconfDevice implements RemoteDevice<NetconfSessionPreferenc
         @Override
         public DeviceSources call() throws Exception {
             final NetconfStateSchemas availableSchemas = stateSchemasResolver.resolve(deviceRpc, remoteSessionCapabilities, id);
-            logger.debug("{}: Schemas exposed by ietf-netconf-monitoring: {}", id, availableSchemas.getAvailableYangSchemasQNames());
+            LOG.debug("{}: Schemas exposed by ietf-netconf-monitoring: {}", id, availableSchemas.getAvailableYangSchemasQNames());
 
             final Set<QName> requiredSources = Sets.newHashSet(remoteSessionCapabilities.getModuleBasedCaps());
             final Set<QName> providedSources = availableSchemas.getAvailableYangSchemasQNames();
 
             final Set<QName> requiredSourcesNotProvided = Sets.difference(requiredSources, providedSources);
             if (!requiredSourcesNotProvided.isEmpty()) {
-                logger.warn("{}: Netconf device does not provide all yang models reported in hello message capabilities, required but not provided: {}",
+                LOG.warn("{}: Netconf device does not provide all yang models reported in hello message capabilities, required but not provided: {}",
                         id, requiredSourcesNotProvided);
-                logger.warn("{}: Attempting to build schema context from required sources", id);
+                LOG.warn("{}: Attempting to build schema context from required sources", id);
             }
 
             // Here all the sources reported in netconf monitoring are merged with those reported in hello.
@@ -343,10 +343,10 @@ public final class NetconfDevice implements RemoteDevice<NetconfSessionPreferenc
             // and as a result one is not able to fully override yang models of a device. It is only possible to add additional models.
             final Set<QName> providedSourcesNotRequired = Sets.difference(providedSources, requiredSources);
             if (!providedSourcesNotRequired.isEmpty()) {
-                logger.warn("{}: Netconf device provides additional yang models not reported in hello message capabilities: {}",
+                LOG.warn("{}: Netconf device provides additional yang models not reported in hello message capabilities: {}",
                         id, providedSourcesNotRequired);
-                logger.warn("{}: Adding provided but not required sources as required to prevent failures", id);
-                logger.debug("{}: Netconf device reported in hello: {}", id, requiredSources);
+                LOG.warn("{}: Adding provided but not required sources as required to prevent failures", id);
+                LOG.debug("{}: Netconf device reported in hello: {}", id, requiredSources);
                 requiredSources.addAll(providedSourcesNotRequired);
             }
 
@@ -410,7 +410,7 @@ public final class NetconfDevice implements RemoteDevice<NetconfSessionPreferenc
          */
         // FIXME reimplement without recursion
         private void setUpSchema(final Collection<SourceIdentifier> requiredSources) {
-            logger.trace("{}: Trying to build schema context from {}", id, requiredSources);
+            LOG.trace("{}: Trying to build schema context from {}", id, requiredSources);
 
             // If no more sources, fail
             if(requiredSources.isEmpty()) {
@@ -426,7 +426,7 @@ public final class NetconfDevice implements RemoteDevice<NetconfSessionPreferenc
 
                 @Override
                 public void onSuccess(final SchemaContext result) {
-                    logger.debug("{}: Schema context built successfully from {}", id, requiredSources);
+                    LOG.debug("{}: Schema context built successfully from {}", id, requiredSources);
                     final Collection<QName> filteredQNames = Sets.difference(deviceSources.getProvidedSourcesQName(), capabilities.getUnresolvedCapabilites().keySet());
                     capabilities.addCapabilities(filteredQNames);
                     capabilities.addNonModuleBasedCapabilities(remoteSessionCapabilities.getNonModuleCaps());
@@ -438,7 +438,7 @@ public final class NetconfDevice implements RemoteDevice<NetconfSessionPreferenc
                     // In case source missing, try without it
                     if (t instanceof MissingSchemaSourceException) {
                         final SourceIdentifier missingSource = ((MissingSchemaSourceException) t).getSourceId();
-                        logger.warn("{}: Unable to build schema context, missing source {}, will reattempt without it", id, missingSource);
+                        LOG.warn("{}: Unable to build schema context, missing source {}, will reattempt without it", id, missingSource);
                         capabilities.addUnresolvedCapabilities(getQNameFromSourceIdentifiers(Sets.newHashSet(missingSource)), UnavailableCapability.FailureReason.MissingSource);
                         setUpSchema(stripMissingSource(requiredSources, missingSource));
 
@@ -448,7 +448,7 @@ public final class NetconfDevice implements RemoteDevice<NetconfSessionPreferenc
                         final SchemaResolutionException resolutionException = (SchemaResolutionException) t;
                         final Set<SourceIdentifier> unresolvedSources = resolutionException.getUnsatisfiedImports().keySet();
                         capabilities.addUnresolvedCapabilities(getQNameFromSourceIdentifiers(unresolvedSources), UnavailableCapability.FailureReason.UnableToResolve);
-                        logger.warn("{}: Unable to build schema context, unsatisfied imports {}, will reattempt with resolved only", id, resolutionException.getUnsatisfiedImports());
+                        LOG.warn("{}: Unable to build schema context, unsatisfied imports {}, will reattempt with resolved only", id, resolutionException.getUnsatisfiedImports());
                         setUpSchema(resolutionException.getResolvedSources());
                     // unknown error, fail
                     } else {
@@ -480,7 +480,7 @@ public final class NetconfDevice implements RemoteDevice<NetconfSessionPreferenc
             });
 
             if (qNames.isEmpty()) {
-                logger.debug("Unable to map any source identfiers to a capability reported by device : " + identifiers);
+                LOG.debug("{}: Unable to map any source identfiers to a capability reported by device : {}", id, identifiers);
             }
             return qNames;
         }