Fix checkstyle warnings in netconf-netty-util 62/12862/5
authorMarian Dubai <mdubai@cisco.com>
Fri, 14 Nov 2014 14:52:51 +0000 (15:52 +0100)
committerMarian Dubai <mdubai@cisco.com>
Thu, 27 Nov 2014 09:18:27 +0000 (10:18 +0100)
Change-Id: I123c7cbff15c1267a1bdb537e100c1bf2f9894d7
Signed-off-by: Marian Dubai <mdubai@cisco.com>
18 files changed:
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/AbstractNetconfSession.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/AbstractNetconfSessionNegotiator.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ChunkedFramingMechanismEncoder.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/EOMFramingMechanismEncoder.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/FramingMechanismHandlerFactory.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfChunkAggregator.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfEXIToMessageDecoder.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfHelloMessageToXMLEncoder.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfMessageToXMLEncoder.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfXMLToHelloMessageDecoder.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/exi/EXIParameters.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/AsyncSshHandler.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerReader.java
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java
opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfEXIHandlersTest.java
opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/exi/EXIParametersTest.java
opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/exi/NetconfStartExiMessageTest.java
opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerTest.java

index e0799d3a2aff8e006032bcec24c96146e7a35ae7..4eaeee9d78bf09c9dc8ef554de7745bf427d453a 100644 (file)
@@ -26,7 +26,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public abstract class AbstractNetconfSession<S extends NetconfSession, L extends NetconfSessionListener<S>> extends AbstractProtocolSession<NetconfMessage> implements NetconfSession, NetconfExiSession {
-    private static final Logger logger = LoggerFactory.getLogger(AbstractNetconfSession.class);
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractNetconfSession.class);
     private final L sessionListener;
     private final long sessionId;
     private boolean up = false;
@@ -39,7 +39,7 @@ public abstract class AbstractNetconfSession<S extends NetconfSession, L extends
         this.sessionListener = sessionListener;
         this.channel = channel;
         this.sessionId = sessionId;
-        logger.debug("Session {} created", sessionId);
+        LOG.debug("Session {} created", sessionId);
     }
 
     protected abstract S thisInstance();
@@ -53,7 +53,7 @@ public abstract class AbstractNetconfSession<S extends NetconfSession, L extends
 
     @Override
     protected void handleMessage(final NetconfMessage netconfMessage) {
-        logger.debug("handling incoming message");
+        LOG.debug("handling incoming message");
         sessionListener.onMessage(thisInstance(), netconfMessage);
     }
 
