Replace logger and log by LOG 18/58018/3
authorDavid Suarez <david.suarez.fuentes@ericsson.com>
Tue, 30 May 2017 19:11:21 +0000 (21:11 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Thu, 1 Jun 2017 12:52:33 +0000 (12:52 +0000)
Replace logger and log by LOG to follow the
OpenDaylight recommendations [1].

[1]
https://wiki.opendaylight.org/view/BestPractices/Logging_Best_Practices

Change-Id: I63787ccee5950bebbc8c3769885574593a666809
Signed-off-by: David Suarez <david.suarez.fuentes@ericsson.com>
15 files changed:
opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/BitBufferHelper.java
opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/LLDP.java
opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/NetUtils.java
opendaylight/commons/liblldp/src/main/java/org/opendaylight/controller/liblldp/Packet.java
opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/Session.java
opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleDispatcher.java
opendaylight/commons/protocol-framework/src/test/java/org/opendaylight/protocol/framework/SimpleSessionListener.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorContextImplTest.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/SingletonHolder.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerPerformanceTest.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/listener/PeopleCarListener.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PeopleProvider.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/PurchaseCarProvider.java

index c2fa6c38d07eadc191bf640dbf72381d74e44ec3..a184d40d1ee96ed5d3986b3ffb3872fb76a269f0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -17,15 +17,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * BitBufferHelper class that provides utility methods to
- * - fetch specific bits from a serialized stream of bits
- * - convert bits to primitive data type - like short, int, long
- * - store bits in specified location in stream of bits
- * - convert primitive data types to stream of bits
+ * BitBufferHelper class that provides utility methods to - fetch specific bits
+ * from a serialized stream of bits - convert bits to primitive data type - like
+ * short, int, long - store bits in specified location in stream of bits -
+ * convert primitive data types to stream of bits.
  */
 public abstract class BitBufferHelper {
-    protected static final Logger logger = LoggerFactory
-    .getLogger(BitBufferHelper.class);
+    protected static final Logger LOG = LoggerFactory.getLogger(BitBufferHelper.class);
 
     public static final long ByteMask = 0xFF;
 
@@ -36,67 +34,67 @@ public abstract class BitBufferHelper {
     // All this function return an exception if overflow or underflow
 
     /**
-     * Returns the first byte from the byte array
+     * Returns the first byte from the byte array.
+     *
      * @return byte value
      */
     public static byte getByte(final byte[] data) {
-        if ((data.length * NetUtils.NumBitsInAByte) > Byte.SIZE) {
+        if (data.length * NetUtils.NumBitsInAByte > Byte.SIZE) {
             try {
-                throw new BufferException(
-                        "Container is too small for the number of requested bits");
+                throw new BufferException("Container is too small for the number of requested bits");
             } catch (final BufferException e) {
-                logger.error("", e);
+                LOG.error("", e);
             }
         }
-        return (data[0]);
+        return data[0];
     }
 
     /**
-     * Returns the short value for the byte array passed.
-     * Size of byte array is restricted to Short.SIZE
+     * Returns the short value for the byte array passed. Size of byte array is
+     * restricted to Short.SIZE
+     *
      * @return short value
      */
     public static short getShort(final byte[] data) {
         if (data.length > Short.SIZE) {
             try {
-                throw new BufferException(
-                        "Container is too small for the number of requested bits");
+                throw new BufferException("Container is too small for the number of requested bits");
             } catch (final BufferException e) {
-                logger.error("", e);
+                LOG.error("", e);
             }
         }
         return (short) toNumber(data);
     }
 
     /**
-     * Returns the int value for the byte array passed.
-     * Size of byte array is restricted to Integer.SIZE
+     * Returns the int value for the byte array passed. Size of byte array is
+     * restricted to Integer.SIZE
+     *
      * @return int - the integer value of byte array
      */
     public static int getInt(final byte[] data) {
         if (data.length > Integer.SIZE) {
             try {
-                throw new BufferException(
-                        "Container is too small for the number of requested bits");
+                throw new BufferException("Container is too small for the number of requested bits");
             } catch (final BufferException e) {
-                logger.error("", e);
+                LOG.error("", e);
             }
         }
         return (int) toNumber(data);
     }
 
     /**
-     * Returns the long value for the byte array passed.
-     * Size of byte array is restricted to Long.SIZE
+     * Returns the long value for the byte array passed. Size of byte array is
+     * restricted to Long.SIZE
+     *
      * @return long - the integer value of byte array
      */
     public static long getLong(final byte[] data) {
         if (data.length > Long.SIZE) {
             try {
-                throw new BufferException(
-                        "Container is too small for the number of requested bits");
+                throw new BufferException("Container is too small for the number of requested bits");
             } catch (final Exception e) {
-                logger.error("", e);
+                LOG.error("", e);
             }
         }
         return toNumber(data);
@@ -105,15 +103,15 @@ public abstract class BitBufferHelper {
     /**
      * Returns the short value for the last numBits of the byte array passed.
      * Size of numBits is restricted to Short.SIZE
+     *
      * @return short - the short value of byte array
      */
     public static short getShort(final byte[] data, final int numBits) {
         if (numBits > Short.SIZE) {
             try {
-                throw new BufferException(
-                        "Container is too small for the number of requested bits");
+                throw new BufferException("Container is too small for the number of requested bits");
             } catch (final BufferException e) {
-                logger.error("", e);
+                LOG.error("", e);
             }
         }
         int startOffset = data.length * NetUtils.NumBitsInAByte - numBits;
@@ -121,23 +119,23 @@ public abstract class BitBufferHelper {
         try {
             bits = BitBufferHelper.getBits(data, startOffset, numBits);
         } catch (final BufferException e) {
-            logger.error("", e);
+            LOG.error("", e);
         }
         return (short) toNumber(bits, numBits);
     }
 
     /**
-     * Returns the int value for the last numBits of the byte array passed.
-     * Size of numBits is restricted to Integer.SIZE
+     * Returns the int value for the last numBits of the byte array passed. Size
+     * of numBits is restricted to Integer.SIZE
+     *
      * @return int - the integer value of byte array
      */
     public static int getInt(final byte[] data, final int numBits) {
         if (numBits > Integer.SIZE) {
             try {
-                throw new BufferException(
-                        "Container is too small for the number of requested bits");
+                throw new BufferException("Container is too small for the number of requested bits");
             } catch (final BufferException e) {
-                logger.error("", e);
+                LOG.error("", e);
             }
         }
         int startOffset = data.length * NetUtils.NumBitsInAByte - numBits;
@@ -145,7 +143,7 @@ public abstract class BitBufferHelper {
         try {
             bits = BitBufferHelper.getBits(data, startOffset, numBits);
         } catch (final BufferException e) {
-            logger.error("", e);
+            LOG.error("", e);
         }
         return (int) toNumber(bits, numBits);
     }
@@ -153,23 +151,22 @@ public abstract class BitBufferHelper {
     /**
      * Returns the long value for the last numBits of the byte array passed.
      * Size of numBits is restricted to Long.SIZE
+     *
      * @return long - the integer value of byte array
      */
     public static long getLong(final byte[] data, final int numBits) {
         if (numBits > Long.SIZE) {
             try {
-                throw new BufferException(
-                        "Container is too small for the number of requested bits");
+                throw new BufferException("Container is too small for the number of requested bits");
             } catch (final BufferException e) {
-                logger.error("", e);
+                LOG.error("", e);
             }
         }
         if (numBits > data.length * NetUtils.NumBitsInAByte) {
             try {
-                throw new BufferException(
-                        "Trying to read more bits than contained in the data buffer");
+                throw new BufferException("Trying to read more bits than contained in the data buffer");
             } catch (final BufferException e) {
-                logger.error("", e);
+                LOG.error("", e);
             }
         }
         int startOffset = data.length * NetUtils.NumBitsInAByte - numBits;
@@ -177,41 +174,37 @@ public abstract class BitBufferHelper {
         try {
             bits = BitBufferHelper.getBits(data, startOffset, numBits);
         } catch (final BufferException e) {
-            logger.error("", e);
+            LOG.error("", e);
         }
         return toNumber(bits, numBits);
     }
 
     /**
-     * Reads the specified number of bits from the passed byte array
-     * starting to read from the specified offset
-     * The bits read are stored in a byte array which size is dictated
-     * by the number of bits to be stored.
-     * The bits are stored in the byte array LSB aligned.
+     * Reads the specified number of bits from the passed byte array starting to
+     * read from the specified offset The bits read are stored in a byte array
+     * which size is dictated by the number of bits to be stored. The bits are
+     * stored in the byte array LSB aligned.
      *
-     * Ex.
-     * Read 7 bits at offset 10
-     * 0         9 10     16 17
-     * 0101000010 | 0000101 | 1111001010010101011
-     * will be returned as {0,0,0,0,0,1,0,1}
+     * Ex. Read 7 bits at offset 10 0 9 10 16 17 0101000010 | 0000101 |
+     * 1111001010010101011 will be returned as {0,0,0,0,0,1,0,1}
      *
-     * @param startOffset - offset to start fetching bits from data from
-     * @param numBits - number of bits to be fetched from data
+     * @param startOffset
+     *            - offset to start fetching bits from data from
+     * @param numBits
+     *            - number of bits to be fetched from data
      * @return byte [] - LSB aligned bits
      *
      * @throws BufferException
      *             when the startOffset and numBits parameters are not congruent
      *             with the data buffer size
      */
-    public static byte[] getBits(final byte[] data, final int startOffset, final int numBits)
-            throws BufferException {
-
+    public static byte[] getBits(final byte[] data, final int startOffset, final int numBits) throws BufferException {
         int startByteOffset = 0;
         int valfromcurr, valfromnext;
         int extranumBits = numBits % NetUtils.NumBitsInAByte;
         int extraOffsetBits = startOffset % NetUtils.NumBitsInAByte;
-        int numBytes = (numBits % NetUtils.NumBitsInAByte != 0) ? 1 + numBits
-                / NetUtils.NumBitsInAByte : numBits / NetUtils.NumBitsInAByte;
+        int numBytes = numBits % NetUtils.NumBitsInAByte != 0 ? 1 + numBits / NetUtils.NumBitsInAByte
+                : numBits / NetUtils.NumBitsInAByte;
         byte[] shiftedBytes = new byte[numBytes];
         startByteOffset = startOffset / NetUtils.NumBitsInAByte;
         byte[] bytes = new byte[numBytes];
@@ -227,37 +220,31 @@ public abstract class BitBufferHelper {
                 return bytes;
             } else {
                 System.arraycopy(data, startByteOffset, bytes, 0, numBytes - 1);
-                bytes[numBytes - 1] = (byte) (data[startByteOffset
-                        + numBytes - 1] & getMSBMask(extranumBits));
+                bytes[numBytes - 1] = (byte) (data[startByteOffset + numBytes - 1] & getMSBMask(extranumBits));
             }
         } else {
             int i;
             for (i = 0; i < numBits / NetUtils.NumBitsInAByte; i++) {
                 // Reading numBytes starting from offset
-                valfromcurr = (data[startByteOffset + i])
-                        & getLSBMask(NetUtils.NumBitsInAByte - extraOffsetBits);
-                valfromnext = (data[startByteOffset + i + 1])
-                        & getMSBMask(extraOffsetBits);
-                bytes[i] = (byte) (valfromcurr << (extraOffsetBits) | (valfromnext >> (NetUtils.NumBitsInAByte - extraOffsetBits)));
+                valfromcurr = data[startByteOffset + i] & getLSBMask(NetUtils.NumBitsInAByte - extraOffsetBits);
+                valfromnext = data[startByteOffset + i + 1] & getMSBMask(extraOffsetBits);
+                bytes[i] = (byte) (valfromcurr << extraOffsetBits
+                        | valfromnext >> NetUtils.NumBitsInAByte - extraOffsetBits);
             }
             // Now adding the rest of the bits if any
             if (extranumBits != 0) {
-                if (extranumBits < (NetUtils.NumBitsInAByte - extraOffsetBits)) {
-                    valfromnext = (byte) (data[startByteOffset + i] & ((getMSBMask(extranumBits)) >> extraOffsetBits));
+                if (extranumBits < NetUtils.NumBitsInAByte - extraOffsetBits) {
+                    valfromnext = (byte) (data[startByteOffset + i] & getMSBMask(extranumBits) >> extraOffsetBits);
                     bytes[i] = (byte) (valfromnext << extraOffsetBits);
-                } else if (extranumBits == (NetUtils.NumBitsInAByte - extraOffsetBits)) {
-                    valfromcurr = (data[startByteOffset + i])
-                            & getLSBMask(NetUtils.NumBitsInAByte
-                                    - extraOffsetBits);
+                } else if (extranumBits == NetUtils.NumBitsInAByte - extraOffsetBits) {
+                    valfromcurr = data[startByteOffset + i] & getLSBMask(NetUtils.NumBitsInAByte - extraOffsetBits);
                     bytes[i] = (byte) (valfromcurr << extraOffsetBits);
                 } else {
-                    valfromcurr = (data[startByteOffset + i])
-                            & getLSBMask(NetUtils.NumBitsInAByte
-                                    - extraOffsetBits);
-                    valfromnext = (data[startByteOffset + i + 1])
-                            & (getMSBMask(extranumBits
-                                    - (NetUtils.NumBitsInAByte - extraOffsetBits)));
-                    bytes[i] = (byte) (valfromcurr << (extraOffsetBits) | (valfromnext >> (NetUtils.NumBitsInAByte - extraOffsetBits)));
+                    valfromcurr = data[startByteOffset + i] & getLSBMask(NetUtils.NumBitsInAByte - extraOffsetBits);
+                    valfromnext = data[startByteOffset + i + 1]
+                            & getMSBMask(extranumBits - (NetUtils.NumBitsInAByte - extraOffsetBits));
+                    bytes[i] = (byte) (valfromcurr << extraOffsetBits
+                            | valfromnext >> NetUtils.NumBitsInAByte - extraOffsetBits);
                 }
 
             }
@@ -275,17 +262,22 @@ public abstract class BitBufferHelper {
 
     /**
      * Bits are expected to be stored in the input byte array from LSB
-     * @param data to set the input byte
-     * @param input byte to be inserted
-     * @param startOffset offset of data[] to start inserting byte from
-     * @param numBits number of bits of input to be inserted into data[]
+     *
+     * @param data
+     *            to set the input byte
+     * @param input
+     *            byte to be inserted
+     * @param startOffset
+     *            offset of data[] to start inserting byte from
+     * @param numBits
+     *            number of bits of input to be inserted into data[]
      *
      * @throws BufferException
      *             when the input, startOffset and numBits are not congruent
      *             with the data buffer size
      */
-    public static void setByte(final byte[] data, final byte input, final int startOffset,
-            final int numBits) throws BufferException {
+    public static void setByte(final byte[] data, final byte input, final int startOffset, final int numBits)
+            throws BufferException {
         byte[] inputByteArray = new byte[1];
         Arrays.fill(inputByteArray, 0, 1, input);
         setBytes(data, inputByteArray, startOffset, numBits);
@@ -293,16 +285,21 @@ public abstract class BitBufferHelper {
 
     /**
      * Bits are expected to be stored in the input byte array from LSB
-     * @param data to set the input byte
-     * @param input bytes to be inserted
-     * @param startOffset offset of data[] to start inserting byte from
-     * @param numBits number of bits of input to be inserted into data[]
+     *
+     * @param data
+     *            to set the input byte
+     * @param input
+     *            bytes to be inserted
+     * @param startOffset
+     *            offset of data[] to start inserting byte from
+     * @param numBits
+     *            number of bits of input to be inserted into data[]
      * @throws BufferException
      *             when the startOffset and numBits parameters are not congruent
      *             with data and input buffers' size
      */
-    public static void setBytes(final byte[] data, final byte[] input, final int startOffset,
-            final int numBits) throws BufferException {
+    public static void setBytes(final byte[] data, final byte[] input, final int startOffset, final int numBits)
+            throws BufferException {
         checkExceptions(data, startOffset, numBits);
         insertBits(data, input, startOffset, numBits);
     }
@@ -313,7 +310,7 @@ public abstract class BitBufferHelper {
     public static int getMSBMask(final int numBits) {
         int mask = 0;
         for (int i = 0; i < numBits; i++) {
-            mask = mask | (1 << (7 - i));
+            mask = mask | 1 << 7 - i;
         }
         return mask;
     }
@@ -324,7 +321,7 @@ public abstract class BitBufferHelper {
     public static int getLSBMask(final int numBits) {
         int mask = 0;
         for (int i = 0; i < numBits; i++) {
-            mask = mask | (1 << i);
+            mask = mask | 1 << i;
         }
         return mask;
     }
@@ -343,8 +340,7 @@ public abstract class BitBufferHelper {
             if (value < 0) {
                 value += 256;
             }
-            ret = ret
-                    | (long) value << ((length - i - 1) * NetUtils.NumBitsInAByte);
+            ret = ret | (long) value << (length - i - 1) * NetUtils.NumBitsInAByte;
         }
         return ret;
     }
@@ -363,18 +359,15 @@ public abstract class BitBufferHelper {
         int value = 0;
 
         value = array[startOffset - 1] & getLSBMask(bitsRest);
-        value = (array[startOffset - 1] < 0) ? (array[startOffset - 1] + 256)
-                : array[startOffset - 1];
-        ret = ret
-                | (value << ((array.length - startOffset) * NetUtils.NumBitsInAByte));
+        value = array[startOffset - 1] < 0 ? array[startOffset - 1] + 256 : array[startOffset - 1];
+        ret = ret | value << (array.length - startOffset) * NetUtils.NumBitsInAByte;
 
         for (int i = startOffset; i < array.length; i++) {
             value = array[i];
             if (value < 0) {
                 value += 256;
             }
-            ret = ret
-                    | (long) value << ((array.length - i - 1) * NetUtils.NumBitsInAByte);
+            ret = ret | (long) value << (array.length - i - 1) * NetUtils.NumBitsInAByte;
         }
 
         return ret;
@@ -399,8 +392,7 @@ public abstract class BitBufferHelper {
         } else if (dataType == Long.class || dataType == long.class) {
             size = Long.SIZE;
         } else {
-            throw new IllegalArgumentException(
-                    "Parameter must one of the following: Short/Int/Long\n");
+            throw new IllegalArgumentException("Parameter must one of the following: Short/Int/Long\n");
         }
 
         int length = size / NetUtils.NumBitsInAByte;
@@ -408,8 +400,7 @@ public abstract class BitBufferHelper {
 
         // Getting the bytes from input value
         for (int i = 0; i < length; i++) {
-            bytes[i] = (byte) ((longValue >> (NetUtils.NumBitsInAByte * (length
-                    - i - 1))) & ByteMask);
+            bytes[i] = (byte) (longValue >> NetUtils.NumBitsInAByte * (length - i - 1) & ByteMask);
         }
         return bytes;
     }
@@ -419,7 +410,8 @@ public abstract class BitBufferHelper {
      * aligned form example: input = 5000 [1001110001000] bytes = -114, 64
      * [10011100] [01000000]
      *
-     * @param numBits - the number of bits to be returned
+     * @param numBits
+     *            - the number of bits to be returned
      * @return byte[]
      *
      */
@@ -435,8 +427,7 @@ public abstract class BitBufferHelper {
         } else if (dataType == Long.class) {
             size = Long.SIZE;
         } else {
-            throw new IllegalArgumentException(
-                    "Parameter must one of the following: Short/Int/Long\n");
+            throw new IllegalArgumentException("Parameter must one of the following: Short/Int/Long\n");
         }
 
         int length = size / NetUtils.NumBitsInAByte;
@@ -446,12 +437,10 @@ public abstract class BitBufferHelper {
 
         // Getting the bytes from input value
         for (int i = 0; i < length; i++) {
-            bytes[i] = (byte) ((longValue >> (NetUtils.NumBitsInAByte * (length
-                    - i - 1))) & ByteMask);
+            bytes[i] = (byte) (longValue >> NetUtils.NumBitsInAByte * (length - i - 1) & ByteMask);
         }
 
-        if ((bytes[0] == 0 && dataType == Long.class)
-                || (bytes[0] == 0 && dataType == Integer.class)) {
+        if (bytes[0] == 0 && dataType == Long.class || bytes[0] == 0 && dataType == Integer.class) {
             int index = 0;
             for (index = 0; index < length; ++index) {
                 if (bytes[index] != 0) {
@@ -480,7 +469,8 @@ public abstract class BitBufferHelper {
      * Example: For inputbytes = [00000111][01110001] and numBits = 12 it
      * returns: shiftedBytes = [01110111][00010000]
      *
-     * @param numBits - number of bits to be left aligned
+     * @param numBits
+     *            - number of bits to be left aligned
      * @return byte[]
      */
     public static byte[] shiftBitsToMSB(final byte[] inputBytes, final int numBits) {
@@ -490,7 +480,7 @@ public abstract class BitBufferHelper {
         int i;
 
         for (i = 0; i < Byte.SIZE; i++) {
-            if (((byte) (inputBytes[0] & getMSBMask(i + 1))) != 0) {
+            if ((byte) (inputBytes[0] & getMSBMask(i + 1)) != 0) {
                 leadZeroesMSB = i;
                 break;
             }
@@ -499,8 +489,8 @@ public abstract class BitBufferHelper {
         if (numBits % NetUtils.NumBitsInAByte == 0) {
             numBitstoShiftBy = 0;
         } else {
-            numBitstoShiftBy = ((NetUtils.NumBitsInAByte - (numBits % NetUtils.NumBitsInAByte)) < leadZeroesMSB) ? (NetUtils.NumBitsInAByte - (numBits % NetUtils.NumBitsInAByte))
-                    : leadZeroesMSB;
+            numBitstoShiftBy = NetUtils.NumBitsInAByte - numBits % NetUtils.NumBitsInAByte < leadZeroesMSB
+                    ? NetUtils.NumBitsInAByte - numBits % NetUtils.NumBitsInAByte : leadZeroesMSB;
         }
         if (numBitstoShiftBy == 0) {
             return inputBytes;
@@ -514,16 +504,23 @@ public abstract class BitBufferHelper {
             numEndRestBits = NetUtils.NumBitsInAByte
                     - (inputBytes.length * NetUtils.NumBitsInAByte - numBits - numBitstoShiftBy);
 
-            for (i = 0; i < (size - 1); i++) {
-                if ((i + 1) == (size - 1)) {
+            for (i = 0; i < size - 1; i++) {
+                if (i + 1 == size - 1) {
                     if (numEndRestBits > numBitstoShiftBy) {
-                        shiftedBytes[i] = (byte) ((inputBytes[i] << numBitstoShiftBy) | ((inputBytes[i + 1] & getMSBMask(numBitstoShiftBy)) >> (numEndRestBits - numBitstoShiftBy)));
-                        shiftedBytes[i + 1] = (byte) ((inputBytes[i + 1] & getLSBMask(numEndRestBits
-                                - numBitstoShiftBy)) << numBitstoShiftBy);
-                    } else
-                        shiftedBytes[i] = (byte) ((inputBytes[i] << numBitstoShiftBy) | ((inputBytes[i + 1] & getMSBMask(numEndRestBits)) >> (NetUtils.NumBitsInAByte - numEndRestBits)));
+                        shiftedBytes[i] = (byte) (inputBytes[i] << numBitstoShiftBy
+                                | (inputBytes[i + 1] & getMSBMask(numBitstoShiftBy)) >> numEndRestBits
+                                        - numBitstoShiftBy);
+                        shiftedBytes[i + 1] = (byte) ((inputBytes[i + 1]
+                                & getLSBMask(numEndRestBits - numBitstoShiftBy)) << numBitstoShiftBy);
+                    } else {
+                        shiftedBytes[i] = (byte) (inputBytes[i] << numBitstoShiftBy
+                                | (inputBytes[i + 1] & getMSBMask(numEndRestBits)) >> NetUtils.NumBitsInAByte
+                                        - numEndRestBits);
+                    }
                 }
-                shiftedBytes[i] = (byte) ((inputBytes[i] << numBitstoShiftBy) | (inputBytes[i + 1] & getMSBMask(numBitstoShiftBy)) >> (NetUtils.NumBitsInAByte - numBitstoShiftBy));
+                shiftedBytes[i] = (byte) (inputBytes[i] << numBitstoShiftBy
+                        | (inputBytes[i + 1] & getMSBMask(numBitstoShiftBy)) >> NetUtils.NumBitsInAByte
+                                - numBitstoShiftBy);
             }
 
         }
@@ -538,7 +535,8 @@ public abstract class BitBufferHelper {
      * returns: shiftedBytes = [00000111][01110001]
      *
      * @param inputBytes
-     * @param numBits - number of bits to be right aligned
+     * @param numBits
+     *            - number of bits to be right aligned
      * @return byte[]
      */
     public static byte[] shiftBitsToLSB(final byte[] inputBytes, final int numBits) {
@@ -552,17 +550,16 @@ public abstract class BitBufferHelper {
         }
 
         for (int i = 1; i < numBytes; i++) {
-            inputLsb = inputBytes[i - 1]
-                    & getLSBMask(NetUtils.NumBitsInAByte - numBitstoShift);
-            inputLsb = (inputLsb < 0) ? (inputLsb + 256) : inputLsb;
+            inputLsb = inputBytes[i - 1] & getLSBMask(NetUtils.NumBitsInAByte - numBitstoShift);
+            inputLsb = inputLsb < 0 ? inputLsb + 256 : inputLsb;
             inputMsb = inputBytes[i] & getMSBMask(numBitstoShift);
-            inputMsb = (inputBytes[i] < 0) ? (inputBytes[i] + 256)
-                    : inputBytes[i];
-            shiftedBytes[i] = (byte) ((inputLsb << numBitstoShift) | (inputMsb >> (NetUtils.NumBitsInAByte - numBitstoShift)));
+            inputMsb = inputBytes[i] < 0 ? inputBytes[i] + 256 : inputBytes[i];
+            shiftedBytes[i] = (byte) (inputLsb << numBitstoShift
+                    | inputMsb >> NetUtils.NumBitsInAByte - numBitstoShift);
         }
-        inputMsb = inputBytes[0] & (getMSBMask(numBitstoShift));
-        inputMsb = (inputMsb < 0) ? (inputMsb + 256) : inputMsb;
-        shiftedBytes[0] = (byte) (inputMsb >> (NetUtils.NumBitsInAByte - numBitstoShift));
+        inputMsb = inputBytes[0] & getMSBMask(numBitstoShift);
+        inputMsb = inputMsb < 0 ? inputMsb + 256 : inputMsb;
+        shiftedBytes[0] = (byte) (inputMsb >> NetUtils.NumBitsInAByte - numBitstoShift);
         return shiftedBytes;
     }
 
@@ -571,12 +568,13 @@ public abstract class BitBufferHelper {
      * of bits specified from the input data byte array. The input byte array
      * has the bits stored starting from the LSB
      */
-    public static void insertBits(final byte[] data, final byte[] inputdataLSB,
-            final int startOffset, final int numBits) {
+    public static void insertBits(final byte[] data, final byte[] inputdataLSB, final int startOffset,
+            final int numBits) {
         byte[] inputdata = shiftBitsToMSB(inputdataLSB, numBits); // Align to
-                                                                  // MSB the
-                                                                  // passed byte
-                                                                  // array
+                                                                    // MSB the
+                                                                    // passed
+                                                                    // byte
+                                                                    // array
         int numBytes = numBits / NetUtils.NumBitsInAByte;
         int startByteOffset = startOffset / NetUtils.NumBitsInAByte;
         int extraOffsetBits = startOffset % NetUtils.NumBitsInAByte;
@@ -595,88 +593,77 @@ public abstract class BitBufferHelper {
                 System.arraycopy(inputdata, 0, data, startByteOffset, numBytes);
             } else {
                 System.arraycopy(inputdata, 0, data, startByteOffset, numBytes);
-                data[startByteOffset + numBytes] = (byte) (data[startByteOffset
-                        + numBytes] | (inputdata[numBytes] & getMSBMask(extranumBits)));
+                data[startByteOffset + numBytes] = (byte) (data[startByteOffset + numBytes]
+                        | inputdata[numBytes] & getMSBMask(extranumBits));
             }
         } else {
             for (i = 0; i < numBytes; i++) {
                 if (i != 0) {
-                    InputLSBbits = (inputdata[i - 1] & getLSBMask(extraOffsetBits));
+                    InputLSBbits = inputdata[i - 1] & getLSBMask(extraOffsetBits);
                 }
-                InputMSBbits = (byte) (inputdata[i] & (getMSBMask(NetUtils.NumBitsInAByte
-                        - extraOffsetBits)));
-                InputMSBbits = (InputMSBbits >= 0) ? InputMSBbits
-                        : InputMSBbits + 256;
+                InputMSBbits = (byte) (inputdata[i] & getMSBMask(NetUtils.NumBitsInAByte - extraOffsetBits));
+                InputMSBbits = InputMSBbits >= 0 ? InputMSBbits : InputMSBbits + 256;
                 data[startByteOffset + i] = (byte) (data[startByteOffset + i]
-                        | (InputLSBbits << (NetUtils.NumBitsInAByte - extraOffsetBits)) | (InputMSBbits >> extraOffsetBits));
+                        | InputLSBbits << NetUtils.NumBitsInAByte - extraOffsetBits | InputMSBbits >> extraOffsetBits);
                 InputMSBbits = InputLSBbits = 0;
             }
-            if (RestBits < (NetUtils.NumBitsInAByte - extraOffsetBits)) {
+            if (RestBits < NetUtils.NumBitsInAByte - extraOffsetBits) {
                 if (numBytes != 0) {
-                    InputLSBbits = (inputdata[i - 1] & getLSBMask(extraOffsetBits));
+                    InputLSBbits = inputdata[i - 1] & getLSBMask(extraOffsetBits);
                 }
-                InputMSBbits = (byte) (inputdata[i] & (getMSBMask(RestBits)));
-                InputMSBbits = (InputMSBbits >= 0) ? InputMSBbits
-                        : InputMSBbits + 256;
-                data[startByteOffset + i] = (byte) ((data[startByteOffset + i])
-                        | (InputLSBbits << (NetUtils.NumBitsInAByte - extraOffsetBits)) | (InputMSBbits >> extraOffsetBits));
-            } else if (RestBits == (NetUtils.NumBitsInAByte - extraOffsetBits)) {
+                InputMSBbits = (byte) (inputdata[i] & getMSBMask(RestBits));
+                InputMSBbits = InputMSBbits >= 0 ? InputMSBbits : InputMSBbits + 256;
+                data[startByteOffset + i] = (byte) (data[startByteOffset + i]
+                        | InputLSBbits << NetUtils.NumBitsInAByte - extraOffsetBits | InputMSBbits >> extraOffsetBits);
+            } else if (RestBits == NetUtils.NumBitsInAByte - extraOffsetBits) {
                 if (numBytes != 0) {
-                    InputLSBbits = (inputdata[i - 1] & getLSBMask(extraOffsetBits));
+                    InputLSBbits = inputdata[i - 1] & getLSBMask(extraOffsetBits);
                 }
-                InputMSBbits = (byte) (inputdata[i] & (getMSBMask(NetUtils.NumBitsInAByte
-                        - extraOffsetBits)));
-                InputMSBbits = (InputMSBbits >= 0) ? InputMSBbits
-                        : InputMSBbits + 256;
+                InputMSBbits = (byte) (inputdata[i] & getMSBMask(NetUtils.NumBitsInAByte - extraOffsetBits));
+                InputMSBbits = InputMSBbits >= 0 ? InputMSBbits : InputMSBbits + 256;
                 data[startByteOffset + i] = (byte) (data[startByteOffset + i]
-                        | (InputLSBbits << (NetUtils.NumBitsInAByte - extraOffsetBits)) | (InputMSBbits >> extraOffsetBits));
+                        | InputLSBbits << NetUtils.NumBitsInAByte - extraOffsetBits | InputMSBbits >> extraOffsetBits);
             } else {
                 if (numBytes != 0) {
-                    InputLSBbits = (inputdata[i - 1] & getLSBMask(extraOffsetBits));
+                    InputLSBbits = inputdata[i - 1] & getLSBMask(extraOffsetBits);
                 }
-                InputMSBbits = (byte) (inputdata[i] & (getMSBMask(NetUtils.NumBitsInAByte
-                        - extraOffsetBits)));
-                InputMSBbits = (InputMSBbits >= 0) ? InputMSBbits
-                        : InputMSBbits + 256;
+                InputMSBbits = (byte) (inputdata[i] & getMSBMask(NetUtils.NumBitsInAByte - extraOffsetBits));
+                InputMSBbits = InputMSBbits >= 0 ? InputMSBbits : InputMSBbits + 256;
                 data[startByteOffset + i] = (byte) (data[startByteOffset + i]
-                        | (InputLSBbits << (NetUtils.NumBitsInAByte - extraOffsetBits)) | (InputMSBbits >> extraOffsetBits));
+                        | InputLSBbits << NetUtils.NumBitsInAByte - extraOffsetBits | InputMSBbits >> extraOffsetBits);
 
-                InputLSBbits = (inputdata[i] & (getLSBMask(RestBits
-                        - (NetUtils.NumBitsInAByte - extraOffsetBits)) << (NetUtils.NumBitsInAByte - RestBits)));
-                data[startByteOffset + i + 1] = (byte) (data[startByteOffset
-                        + i + 1] | (InputLSBbits << (NetUtils.NumBitsInAByte - extraOffsetBits)));
+                InputLSBbits = inputdata[i]
+                        & getLSBMask(RestBits - (NetUtils.NumBitsInAByte - extraOffsetBits)) << NetUtils.NumBitsInAByte
+                                - RestBits;
+                data[startByteOffset + i + 1] = (byte) (data[startByteOffset + i + 1]
+                        | InputLSBbits << NetUtils.NumBitsInAByte - extraOffsetBits);
             }
         }
     }
 
     /**
      * Checks for overflow and underflow exceptions
-     * @throws BufferException when the startOffset and numBits parameters
-     *                    are not congruent with the data buffer's size
+     *
+     * @throws BufferException
+     *             when the startOffset and numBits parameters are not congruent
+     *             with the data buffer's size
      */
     public static void checkExceptions(final byte[] data, final int startOffset, final int numBits)
             throws BufferException {
         int endOffsetByte;
         int startByteOffset;
-        endOffsetByte = startOffset
-                / NetUtils.NumBitsInAByte
-                + numBits
-                / NetUtils.NumBitsInAByte
-                + ((numBits % NetUtils.NumBitsInAByte != 0) ? 1 : ((startOffset
-                        % NetUtils.NumBitsInAByte != 0) ? 1 : 0));
+        endOffsetByte = startOffset / NetUtils.NumBitsInAByte + numBits / NetUtils.NumBitsInAByte
+                + (numBits % NetUtils.NumBitsInAByte != 0 ? 1 : startOffset % NetUtils.NumBitsInAByte != 0 ? 1 : 0);
         startByteOffset = startOffset / NetUtils.NumBitsInAByte;
 
         if (data == null) {
             throw new BufferException("data[] is null\n");
         }
 
-        if ((startOffset < 0) || (startByteOffset >= data.length)
-                || (endOffsetByte > data.length) || (numBits < 0)
-                || (numBits > NetUtils.NumBitsInAByte * data.length)) {
-            throw new BufferException(
-                    "Illegal arguement/out of bound exception - data.length = "
-                            + data.length + " startOffset = " + startOffset
-                            + " numBits " + numBits);
+        if (startOffset < 0 || startByteOffset >= data.length || endOffsetByte > data.length || numBits < 0
+                || numBits > NetUtils.NumBitsInAByte * data.length) {
+            throw new BufferException("Illegal arguement/out of bound exception - data.length = " + data.length
+                    + " startOffset = " + startOffset + " numBits " + numBits);
         }
     }
 }
index 1b76c9980576aee902e795c084f22f199383deb5..dfd8ca42e5e7b2271faf7a571515b506ca6000ed 100644 (file)
@@ -222,8 +222,8 @@ public class LLDP extends Packet {
         int lldpOffset = bitOffset; // LLDP start
         int lldpSize = size; // LLDP size
 
-        if (logger.isTraceEnabled()) {
-            logger.trace("LLDP: {} (offset {} bitsize {})", new Object[] { HexEncode.bytesToHexString(data),
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("LLDP: {} (offset {} bitsize {})", new Object[] { HexEncode.bytesToHexString(data),
                     lldpOffset, lldpSize });
         }
         /*
@@ -270,8 +270,8 @@ public class LLDP extends Packet {
             throw new PacketException(e.getMessage());
         }
 
-        if (logger.isTraceEnabled()) {
-            logger.trace("LLDP: serialized: {}", HexEncode.bytesToHexString(serializedBytes));
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("LLDP: serialized: {}", HexEncode.bytesToHexString(serializedBytes));
         }
         return serializedBytes;
     }
index 55466a6b1bdcab3f7b1329a7f5da57118fbaf5e1..2ed77879cba48e470987be89d275bd00b5be902a 100644 (file)
@@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory;
  * networking data structures
  */
 public abstract class NetUtils {
-    protected static final Logger logger = LoggerFactory.getLogger(NetUtils.class);
+    protected static final Logger LOG = LoggerFactory.getLogger(NetUtils.class);
     /**
      * Constant holding the number of bits in a byte
      */
@@ -56,7 +56,7 @@ public abstract class NetUtils {
         if (ba == null || ba.length != 4) {
             return 0;
         }
-        return (0xff & ba[0]) << 24 | (0xff & ba[1]) << 16 | (0xff & ba[2]) << 8 | (0xff & ba[3]);
+        return (0xff & ba[0]) << 24 | (0xff & ba[1]) << 16 | (0xff & ba[2]) << 8 | 0xff & ba[3];
     }
 
     /**
@@ -108,7 +108,7 @@ public abstract class NetUtils {
      * @return the byte array
      */
     public static byte[] intToByteArray4(final int i) {
-        return new byte[] { (byte) ((i >> 24) & 0xff), (byte) ((i >> 16) & 0xff), (byte) ((i >> 8) & 0xff),
+        return new byte[] { (byte) (i >> 24 & 0xff), (byte) (i >> 16 & 0xff), (byte) (i >> 8 & 0xff),
                 (byte) (i & 0xff) };
     }
 
@@ -125,7 +125,7 @@ public abstract class NetUtils {
         try {
             ip = InetAddress.getByAddress(NetUtils.intToByteArray4(address));
         } catch (final UnknownHostException e) {
-            logger.error("", e);
+            LOG.error("", e);
         }
         return ip;
     }
@@ -143,12 +143,12 @@ public abstract class NetUtils {
      * @return
      */
     public static InetAddress getInetNetworkMask(final int prefixMaskLength, final boolean isV6) {
-        if (prefixMaskLength < 0 || (!isV6 && prefixMaskLength > 32) || (isV6 && prefixMaskLength > 128)) {
+        if (prefixMaskLength < 0 || !isV6 && prefixMaskLength > 32 || isV6 && prefixMaskLength > 128) {
             return null;
         }
         byte v4Address[] = { 0, 0, 0, 0 };
         byte v6Address[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-        byte address[] = (isV6) ? v6Address : v4Address;
+        byte address[] = isV6 ? v6Address : v4Address;
         int numBytes = prefixMaskLength / 8;
         int numBits = prefixMaskLength % 8;
         int i = 0;
@@ -158,7 +158,7 @@ public abstract class NetUtils {
         if (numBits > 0) {
             int rem = 0;
             for (int j = 0; j < numBits; j++) {
-                rem |= 1 << (7 - j);
+                rem |= 1 << 7 - j;
             }
             address[i] = (byte) rem;
         }
@@ -166,7 +166,7 @@ public abstract class NetUtils {
         try {
             return InetAddress.getByAddress(address);
         } catch (final UnknownHostException e) {
-            logger.error("", e);
+            LOG.error("", e);
         }
         return null;
     }
@@ -229,12 +229,12 @@ public abstract class NetUtils {
         byte modifiedByte;
         byte[] sn = ip.getAddress();
         if (bits > 0) {
-            modifiedByte = (byte) (sn[bytes] >> (8 - bits));
-            sn[bytes] = (byte) (modifiedByte << (8 - bits));
+            modifiedByte = (byte) (sn[bytes] >> 8 - bits);
+            sn[bytes] = (byte) (modifiedByte << 8 - bits);
             bytes++;
         }
         for (; bytes < sn.length; bytes++) {
-            sn[bytes] = (byte) (0);
+            sn[bytes] = (byte) 0;
         }
         try {
             return InetAddress.getByAddress(sn);
@@ -271,7 +271,7 @@ public abstract class NetUtils {
     public static boolean inetAddressConflict(final InetAddress testAddress, final InetAddress filterAddress, final InetAddress testMask,
             final InetAddress filterMask) {
         // Sanity check
-        if ((testAddress == null) || (filterAddress == null)) {
+        if (testAddress == null || filterAddress == null) {
             return false;
         }
 
@@ -280,9 +280,9 @@ public abstract class NetUtils {
             return false;
         }
 
-        int testMaskLen = (testMask == null) ? ((testAddress instanceof Inet4Address) ? 32 : 128) : NetUtils
+        int testMaskLen = testMask == null ? testAddress instanceof Inet4Address ? 32 : 128 : NetUtils
                 .getSubnetMaskLength(testMask);
-        int filterMaskLen = (filterMask == null) ? ((testAddress instanceof Inet4Address) ? 32 : 128) : NetUtils
+        int filterMaskLen = filterMask == null ? testAddress instanceof Inet4Address ? 32 : 128 : NetUtils
                 .getSubnetMaskLength(filterMask);
 
         // Mask length check. Test mask has to be more specific than filter one
@@ -293,7 +293,7 @@ public abstract class NetUtils {
         // Subnet Prefix on filter mask length must be the same
         InetAddress prefix1 = getSubnetPrefix(testAddress, filterMaskLen);
         InetAddress prefix2 = getSubnetPrefix(filterAddress, filterMaskLen);
-        return (!prefix1.equals(prefix2));
+        return !prefix1.equals(prefix2);
     }
 
     /**
@@ -377,7 +377,7 @@ public abstract class NetUtils {
     }
 
     public static boolean fieldsConflict(final int field1, final int field2) {
-        if ((field1 == 0) || (field2 == 0) || (field1 == field2)) {
+        if (field1 == 0 || field2 == 0 || field1 == field2) {
             return false;
         }
         return true;
@@ -388,7 +388,7 @@ public abstract class NetUtils {
         try {
             address = InetAddress.getByName(addressString);
         } catch (final UnknownHostException e) {
-            logger.error("", e);
+            LOG.error("", e);
         }
         return address;
     }
@@ -415,7 +415,7 @@ public abstract class NetUtils {
         }
         if (values.length >= 2) {
             int prefix = Integer.valueOf(values[1]);
-            if ((prefix < 0) || (prefix > 32)) {
+            if (prefix < 0 || prefix > 32) {
                 return false;
             }
         }
@@ -449,7 +449,7 @@ public abstract class NetUtils {
 
         if (values.length >= 2) {
             int prefix = Integer.valueOf(values[1]);
-            if ((prefix < 0) || (prefix > 128)) {
+            if (prefix < 0 || prefix > 128) {
                 return false;
             }
         }
@@ -503,7 +503,7 @@ public abstract class NetUtils {
      */
     public static InetAddress gethighestIP(final boolean v6) {
         try {
-            return (v6) ? InetAddress.getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") : InetAddress
+            return v6 ? InetAddress.getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") : InetAddress
                     .getByName("255.255.255.255");
         } catch (final UnknownHostException e) {
             return null;
index 0d8acb52b736df2055a94aa523e4091c38718ca8..3e3ad14a6f49664c0154761dac1fcc8fce6e5f53 100644 (file)
@@ -23,8 +23,7 @@ import org.slf4j.LoggerFactory;
  */
 
 public abstract class Packet {
-    protected static final Logger logger = LoggerFactory
-            .getLogger(Packet.class);
+    protected static final Logger LOG = LoggerFactory.getLogger(Packet.class);
     // Access level granted to this packet
     protected boolean writeAccess;
     // When deserialized from wire, packet could result corrupted
@@ -108,8 +107,8 @@ public abstract class Packet {
              */
             this.setHeaderField(hdrField, hdrFieldBytes);
 
-            if (logger.isTraceEnabled()) {
-                logger.trace("{}: {}: {} (offset {} bitsize {})",
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("{}: {}: {} (offset {} bitsize {})",
                         new Object[] { this.getClass().getSimpleName(), hdrField,
                         HexEncode.bytesToHexString(hdrFieldBytes),
                         startOffset, numBits });
@@ -162,7 +161,7 @@ public abstract class Packet {
         } else if (rawPayload != null) {
             payloadBytes = rawPayload;
         }
-        int payloadSize = (payloadBytes == null) ? 0 : payloadBytes.length;
+        int payloadSize = payloadBytes == null ? 0 : payloadBytes.length;
 
         // Allocate the buffer to contain the full (header + payload) packet
         int headerSize = this.getHeaderSize() / NetUtils.NumBitsInAByte;
@@ -190,8 +189,8 @@ public abstract class Packet {
         // Perform post serialize operations (like checksum computation)
         postSerializeCustomOperation(packetBytes);
 
-        if (logger.isTraceEnabled()) {
-            logger.trace("{}: {}", this.getClass().getSimpleName(),
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("{}: {}", this.getClass().getSimpleName(),
                     HexEncode.bytesToHexString(packetBytes));
         }
 
@@ -327,7 +326,7 @@ public abstract class Packet {
         final int prime = 31;
         int result = super.hashCode();
         result = prime * result
-                + ((this.hdrFieldsMap == null) ? 0 : hdrFieldsMap.hashCode());
+                + (this.hdrFieldsMap == null ? 0 : hdrFieldsMap.hashCode());
         return result;
     }
 
index 22ad93065655369e08d4bec3b755abf5e268f219..b1defd25cb98e3152ce033f92a43cf5f204bc629 100644 (file)
@@ -16,7 +16,7 @@ import com.google.common.collect.Lists;
 
 public class Session extends AbstractProtocolSession<SimpleMessage> {
 
-    private static final Logger logger = LoggerFactory.getLogger(Session.class);
+    private static final Logger LOG = LoggerFactory.getLogger(Session.class);
 
     public final List<SimpleMessage> msgs = Lists.newArrayList();
 
@@ -29,19 +29,19 @@ public class Session extends AbstractProtocolSession<SimpleMessage> {
 
     @Override
     public void handleMessage(final SimpleMessage msg) {
-        logger.debug("Message received: {}", msg.getMessage());
+        LOG.debug("Message received: {}", msg.getMessage());
         this.up = true;
         this.msgs.add(msg);
-        logger.debug(this.msgs.size() + "");
+        LOG.debug(this.msgs.size() + "");
     }
 
     @Override
     public void endOfInput() {
-        logger.debug("End of input reported.");
+        LOG.debug("End of input reported.");
     }
 
     @Override
     protected void sessionUp() {
-        logger.debug("Session up reported.");
+        LOG.debug("Session up reported.");
     }
 }
index d83738520cccc1e7bc24b4f97cb31c30ff6e51ad..314fd42c7d37c2865fdb5842afdcfa6c3d62ce87 100644 (file)
@@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Preconditions;
 
 public class SimpleDispatcher extends AbstractDispatcher<SimpleSession, SimpleSessionListener> {
-    private static final Logger logger = LoggerFactory.getLogger(SimpleDispatcher.class);
+    private static final Logger LOG = LoggerFactory.getLogger(SimpleDispatcher.class);
 
     private final SessionNegotiatorFactory<SimpleMessage, SimpleSession, SimpleSessionListener> negotiatorFactory;
     private final ChannelOutboundHandler encoder = new SimpleMessageToByteEncoder();
@@ -39,7 +39,7 @@ public class SimpleDispatcher extends AbstractDispatcher<SimpleSession, SimpleSe
             channel.pipeline().addLast(new SimpleByteToMessageDecoder());
             channel.pipeline().addLast("negotiator", negotiatorFactory.getSessionNegotiator(listenerFactory, channel, promise));
             channel.pipeline().addLast(encoder);
-            logger.debug("initialization completed for channel {}", channel);
+            LOG.debug("initialization completed for channel {}", channel);
         }
 
     }
index 5d167566f2635fc8e839e4d5f633ecc05ed04704..8db14f7f5a41288fb48aec885cd6fe7fac338d95 100644 (file)
@@ -17,7 +17,7 @@ import org.slf4j.LoggerFactory;
  * Simple Session Listener that is notified about messages and changes in the session.
  */
 public class SimpleSessionListener implements SessionListener<SimpleMessage, SimpleSession, TerminationReason> {
-    private static final Logger logger = LoggerFactory.getLogger(SimpleSessionListener.class);
+    private static final Logger LOG = LoggerFactory.getLogger(SimpleSessionListener.class);
 
     public List<SimpleMessage> messages = new ArrayList<>();
 
@@ -27,7 +27,7 @@ public class SimpleSessionListener implements SessionListener<SimpleMessage, Sim
 
     @Override
     public void onMessage(final SimpleSession session, final SimpleMessage message) {
-        logger.debug("Received message: " + message.getClass() + " " + message);
+        LOG.debug("Received message: " + message.getClass() + " " + message);
         this.messages.add(message);
     }
 
index 56523cb60b233a5487da8c6c83173ec63b2a1cad..8945de6bafcb16651768335f79bce74b50c180c9 100644 (file)
@@ -44,7 +44,7 @@ public class RaftActorContextImplTest extends AbstractActorTest {
     private final TestActorRef<DoNothingActor> actor = actorFactory.createTestActor(
             Props.create(DoNothingActor.class), actorFactory.generateActorId("actor"));
 
-    private final Logger log = LoggerFactory.getLogger(RaftActorContextImplTest.class);
+    private static final Logger LOG = LoggerFactory.getLogger(RaftActorContextImplTest.class);
 
     @After
     public void tearDown() {
@@ -58,8 +58,8 @@ public class RaftActorContextImplTest extends AbstractActorTest {
         peerMap.put("peer2", null);
         DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl();
         RaftActorContextImpl context = new RaftActorContextImpl(actor, actor.underlyingActor().getContext(),
-                "test", new ElectionTermImpl(new NonPersistentDataProvider(), "test", log), -1, -1,
-                peerMap, configParams, new NonPersistentDataProvider(), applyState -> { }, log);
+                "test", new ElectionTermImpl(new NonPersistentDataProvider(), "test", LOG), -1, -1,
+                peerMap, configParams, new NonPersistentDataProvider(), applyState -> { }, LOG);
 
         assertEquals("getPeerAddress", "peerAddress1", context.getPeerAddress("peer1"));
         assertEquals("getPeerAddress", null, context.getPeerAddress("peer2"));
@@ -82,9 +82,9 @@ public class RaftActorContextImplTest extends AbstractActorTest {
     public void testSetPeerAddress() {
         DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl();
         RaftActorContextImpl context = new RaftActorContextImpl(actor, actor.underlyingActor().getContext(),
-                "test", new ElectionTermImpl(new NonPersistentDataProvider(), "test", log), -1, -1,
+                "test", new ElectionTermImpl(new NonPersistentDataProvider(), "test", LOG), -1, -1,
                 Maps.newHashMap(ImmutableMap.<String, String>of("peer1", "peerAddress1")), configParams,
-                new NonPersistentDataProvider(), applyState -> { }, log);
+                new NonPersistentDataProvider(), applyState -> { }, LOG);
 
         context.setPeerAddress("peer1", "peerAddress1_1");
         assertEquals("getPeerAddress", "peerAddress1_1", context.getPeerAddress("peer1"));
@@ -96,9 +96,9 @@ public class RaftActorContextImplTest extends AbstractActorTest {
     @Test
     public void testUpdatePeerIds() {
         RaftActorContextImpl context = new RaftActorContextImpl(actor, actor.underlyingActor().getContext(),
-                "self", new ElectionTermImpl(new NonPersistentDataProvider(), "test", log), -1, -1,
+                "self", new ElectionTermImpl(new NonPersistentDataProvider(), "test", LOG), -1, -1,
                 Maps.newHashMap(ImmutableMap.<String, String>of("peer1", "peerAddress1")),
-                new DefaultConfigParamsImpl(), new NonPersistentDataProvider(), applyState -> { }, log);
+                new DefaultConfigParamsImpl(), new NonPersistentDataProvider(), applyState -> { }, LOG);
 
         context.updatePeerIds(new ServerConfigurationPayload(Arrays.asList(new ServerInfo("self", false),
                 new ServerInfo("peer2", true), new ServerInfo("peer3", false))));
index bbe5036d791c02559612a245b5d00a3b2ee6a4e6..cdf29f687e80bf848efc661dc86707059261dcb0 100644 (file)
@@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory;
 import javassist.ClassPool;
 
 public class SingletonHolder {
-    private static final Logger logger = LoggerFactory.getLogger(SingletonHolder.class);
+    private static final Logger LOG = LoggerFactory.getLogger(SingletonHolder.class);
 
     public static final ClassPool CLASS_POOL = ClassPool.getDefault();
     public static final JavassistUtils JAVASSIST = JavassistUtils.forClassPool(CLASS_POOL);
@@ -55,9 +55,9 @@ public class SingletonHolder {
             if (StringUtils.isNotBlank(queueValue)) {
                 try {
                     queueSize = Integer.parseInt(queueValue);
-                    logger.trace("Queue size was set to {}", queueSize);
+                    LOG.trace("Queue size was set to {}", queueSize);
                 } catch (final NumberFormatException e) {
-                    logger.warn("Cannot parse {} as set by {}, using default {}", queueValue,
+                    LOG.warn("Cannot parse {} as set by {}, using default {}", queueValue,
                             NOTIFICATION_QUEUE_SIZE_PROPERTY, queueSize);
                 }
             }
index 6cd0ebc5f838dbded2f16dac6fd5dc9eeee748a7..33fc2446196d5473f9742883155b92d25110fc77 100644 (file)
@@ -38,7 +38,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class BrokerImpl implements Broker, DOMRpcProviderService, DOMRpcService, AutoCloseable {
-    private final static Logger log = LoggerFactory.getLogger(BrokerImpl.class);
+    private static final Logger LOG = LoggerFactory.getLogger(BrokerImpl.class);
 
     // Broker Generic Context
     private final Set<ConsumerContextImpl> sessions = Collections
@@ -144,7 +144,7 @@ public class BrokerImpl implements Broker, DOMRpcProviderService, DOMRpcService,
     @Override
     public ConsumerSession registerConsumer(final Consumer consumer) {
         checkPredicates(consumer);
-        log.trace("Registering consumer {}", consumer);
+        LOG.trace("Registering consumer {}", consumer);
         final ConsumerContextImpl session = newSessionFor(consumer);
         consumer.onSessionInitiated(session);
         sessions.add(session);
index 81af5f303381112141f65f8d2cd55a4b7e665088..467acf05d8c9bdf8c0c3b1f96dcc6358d71148e3 100644 (file)
@@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory;
 
 public class DOMBrokerPerformanceTest {
 
-    private static final Logger log = LoggerFactory.getLogger(DOMBrokerPerformanceTest.class);
+    private static final Logger LOG = LoggerFactory.getLogger(DOMBrokerPerformanceTest.class);
 
     private static NormalizedNode<?, ?> outerList(final int i) {
         return ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, i);
@@ -56,13 +56,13 @@ public class DOMBrokerPerformanceTest {
 
     private static <V> V measure(final String name, final Callable<V> callable) throws Exception {
         // TODO Auto-generated method stub
-        log.debug("Measurement:{} Start", name);
+        LOG.debug("Measurement:{} Start", name);
         long startNano = System.nanoTime();
         try {
             return callable.call();
         } finally {
             long endNano = System.nanoTime();
-            log.info("Measurement:\"{}\" Time:{} ms", name, (endNano - startNano) / 1000000.0d);
+            LOG.info("Measurement:\"{}\" Time:{} ms", name, (endNano - startNano) / 1000000.0d);
         }
     }
 
index a01a858e2a8000f4d515bda3f4002a497c0c07b0..5dee90db877e57368ec12dee7ff54a2d245e2bf0 100644 (file)
@@ -26,7 +26,7 @@ import org.slf4j.LoggerFactory;
 
 public class PeopleCarListener implements CarPurchaseListener {
 
-  private static final Logger log = LoggerFactory.getLogger(PeopleCarListener.class);
+  private static final Logger LOG = LoggerFactory.getLogger(PeopleCarListener.class);
 
   private DataBroker dataProvider;
 
@@ -46,7 +46,7 @@ public class PeopleCarListener implements CarPurchaseListener {
     carPersonBuilder.setKey(key);
     final CarPerson carPerson = carPersonBuilder.build();
 
-    log.info("Car bought, adding car-person entry: [{}]", carPerson);
+    LOG.info("Car bought, adding car-person entry: [{}]", carPerson);
 
     InstanceIdentifier<CarPerson> carPersonIId =
         InstanceIdentifier.<CarPeople>builder(CarPeople.class).child(CarPerson.class, carPerson.getKey()).build();
@@ -58,12 +58,12 @@ public class PeopleCarListener implements CarPurchaseListener {
     Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
       @Override
       public void onSuccess(final Void result) {
-        log.info("Successfully added car-person entry: [{}]", carPerson);
+        LOG.info("Successfully added car-person entry: [{}]", carPerson);
       }
 
       @Override
       public void onFailure(final Throwable t) {
-        log.error(String.format("Failed to add car-person entry: [%s]", carPerson), t);
+        LOG.error(String.format("Failed to add car-person entry: [%s]", carPerson), t);
       }
     });
 
index 63041aba0ed86282c1fb75251f0dad4f417472fa..ec4c1bb1618e0f79f3a3848fa9b2850e2ee06da9 100644 (file)
@@ -58,9 +58,9 @@ import org.slf4j.LoggerFactory;
  * @author Thomas Pantelis
  */
 public class CarProvider implements CarService {
-    private static final Logger log = LoggerFactory.getLogger(PurchaseCarProvider.class);
+    private static final Logger LOG_PURCHASE_CAR = LoggerFactory.getLogger(PurchaseCarProvider.class);
 
-    private static final Logger LOG = LoggerFactory.getLogger(CarProvider.class);
+    private static final Logger LOG_CAR_PROVIDER = LoggerFactory.getLogger(CarProvider.class);
 
     private static final String ENTITY_TYPE = "cars";
     private static final InstanceIdentifier CARS_IID = InstanceIdentifier.builder(Cars.class).build();
@@ -116,7 +116,7 @@ public class CarProvider implements CarService {
 
         // If rate is not provided, or given as zero, then just return.
         if (input.getRate() == null || input.getRate() == 0) {
-            log.info("Exiting stress test as no rate is given.");
+            LOG_PURCHASE_CAR.info("Exiting stress test as no rate is given.");
             return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
                     .withError(ErrorType.PROTOCOL, "invalid rate")
                     .build());
@@ -130,7 +130,7 @@ public class CarProvider implements CarService {
             inputCount = 0;
         }
 
-        log.info("Stress test starting : rate: {} count: {}", inputRate, inputCount);
+        LOG_PURCHASE_CAR.info("Stress test starting : rate: {} count: {}", inputRate, inputCount);
 
         stopThread();
         // clear counters
@@ -143,7 +143,7 @@ public class CarProvider implements CarService {
         try {
             tx.submit().checkedGet(5, TimeUnit.SECONDS);
         } catch (TransactionCommitFailedException | TimeoutException e) {
-            log.error("Put Cars failed",e);
+            LOG_PURCHASE_CAR.error("Put Cars failed",e);
             return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
         }
 
@@ -173,7 +173,7 @@ public class CarProvider implements CarService {
                     public void onFailure(final Throwable t) {
                         // Transaction failed
                         failureCounter.getAndIncrement();
-                        LOG.error("Put Cars failed", t);
+                        LOG_CAR_PROVIDER.error("Put Cars failed", t);
                     }
                 });
                 try {
@@ -183,7 +183,7 @@ public class CarProvider implements CarService {
                 }
 
                 if(count.get() % 1000 == 0) {
-                    log.info("Cars created {}, time: {}",count.get(),sw.elapsed(TimeUnit.SECONDS));
+                    LOG_PURCHASE_CAR.info("Cars created {}, time: {}",count.get(),sw.elapsed(TimeUnit.SECONDS));
                 }
 
                 // Check if a count is specified in input and we have created that many cars.
@@ -192,7 +192,7 @@ public class CarProvider implements CarService {
                 }
             }
 
-            log.info("Stress test thread stopping after creating {} cars.", count.get());
+            LOG_PURCHASE_CAR.info("Stress test thread stopping after creating {} cars.", count.get());
         });
         testThread.start();
 
@@ -208,7 +208,7 @@ public class CarProvider implements CarService {
                 .setFailureCount(failureCounter.longValue());
 
         StopStressTestOutput result = stopStressTestOutput.build();
-        log.info("Executed Stop Stress test; No. of cars created {}; " +
+        LOG_PURCHASE_CAR.info("Executed Stop Stress test; No. of cars created {}; " +
                 "No. of cars failed {}; ", succcessCounter, failureCounter);
         // clear counters
         succcessCounter.set(0);
@@ -242,13 +242,13 @@ public class CarProvider implements CarService {
     private static class CarEntityOwnershipListener implements EntityOwnershipListener {
         @Override
         public void ownershipChanged(EntityOwnershipChange ownershipChange) {
-            LOG.info("ownershipChanged: {}", ownershipChange);
+            LOG_CAR_PROVIDER.info("ownershipChanged: {}", ownershipChange);
         }
     }
 
     @Override
     public Future<RpcResult<java.lang.Void>> registerLoggingDcl() {
-        LOG.info("Registering a new CarDataChangeListener");
+        LOG_CAR_PROVIDER.info("Registering a new CarDataChangeListener");
         final ListenerRegistration carsDclRegistration = dataProvider.registerDataChangeListener(
                 LogicalDatastoreType.CONFIGURATION, CARS_IID, new CarDataChangeListener(),
                 AsyncDataBroker.DataChangeScope.SUBTREE);
@@ -262,7 +262,7 @@ public class CarProvider implements CarService {
 
     @Override
     public Future<RpcResult<java.lang.Void>> registerLoggingDtcl() {
-        LOG.info("Registering a new CarDataTreeChangeListener");
+        LOG_CAR_PROVIDER.info("Registering a new CarDataTreeChangeListener");
         final ListenerRegistration<CarDataTreeChangeListener> carsDtclRegistration =
                 dataProvider.registerDataTreeChangeListener(CARS_DTID, new CarDataTreeChangeListener());
 
@@ -275,7 +275,7 @@ public class CarProvider implements CarService {
 
     @Override
     public Future<RpcResult<java.lang.Void>> unregisterLoggingDcls() {
-        LOG.info("Unregistering the CarDataChangeListener(s)");
+        LOG_CAR_PROVIDER.info("Unregistering the CarDataChangeListener(s)");
         synchronized (carsDclRegistrations) {
             int numListeners = 0;
             for (ListenerRegistration<DataChangeListener> carsDclRegistration : carsDclRegistrations) {
@@ -283,14 +283,14 @@ public class CarProvider implements CarService {
                 numListeners++;
             }
             carsDclRegistrations.clear();
-            LOG.info("Unregistered {} CarDataChangeListener(s)", numListeners);
+            LOG_CAR_PROVIDER.info("Unregistered {} CarDataChangeListener(s)", numListeners);
         }
         return RpcResultBuilder.<Void>success().buildFuture();
     }
 
     @Override
     public Future<RpcResult<java.lang.Void>> unregisterLoggingDtcls() {
-        LOG.info("Unregistering the CarDataTreeChangeListener(s)");
+        LOG_CAR_PROVIDER.info("Unregistering the CarDataTreeChangeListener(s)");
         synchronized (carsDtclRegistrations) {
             int numListeners = 0;
             for (ListenerRegistration<CarDataTreeChangeListener> carsDtclRegistration : carsDtclRegistrations) {
@@ -298,7 +298,7 @@ public class CarProvider implements CarService {
                 numListeners++;
             }
             carsDtclRegistrations.clear();
-            LOG.info("Unregistered {} CaraDataTreeChangeListener(s)", numListeners);
+            LOG_CAR_PROVIDER.info("Unregistered {} CaraDataTreeChangeListener(s)", numListeners);
         }
         return RpcResultBuilder.<Void>success().buildFuture();
     }
@@ -310,7 +310,7 @@ public class CarProvider implements CarService {
         if (reg != null) {
             try {
                 reg.close();
-                LOG.info("Unregistered commit cohort");
+                LOG_CAR_PROVIDER.info("Unregistered commit cohort");
             } catch (Exception e) {
                 return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION,
                         "Error closing commit cohort registration", e).buildFuture();
@@ -348,7 +348,7 @@ public class CarProvider implements CarService {
                     org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION,
                         carEntryPath), new CarEntryDataTreeCommitCohort()));
 
-        LOG.info("Registered commit cohort");
+        LOG_CAR_PROVIDER.info("Registered commit cohort");
 
         return RpcResultBuilder.<Void>success().buildFuture();
     }
index 6301188cc70b954645cb36c0d86de796c08421f6..48385b4e2f95cf944565845d9858c682a99392e4 100644 (file)
@@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory;
 
 public class PeopleProvider implements PeopleService, AutoCloseable {
 
-  private static final Logger log = LoggerFactory.getLogger(PeopleProvider.class);
+  private static final Logger LOG = LoggerFactory.getLogger(PeopleProvider.class);
 
   private DataBroker dataProvider;
 
@@ -49,7 +49,7 @@ public class PeopleProvider implements PeopleService, AutoCloseable {
 
   @Override
   public Future<RpcResult<Void>> addPerson(AddPersonInput input) {
-    log.info("RPC addPerson : adding person [{}]", input);
+    LOG.info("RPC addPerson : adding person [{}]", input);
 
     PersonBuilder builder = new PersonBuilder(input);
     final Person person = builder.build();
@@ -67,15 +67,15 @@ public class PeopleProvider implements PeopleService, AutoCloseable {
     Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
       @Override
       public void onSuccess(final Void result) {
-        log.info("RPC addPerson : person added successfully [{}]", person);
+        LOG.info("RPC addPerson : person added successfully [{}]", person);
         rpcRegistration.registerPath(PersonContext.class, personId);
-        log.info("RPC addPerson : routed rpc registered for instance ID [{}]", personId);
+        LOG.info("RPC addPerson : routed rpc registered for instance ID [{}]", personId);
         futureResult.set(RpcResultBuilder.<Void>success().build());
       }
 
       @Override
       public void onFailure(final Throwable t) {
-        log.error(String.format("RPC addPerson : person addition failed [%s]", person), t);
+        LOG.error(String.format("RPC addPerson : person addition failed [%s]", person), t);
         futureResult.set(RpcResultBuilder.<Void>failed()
             .withError(RpcError.ErrorType.APPLICATION, t.getMessage()).build());
       }
index 74a0aa68ed91dcac50dbb3714421ffd77f70efe8..c31a508b753fc28266e4fa614ba6ecb9214e9967 100644 (file)
@@ -23,7 +23,7 @@ import java.util.concurrent.Future;
 
 public class PurchaseCarProvider implements CarPurchaseService, AutoCloseable{
 
-  private static final Logger log = LoggerFactory.getLogger(PurchaseCarProvider.class);
+  private static final Logger LOG = LoggerFactory.getLogger(PurchaseCarProvider.class);
 
   private NotificationProviderService notificationProvider;
 
@@ -35,7 +35,7 @@ public class PurchaseCarProvider implements CarPurchaseService, AutoCloseable{
 
   @Override
   public Future<RpcResult<Void>> buyCar(BuyCarInput input) {
-    log.info("Routed RPC buyCar : generating notification for buying car [{}]", input);
+    LOG.info("Routed RPC buyCar : generating notification for buying car [{}]", input);
     SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create();
     CarBoughtBuilder carBoughtBuilder = new CarBoughtBuilder();
     carBoughtBuilder.setCarId(input.getCarId());