@@ -61,8 +61,8 @@ public abstract class AbstractNetconfSession<S extends NetconfSession, L extends
     public ChannelFuture sendMessage(final NetconfMessage netconfMessage) {
         final ChannelFuture future = channel.writeAndFlush(netconfMessage);
         if (delayedEncoder != null) {
-                replaceMessageEncoder(delayedEncoder);
-                delayedEncoder = null;
+            replaceMessageEncoder(delayedEncoder);
+            delayedEncoder = null;
         }
 
         return future;
@@ -70,7 +70,7 @@ public abstract class AbstractNetconfSession<S extends NetconfSession, L extends
 
     @Override
     protected void endOfInput() {
-        logger.debug("Session {} end of input detected while session was in state {}", toString(), isUp() ? "up"
+        LOG.debug("Session {} end of input detected while session was in state {}", toString(), isUp() ? "up"
                 : "initialized");
         if (isUp()) {
             this.sessionListener.onSessionDown(thisInstance(), new IOException("End of input detected. Close the session."));
@@ -79,7 +79,7 @@ public abstract class AbstractNetconfSession<S extends NetconfSession, L extends
 
     @Override
     protected void sessionUp() {
-        logger.debug("Session {} up", toString());
+        LOG.debug("Session {} up", toString());
         sessionListener.onSessionUp(thisInstance());
         this.up = true;
     }
@@ -114,12 +114,12 @@ public abstract class AbstractNetconfSession<S extends NetconfSession, L extends
         try {
             exiParams = EXIParameters.fromXmlElement(XmlElement.fromDomDocument(startExiMessage.getDocument()));
         } catch (final EXIOptionsException e) {
-            logger.warn("Unable to parse EXI parameters from {} om session {}", XmlUtil.toString(startExiMessage.getDocument()), this, e);
+            LOG.warn("Unable to parse EXI parameters from {} om session {}", XmlUtil.toString(startExiMessage.getDocument()), this, e);
             throw new IllegalArgumentException(e);
         }
         final NetconfEXICodec exiCodec = new NetconfEXICodec(exiParams.getOptions());
         addExiHandlers(exiCodec);
-        logger.debug("Session {} EXI handlers added to pipeline", this);
+        LOG.debug("Session {} EXI handlers added to pipeline", this);
     }
 
     protected abstract void addExiHandlers(NetconfEXICodec exiCodec);
index de3f732b25763fa19d6b481a64bfbcf4d8bcf87c..e5c3c12b992246516165e94f1f0dbb48de3ddefd 100644 (file)
@@ -42,9 +42,9 @@ import org.w3c.dom.Document;
 import org.w3c.dom.NodeList;
 
 public abstract class AbstractNetconfSessionNegotiator<P extends NetconfSessionPreferences, S extends AbstractNetconfSession<S, L>, L extends NetconfSessionListener<S>>
-extends AbstractSessionNegotiator<NetconfHelloMessage, S> {
+    extends AbstractSessionNegotiator<NetconfHelloMessage, S> {
 
-    private static final Logger logger = LoggerFactory.getLogger(AbstractNetconfSessionNegotiator.class);
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractNetconfSessionNegotiator.class);
 
     public static final String NAME_OF_EXCEPTION_HANDLER = "lastExceptionHandler";
 
@@ -85,7 +85,7 @@ extends AbstractSessionNegotiator<NetconfHelloMessage, S> {
                 @Override
                 public void operationComplete(Future<? super Channel> future) {
                     Preconditions.checkState(future.isSuccess(), "Ssl handshake was not successful");
-                    logger.debug("Ssl handshake complete");
+                    LOG.debug("Ssl handshake complete");
                     start();
                 }
             });
@@ -105,7 +105,7 @@ extends AbstractSessionNegotiator<NetconfHelloMessage, S> {
 
     private void start() {
         final NetconfMessage helloMessage = this.sessionPreferences.getHelloMessage();
-        logger.debug("Session negotiation started with hello message {} on channel {}", XmlUtil.toString(helloMessage.getDocument()), channel);
+        LOG.debug("Session negotiation started with hello message {} on channel {}", XmlUtil.toString(helloMessage.getDocument()), channel);
 
         channel.pipeline().addLast(NAME_OF_EXCEPTION_HANDLER, new ExceptionHandlingInboundChannelHandler());
 
@@ -121,7 +121,7 @@ extends AbstractSessionNegotiator<NetconfHelloMessage, S> {
                 synchronized (this) {
                     if (state != State.ESTABLISHED) {
 
-                        logger.debug("Connection timeout after {}, session is in state {}", timeout, state);
+                        LOG.debug("Connection timeout after {}, session is in state {}", timeout, state);
 
                         // Do not fail negotiation if promise is done or canceled
                         // It would result in setting result of the promise second time and that throws exception
@@ -133,9 +133,9 @@ extends AbstractSessionNegotiator<NetconfHelloMessage, S> {
                                 @Override
                                 public void operationComplete(ChannelFuture future) throws Exception {
                                     if(future.isSuccess()) {
-                                        logger.debug("Channel {} closed: success", future.channel());
+                                        LOG.debug("Channel {} closed: success", future.channel());
                                     } else {
-                                        logger.warn("Channel {} closed: fail", future.channel());
+                                        LOG.warn("Channel {} closed: fail", future.channel());
                                     }
                                 }
                             });
@@ -223,7 +223,7 @@ extends AbstractSessionNegotiator<NetconfHelloMessage, S> {
     protected abstract S getSession(L sessionListener, Channel channel, NetconfHelloMessage message) throws NetconfDocumentedException;
 
     private synchronized void changeState(final State newState) {
-        logger.debug("Changing state from : {} to : {} for channel: {}", state, newState, channel);
+        LOG.debug("Changing state from : {} to : {} for channel: {}", state, newState, channel);
         Preconditions.checkState(isStateChangePermitted(state, newState), "Cannot change state from %s to %s for chanel %s", state,
                 newState, channel);
         this.state = newState;
@@ -249,7 +249,7 @@ extends AbstractSessionNegotiator<NetconfHelloMessage, S> {
         if (state == State.OPEN_WAIT && newState == State.FAILED) {
             return true;
         }
-        logger.debug("Transition from {} to {} is not allowed", state, newState);
+        LOG.debug("Transition from {} to {} is not allowed", state, newState);
         return false;
     }
 
@@ -259,7 +259,7 @@ extends AbstractSessionNegotiator<NetconfHelloMessage, S> {
     private final class ExceptionHandlingInboundChannelHandler extends ChannelInboundHandlerAdapter {
         @Override
         public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
-            logger.warn("An exception occurred during negotiation with {}", channel.remoteAddress(), cause);
+            LOG.warn("An exception occurred during negotiation with {}", channel.remoteAddress(), cause);
             cancelTimeout();
             negotiationFailed(cause);
             changeState(State.FAILED);
index a66e45882fda1f8397134a68060769c32cd4bc24..c4cddb802ea35dd51b17d49d832114c404ae5085 100644 (file)
@@ -8,16 +8,14 @@
 
 package org.opendaylight.controller.netconf.nettyutil.handler;
 
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.MessageToByteEncoder;
-
 import org.opendaylight.controller.netconf.util.messages.NetconfMessageConstants;
 import org.opendaylight.controller.netconf.util.messages.NetconfMessageHeader;
 
-import com.google.common.base.Preconditions;
-
 public class ChunkedFramingMechanismEncoder extends MessageToByteEncoder<ByteBuf> {
     public static final int DEFAULT_CHUNK_SIZE = 8192;
     public static final int MIN_CHUNK_SIZE = 128;
index 92d8f12c1adf08576d696a1d766955865a7e1a43..514b2e129eb7f8eb6df5a704a6b4ce30bf39e8b0 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.controller.netconf.nettyutil.handler;
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.MessageToByteEncoder;
-
 import org.opendaylight.controller.netconf.util.messages.NetconfMessageConstants;
 
 public class EOMFramingMechanismEncoder extends MessageToByteEncoder<ByteBuf> {
index 35f7679496259f0b3b46267ad5b2ded0a69511ff..30589daa22ac65ab9724c3a842f815613f7c75d5 100644 (file)
@@ -8,23 +8,22 @@
 
 package org.opendaylight.controller.netconf.nettyutil.handler;
 
+import io.netty.buffer.ByteBuf;
+import io.netty.handler.codec.MessageToByteEncoder;
 import org.opendaylight.controller.netconf.util.messages.FramingMechanism;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import io.netty.buffer.ByteBuf;
-import io.netty.handler.codec.MessageToByteEncoder;
-
 public final class FramingMechanismHandlerFactory {
 
-    private static final Logger logger = LoggerFactory.getLogger(FramingMechanismHandlerFactory.class);
+    private static final Logger LOG = LoggerFactory.getLogger(FramingMechanismHandlerFactory.class);
 
     private FramingMechanismHandlerFactory() {
         // not called - private constructor for utility class
     }
 
     public static MessageToByteEncoder<ByteBuf> createHandler(FramingMechanism framingMechanism) {
-        logger.debug("{} framing mechanism was selected.", framingMechanism);
+        LOG.debug("{} framing mechanism was selected.", framingMechanism);
         if (framingMechanism == FramingMechanism.EOM) {
             return new EOMFramingMechanismEncoder();
         } else {
index e2a745f3fb876ba296b835210ec10486d5c5d86d..6a7b752023fef30717e1067d57d029ea7c6eee2f 100644 (file)
@@ -8,19 +8,17 @@
 
 package org.opendaylight.controller.netconf.nettyutil.handler;
 
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.CompositeByteBuf;
 import io.netty.buffer.Unpooled;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.ByteToMessageDecoder;
+import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class NetconfChunkAggregator extends ByteToMessageDecoder {
-    private final static Logger logger = LoggerFactory.getLogger(NetconfChunkAggregator.class);
+    private final static Logger LOG = LoggerFactory.getLogger(NetconfChunkAggregator.class);
     private static final String GOT_PARAM_WHILE_WAITING_FOR_PARAM = "Got byte {} while waiting for {}";
     private static final String GOT_PARAM_WHILE_WAITING_FOR_PARAM_PARAM = "Got byte {} while waiting for {}-{}";
     public static final int DEFAULT_MAXIMUM_CHUNK_SIZE = 16 * 1024 * 1024;
@@ -44,21 +42,21 @@ public class NetconfChunkAggregator extends ByteToMessageDecoder {
 
     private void checkNewLine(byte b,String errorMessage){
         if (b != '\n') {
-            logger.debug(GOT_PARAM_WHILE_WAITING_FOR_PARAM, b, (byte)'\n');
+            LOG.debug(GOT_PARAM_WHILE_WAITING_FOR_PARAM, b, (byte)'\n');
             throw new IllegalStateException(errorMessage);
         }
     }
 
     private void checkHash(byte b,String errorMessage){
         if (b != '#') {
-            logger.debug(GOT_PARAM_WHILE_WAITING_FOR_PARAM, b, (byte)'#');
+            LOG.debug(GOT_PARAM_WHILE_WAITING_FOR_PARAM, b, (byte)'#');
             throw new IllegalStateException(errorMessage);
         }
     }
 
     private void checkChunkSize(){
         if (chunkSize > maxChunkSize) {
-            logger.debug("Parsed chunk size {}, maximum allowed is {}", chunkSize, maxChunkSize);
+            LOG.debug("Parsed chunk size {}, maximum allowed is {}", chunkSize, maxChunkSize);
             throw new IllegalStateException("Maximum chunk size exceeded");
         }
 
@@ -101,7 +99,7 @@ public class NetconfChunkAggregator extends ByteToMessageDecoder {
                 }
 
                 if (b < '0' || b > '9') {
-                    logger.debug(GOT_PARAM_WHILE_WAITING_FOR_PARAM_PARAM, b, (byte)'0', (byte)'9');
+                    LOG.debug(GOT_PARAM_WHILE_WAITING_FOR_PARAM_PARAM, b, (byte)'0', (byte)'9');
                     throw new IllegalStateException("Invalid chunk size encountered");
                 }
 
@@ -118,7 +116,7 @@ public class NetconfChunkAggregator extends ByteToMessageDecoder {
                  *        comes through.
                  */
                 if (in.readableBytes() < chunkSize) {
-                    logger.debug("Buffer has {} bytes, need {} to complete chunk", in.readableBytes(), chunkSize);
+                    LOG.debug("Buffer has {} bytes, need {} to complete chunk", in.readableBytes(), chunkSize);
                     in.discardReadBytes();
                     return;
                 }
@@ -175,7 +173,7 @@ public class NetconfChunkAggregator extends ByteToMessageDecoder {
         } else if (b == '#') {
             state = State.FOOTER_FOUR;
         } else {
-            logger.debug(GOT_PARAM_WHILE_WAITING_FOR_PARAM_PARAM, b, (byte) '#', (byte) '1', (byte) '9');
+            LOG.debug(GOT_PARAM_WHILE_WAITING_FOR_PARAM_PARAM, b, (byte) '#', (byte) '1', (byte) '9');
             throw new IllegalStateException("Malformed chunk footer encountered (byte 2)");
         }
     }
@@ -193,7 +191,7 @@ public class NetconfChunkAggregator extends ByteToMessageDecoder {
 
     private static int processHeaderLengthFirst(byte b) {
         if (!isHeaderLengthFirst(b)) {
-            logger.debug(GOT_PARAM_WHILE_WAITING_FOR_PARAM_PARAM, b, (byte)'1', (byte)'9');
+            LOG.debug(GOT_PARAM_WHILE_WAITING_FOR_PARAM_PARAM, b, (byte)'1', (byte)'9');
             throw new IllegalStateException("Invalid chunk size encountered (byte 0)");
         }
 
index 57134af3c74f213884ca701109b8454d0d1b32df..db3dcafbdef93eb4a007fb4e1189daa1ad9e3957 100644 (file)
@@ -7,14 +7,18 @@
  */
 package org.opendaylight.controller.netconf.nettyutil.handler;
 
+import com.google.common.base.Preconditions;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufInputStream;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
 import java.io.InputStream;
 import java.util.List;
-
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.sax.SAXTransformerFactory;
 import javax.xml.transform.sax.TransformerHandler;
-
 import org.opendaylight.controller.netconf.api.NetconfMessage;
 import org.openexi.sax.EXIReader;
 import org.slf4j.Logger;
@@ -22,14 +26,6 @@ import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
 
-import com.google.common.base.Preconditions;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.ByteBufInputStream;
-import io.netty.buffer.ByteBufUtil;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.ByteToMessageDecoder;
-
 public final class NetconfEXIToMessageDecoder extends ByteToMessageDecoder {
 
     private static final Logger LOG = LoggerFactory.getLogger(NetconfEXIToMessageDecoder.class);
@@ -60,7 +56,7 @@ public final class NetconfEXIToMessageDecoder extends ByteToMessageDecoder {
         final EXIReader r = codec.getReader();
 
         final SAXTransformerFactory transformerFactory
-                = (SAXTransformerFactory) TransformerFactory.newInstance();
+            = (SAXTransformerFactory) TransformerFactory.newInstance();
         final TransformerHandler handler = transformerFactory.newTransformerHandler();
         r.setContentHandler(handler);
 
index f39e2c425d039cca549fd574607c52af02eced9e..8af5cf3ff4fd7d7b2d1eb45cb1da4f4d7e220028 100644 (file)
@@ -7,22 +7,18 @@
  */
 package org.opendaylight.controller.netconf.nettyutil.handler;
 
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Charsets;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
-
 import java.io.IOException;
-
 import javax.xml.transform.TransformerException;
-
 import org.opendaylight.controller.netconf.api.NetconfMessage;
 import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessage;
 import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
 
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-
 /**
  * Customized NetconfMessageToXMLEncoder that serializes additional header with
  * session metadata along with
index d810a870ff29f68b59b19788bf3064e0218cb148..8ce9411cbd9c00ecf31639301454ac1f871b3179 100644 (file)
@@ -7,32 +7,28 @@
  */
 package org.opendaylight.controller.netconf.nettyutil.handler;
 
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufOutputStream;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.MessageToByteEncoder;
-
 import java.io.BufferedWriter;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
-
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
-
 import org.opendaylight.controller.netconf.api.NetconfMessage;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Comment;
 
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
-
 public class NetconfMessageToXMLEncoder extends MessageToByteEncoder<NetconfMessage> {
     private static final Logger LOG = LoggerFactory.getLogger(NetconfMessageToXMLEncoder.class);
     private static final TransformerFactory FACTORY = TransformerFactory.newInstance();
index efe4861577b0ce3173a182d8005f37e186242ae8..197ae5f424469b453c9fe5c789181a55fd776628 100644 (file)
@@ -7,19 +7,20 @@
  */
 package org.opendaylight.controller.netconf.nettyutil.handler;
 
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Charsets;
 import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufUtil;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.ByteToMessageDecoder;
-
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Arrays;
 import java.util.List;
-
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
 import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessage;
@@ -28,10 +29,6 @@ import org.opendaylight.controller.netconf.util.xml.XmlUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
-import com.google.common.collect.ImmutableList;
 import org.xml.sax.SAXException;
 
 /**
index ccd7dead9f1a9a782743d423650fd5153005e1eb..859006877486292258f77409dbbdb3e48d826903 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.netconf.nettyutil.handler.exi;
 
+import com.google.common.base.Preconditions;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
 import org.openexi.proc.common.AlignmentType;
 import org.openexi.proc.common.EXIOptions;
@@ -14,8 +15,6 @@ import org.openexi.proc.common.EXIOptionsException;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 
-import com.google.common.base.Preconditions;
-
 public final class EXIParameters {
     private static final String EXI_PARAMETER_ALIGNMENT = "alignment";
     static final String EXI_PARAMETER_BYTE_ALIGNED = "byte-aligned";
index fa7d0900edc805ebd45f3b2edce8a21d46cfb031..14d753f1f8b59c25a7ea871e3bfe5e430c1d9970 100644 (file)
@@ -8,9 +8,13 @@
 
 package org.opendaylight.controller.netconf.nettyutil.handler.ssh.client;
 
+import com.google.common.base.Preconditions;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelOutboundHandlerAdapter;
+import io.netty.channel.ChannelPromise;
 import java.io.IOException;
 import java.net.SocketAddress;
-
 import org.apache.sshd.ClientChannel;
 import org.apache.sshd.ClientSession;
 import org.apache.sshd.SshClient;
@@ -23,19 +27,12 @@ import org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication.
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelOutboundHandlerAdapter;
-import io.netty.channel.ChannelPromise;
-
 /**
  * Netty SSH handler class. Acts as interface between Netty and SSH library.
  */
 public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
 
-    private static final Logger logger = LoggerFactory.getLogger(AsyncSshHandler.class);
+    private static final Logger LOG = LoggerFactory.getLogger(AsyncSshHandler.class);
     public static final String SUBSYSTEM = "netconf";
 
     public static final SshClient DEFAULT_CLIENT = SshClient.setUpDefaultClient();
@@ -77,7 +74,7 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
     }
 
     private void startSsh(final ChannelHandlerContext ctx, final SocketAddress address) {
-        logger.debug("Starting SSH to {} on channel: {}", address, ctx.channel());
+        LOG.debug("Starting SSH to {} on channel: {}", address, ctx.channel());
 
         final ConnectFuture sshConnectionFuture = sshClient.connect(authenticationHandler.getUsername(), address);
         sshConnectionFuture.addListener(new SshFutureListener<ConnectFuture>() {
@@ -94,7 +91,7 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
 
     private synchronized void handleSshSessionCreated(final ConnectFuture future, final ChannelHandlerContext ctx) {
         try {
-            logger.trace("SSH session created on channel: {}", ctx.channel());
+            LOG.trace("SSH session created on channel: {}", ctx.channel());
 
             session = future.getSession();
             final AuthFuture authenticateFuture = authenticationHandler.authenticate(session);
@@ -115,7 +112,7 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
 
     private synchronized void handleSshAuthenticated(final ClientSession session, final ChannelHandlerContext ctx) {
         try {
-            logger.debug("SSH session authenticated on channel: {}, server version: {}", ctx.channel(), session.getServerVersion());
+            LOG.debug("SSH session authenticated on channel: {}, server version: {}", ctx.channel(), session.getServerVersion());
 
             channel = session.createSubsystemChannel(SUBSYSTEM);
             channel.setStreaming(ClientChannel.Streaming.Async);
@@ -137,7 +134,7 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
     }
 
     private synchronized void handleSshChanelOpened(final ChannelHandlerContext ctx) {
-        logger.trace("SSH subsystem channel opened successfully on channel: {}", ctx.channel());
+        LOG.trace("SSH subsystem channel opened successfully on channel: {}", ctx.channel());
 
         connectPromise.setSuccess();
         connectPromise = null;
@@ -164,7 +161,7 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
     }
 
     private synchronized void handleSshSetupFailure(final ChannelHandlerContext ctx, final Throwable e) {
-        logger.warn("Unable to setup SSH connection on channel: {}", ctx.channel(), e);
+        LOG.warn("Unable to setup SSH connection on channel: {}", ctx.channel(), e);
         connectPromise.setFailure(e);
         connectPromise = null;
         throw new IllegalStateException("Unable to setup SSH connection on channel: " + ctx.channel(), e);
@@ -211,7 +208,7 @@ public class AsyncSshHandler extends ChannelOutboundHandlerAdapter {
         channel = null;
         promise.setSuccess();
 
-        logger.debug("SSH session closed on channel: {}", ctx.channel());
+        LOG.debug("SSH session closed on channel: {}", ctx.channel());
         ctx.fireChannelInactive();
     }
 
index ada15583cdef9cc86eb6a6d3b45bcf8f9be8defc..ca212e7c4739b1ce66ebc122c07d955c6e82d730 100644 (file)
@@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
  */
 public final class AsyncSshHandlerReader implements SshFutureListener<IoReadFuture>, AutoCloseable {
 
-    private static final Logger logger = LoggerFactory.getLogger(AsyncSshHandler.class);
+    private static final Logger LOG = LoggerFactory.getLogger(AsyncSshHandlerReader.class);
 
     private static final int BUFFER_SIZE = 8192;
 
@@ -49,9 +49,9 @@ public final class AsyncSshHandlerReader implements SshFutureListener<IoReadFutu
         if(future.getException() != null) {
             if(asyncOut.isClosed() || asyncOut.isClosing()) {
                 // Ssh dropped
-                logger.debug("Ssh session dropped on channel: {}", channelId, future.getException());
+                LOG.debug("Ssh session dropped on channel: {}", channelId, future.getException());
             } else {
-                logger.warn("Exception while reading from SSH remote on channel {}", channelId, future.getException());
+                LOG.warn("Exception while reading from SSH remote on channel {}", channelId, future.getException());
             }
             invokeDisconnect();
             return;
@@ -59,8 +59,8 @@ public final class AsyncSshHandlerReader implements SshFutureListener<IoReadFutu
 
         if (future.getRead() > 0) {
             final ByteBuf msg = Unpooled.wrappedBuffer(buf.array(), 0, future.getRead());
-            if(logger.isTraceEnabled()) {
-                logger.trace("Reading message on channel: {}, message: {}", channelId, AsyncSshHandlerWriter.byteBufToString(msg));
+            if(LOG.isTraceEnabled()) {
+                LOG.trace("Reading message on channel: {}, message: {}", channelId, AsyncSshHandlerWriter.byteBufToString(msg));
             }
             readHandler.onMessageRead(msg);
 
index 8e639bd47cc1b24e18176e365d50df2d3185ae5c..1e976ce6a1394c31e0bbd8dd8746463193a3ac5c 100644 (file)
@@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory;
  */
 public final class AsyncSshHandlerWriter implements AutoCloseable {
 
-    private static final Logger logger = LoggerFactory
+    private static final Logger LOG = LoggerFactory
             .getLogger(AsyncSshHandlerWriter.class);
 
     // public static final int MAX_PENDING_WRITES = 1000;
@@ -68,34 +68,34 @@ public final class AsyncSshHandlerWriter implements AutoCloseable {
 
     private void writeWithPendingDetection(final ChannelHandlerContext ctx, final ChannelPromise promise, final ByteBuf byteBufMsg) {
         try {
-            if (logger.isTraceEnabled()) {
-                logger.trace("Writing request on channel: {}, message: {}", ctx.channel(), byteBufToString(byteBufMsg));
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Writing request on channel: {}, message: {}", ctx.channel(), byteBufToString(byteBufMsg));
             }
             asyncIn.write(toBuffer(byteBufMsg)).addListener(new SshFutureListener<IoWriteFuture>() {
 
-                        @Override
-                        public void operationComplete(final IoWriteFuture future) {
-                            if (logger.isTraceEnabled()) {
-                                logger.trace("Ssh write request finished on channel: {} with result: {}: and ex:{}, message: {}",
+                @Override
+                public void operationComplete(final IoWriteFuture future) {
+                    if (LOG.isTraceEnabled()) {
+                        LOG.trace("Ssh write request finished on channel: {} with result: {}: and ex:{}, message: {}",
                                         ctx.channel(), future.isWritten(), future.getException(), byteBufToString(byteBufMsg));
-                            }
-
-                            // Notify success or failure
-                            if (future.isWritten()) {
-                                promise.setSuccess();
-                            } else {
-                                logger.warn("Ssh write request failed on channel: {} for message: {}", ctx.channel(), byteBufToString(byteBufMsg), future.getException());
-                                promise.setFailure(future.getException());
-                            }
-
-                            // Not needed anymore, release
-                            byteBufMsg.release();
-
-                            // Check pending queue and schedule next
-                            // At this time we are guaranteed that we are not in pending state anymore so the next request should succeed
-                            writePendingIfAny();
-                        }
-                    });
+                    }
+
+                    // Notify success or failure
+                    if (future.isWritten()) {
+                        promise.setSuccess();
+                    } else {
+                        LOG.warn("Ssh write request failed on channel: {} for message: {}", ctx.channel(), byteBufToString(byteBufMsg), future.getException());
+                        promise.setFailure(future.getException());
+                    }
+
+                    // Not needed anymore, release
+                    byteBufMsg.release();
+
+                    // Check pending queue and schedule next
+                    // At this time we are guaranteed that we are not in pending state anymore so the next request should succeed
+                    writePendingIfAny();
+                }
+            });
         } catch (final WritePendingException e) {
             queueRequest(ctx, byteBufMsg, promise);
         }
@@ -109,8 +109,8 @@ public final class AsyncSshHandlerWriter implements AutoCloseable {
         // In case of pending, reschedule next message from queue
         final PendingWriteRequest pendingWrite = pending.poll();
         final ByteBuf msg = pendingWrite.msg;
-        if (logger.isTraceEnabled()) {
-            logger.trace("Writing pending request on channel: {}, message: {}", pendingWrite.ctx.channel(), byteBufToString(msg));
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("Writing pending request on channel: {}, message: {}", pendingWrite.ctx.channel(), byteBufToString(msg));
         }
 
         writeWithPendingDetection(pendingWrite.ctx, pendingWrite.promise, msg);
@@ -125,13 +125,13 @@ public final class AsyncSshHandlerWriter implements AutoCloseable {
 
     private void queueRequest(final ChannelHandlerContext ctx, final ByteBuf msg, final ChannelPromise promise) {
 //        try {
-        logger.debug("Write pending on channel: {}, queueing, current queue size: {}", ctx.channel(), pending.size());
-        if (logger.isTraceEnabled()) {
-            logger.trace("Queueing request due to pending: {}", byteBufToString(msg));
+        LOG.debug("Write pending on channel: {}, queueing, current queue size: {}", ctx.channel(), pending.size());
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("Queueing request due to pending: {}", byteBufToString(msg));
         }
         new PendingWriteRequest(ctx, msg, promise).pend(pending);
 //        } catch (final Exception ex) {
-//            logger.warn("Unable to queue write request on channel: {}. Setting fail for the request: {}", ctx.channel(), ex, byteBufToString(msg));
+//            LOG.warn("Unable to queue write request on channel: {}. Setting fail for the request: {}", ctx.channel(), ex, byteBufToString(msg));
 //            msg.release();
 //            promise.setFailure(ex);
 //        }
index 8bc0fb8e8242efcc640ea4a1b1ffc4a9f88818f6..4f804abfe8e4478fffb89b69e817afc1157665d0 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.netconf.nettyutil.handler;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+
 import com.google.common.collect.Lists;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
index 15ba3b41f8443aefa99a40fbca7de84267777626..70186f39a45b71fcb0c2e472c71862c97ce174c8 100644 (file)
@@ -51,8 +51,8 @@ public class EXIParametersTest {
         fullOptions.setPreservePIs(true);
 
         return Arrays.asList(new Object[][]{
-                {noChangeXml, new EXIOptions()},
-                {fullOptionsXml, fullOptions},
+            {noChangeXml, new EXIOptions()},
+            {fullOptionsXml, fullOptions},
         });
     }
 
index 47abe96687540969174d50d7ced6affc4c3b3f0e..9d831729fced6a5341fb3f5d1793624bf73ce1a7 100644 (file)
@@ -53,8 +53,8 @@ public class NetconfStartExiMessageTest {
         fullOptions.setPreservePIs(true);
 
         return Arrays.asList(new Object[][]{
-                {noChangeXml, new EXIOptions()},
-                {fullOptionsXml, fullOptions},
+            {noChangeXml, new EXIOptions()},
+            {fullOptionsXml, fullOptions},
         });
     }
 
index b4c9e1e95083dd94b21d57318ef989dca355bdd2..73f2287c8bce6151b9dd33f8fa0bc7ed8d39ac40 100644 (file)
@@ -22,6 +22,7 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.verifyZeroInteractions;
+
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;