Fix checkstyle violations in openflow-protocol-impl - part 1 82/67382/2
authorTom Pantelis <tompantelis@gmail.com>
Sat, 20 Jan 2018 19:43:20 +0000 (14:43 -0500)
committerTom Pantelis <tompantelis@gmail.com>
Sat, 27 Jan 2018 02:29:53 +0000 (21:29 -0500)
Many violations - more to follow

Change-Id: I3467223dd8ab3a9fe52906a2b029b0ab130b0b7d
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
55 files changed:
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ConnectionInitializer.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandler.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDecoder.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFEncoder.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFFrameDecoder.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OnlineProvider.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ServerFacade.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ShutdownProvider.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslContextFactory.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SslKeyStore.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderFactoryImpl.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpChannelInitializer.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageWrapper.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractConnectionAdapter.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractConnectionAdapterStatistics.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractOutboundQueueManager.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractRpcListener.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/AbstractStackedOutboundQueue.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueue.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactory.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterFactoryImpl.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionFacade.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageConsumer.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueHandlerRegistrationImpl.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManagerNoBarrier.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListener.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/RpcResponseKey.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListener.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueueNoBarrier.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedSegment.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/AdditionalMessageDeserializerInitializer.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactory.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializerRegistryImpl.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageTypeCodeKey.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java

index 414f2c25f4676b93a23a1d00c5c59972d535c95c..7af10cc52d006b548a8dcde21951d0d4e396943f 100644 (file)
@@ -14,8 +14,9 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.Deserializati
 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
 
 /**
- * @author michal.polkorab
+ * Factory for ChannelInitializer instances.
  *
+ * @author michal.polkorab
  */
 public class ChannelInitializerFactory {
 
@@ -27,6 +28,8 @@ public class ChannelInitializerFactory {
     private boolean useBarrier;
 
     /**
+     * Creates a TCP publishing channel initializer.
+     *
      * @return PublishingChannelInitializer that initializes new channels
      */
     public TcpChannelInitializer createPublishingChannelInitializer() {
@@ -41,6 +44,8 @@ public class ChannelInitializerFactory {
     }
 
     /**
+     * Creates a UDP channel initializer.
+     *
      * @return PublishingChannelInitializer that initializes new channels
      */
     public UdpChannelInitializer createUdpChannelInitializer() {
@@ -53,44 +58,54 @@ public class ChannelInitializerFactory {
     }
 
     /**
-     * @param switchIdleTimeOut
+     * Sets the switch idle timeout.
+     *
+     * @param timeout the timeout
      */
-    public void setSwitchIdleTimeout(final long switchIdleTimeOut) {
-        this.switchIdleTimeOut = switchIdleTimeOut;
+    public void setSwitchIdleTimeout(final long timeout) {
+        this.switchIdleTimeOut = timeout;
     }
 
     /**
-     * @param deserializationFactory
+     * Sets the DeserializationFactory.
+     *
+     * @param deserializationFactory the DeserializationFactory
      */
     public void setDeserializationFactory(final DeserializationFactory deserializationFactory) {
         this.deserializationFactory = deserializationFactory;
     }
 
     /**
-     * @param serializationFactory
+     * Sets the SerializationFactory.
+     *
+     * @param serializationFactory the SerializationFactory
      */
     public void setSerializationFactory(final SerializationFactory serializationFactory) {
         this.serializationFactory = serializationFactory;
     }
 
     /**
-     * @param tlsConfig
+     * Sets the TlsConfiguration.
+     *
+     * @param tlsConfig the TlsConfiguration
      */
     public void setTlsConfig(final TlsConfiguration tlsConfig) {
         this.tlsConfig = tlsConfig;
     }
 
     /**
-     * @param switchConnectionHandler
+     * Sets the SwitchConnectionHandler.
+     *
+     * @param switchConnectionHandler the SwitchConnectionHandler
      */
     public void setSwitchConnectionHandler(final SwitchConnectionHandler switchConnectionHandler) {
         this.switchConnectionHandler = switchConnectionHandler;
     }
 
     /**
-     * @param useBarrier
+     * Sets whether or not to use a barrier.
      */
     public void setUseBarrier(final boolean useBarrier) {
         this.useBarrier = useBarrier;
     }
-}
\ No newline at end of file
+}
index 1e95c65c48d68c2f69cc10cd25c486cb02f2184d..acd65d826c96000ddbbfd38338099ef63271ac04 100644 (file)
@@ -9,13 +9,15 @@
 package org.opendaylight.openflowjava.protocol.impl.core;
 
 /**
- * @author martin.uhlir
+ * Interface for a connection initializer.
  *
+ * @author martin.uhlir
  */
 public interface ConnectionInitializer {
 
     /**
-     * Initiates connection towards device
+     * Initiates connection towards device.
+     *
      * @param host - host IP
      * @param port - port number
      */
index 5f408e6c6c9396073786cdef2adf78c079c6e057..8ef46bb184830af0494bf678b8f5f5544c274a3f 100644 (file)
@@ -10,15 +10,14 @@ package org.opendaylight.openflowjava.protocol.impl.core;
 
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.timeout.ReadTimeoutHandler;
-
 import java.util.concurrent.TimeUnit;
-
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Detects idle state of switch and informs upper layers
+ * Detects idle state of switch and informs upper layers.
+ *
  * @author michal.polkorab
  */
 public class IdleHandler extends ReadTimeoutHandler {
@@ -27,8 +26,7 @@ public class IdleHandler extends ReadTimeoutHandler {
     private boolean first = true;
 
     /**
-     * @param readerIdleTime
-     * @param unit
+     * Constructor.
      */
     public IdleHandler(final long readerIdleTime, final TimeUnit unit) {
         super(readerIdleTime, unit);
index 261beb9ce2564432ce9d8fc93cf3fb79b6d47964..cecbd42d5c8499aa0fac50149db939f1953c9f91 100644 (file)
@@ -18,20 +18,22 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * @author michal.polkorab
+ * Decoder for datagram packets.
  *
+ * @author michal.polkorab
  */
-public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler<VersionMessageUdpWrapper>{
+public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler<VersionMessageUdpWrapper> {
 
     private static final Logger LOG = LoggerFactory.getLogger(OFDatagramPacketDecoder.class);
     private DeserializationFactory deserializationFactory;
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public void channelRead0(final ChannelHandlerContext ctx, final VersionMessageUdpWrapper msg)
             throws Exception {
         if (LOG.isDebugEnabled()) {
-                LOG.debug("UdpVersionMessageWrapper received");
-                LOG.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
+            LOG.debug("UdpVersionMessageWrapper received");
+            LOG.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
         }
 
         try {
@@ -42,7 +44,7 @@ public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler<Version
                 MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.getAddress());
                 consumer.consume(dataObject);
             }
-        } catch(Exception e) {
+        } catch (RuntimeException e) {
             LOG.warn("Message deserialization failed", e);
             // TODO: delegate exception to allow easier deserialization
             // debugging / deserialization problem awareness
@@ -51,9 +53,6 @@ public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler<Version
         }
     }
 
-    /**
-     * @param deserializationFactory
-     */
     public void setDeserializationFactory(final DeserializationFactory deserializationFactory) {
         this.deserializationFactory = deserializationFactory;
     }
index 8b1faef30f33f6ee5a6eb7a51e598253467e4921..2f79241a18147af15dc0777a245794149899a882 100644 (file)
@@ -8,23 +8,22 @@
 
 package org.opendaylight.openflowjava.protocol.impl.core;
 
-import java.util.List;
-
-import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper;
-import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.PooledByteBufAllocator;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.socket.DatagramPacket;
 import io.netty.handler.codec.MessageToMessageEncoder;
 import io.netty.util.concurrent.Future;
+import java.util.List;
+import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper;
+import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
- * @author michal.polkorab
+ * Encoder for datagram packets.
  *
+ * @author michal.polkorab
  */
 public class OFDatagramPacketEncoder extends MessageToMessageEncoder<UdpMessageListenerWrapper> {
 
@@ -32,6 +31,7 @@ public class OFDatagramPacketEncoder extends MessageToMessageEncoder<UdpMessageL
     private SerializationFactory serializationFactory;
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void encode(ChannelHandlerContext ctx,
             UdpMessageListenerWrapper wrapper, List<Object> out) throws Exception {
         LOG.trace("Encoding");
@@ -39,7 +39,7 @@ public class OFDatagramPacketEncoder extends MessageToMessageEncoder<UdpMessageL
             ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
             serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), buffer, wrapper.getMsg());
             out.add(new DatagramPacket(buffer, wrapper.getAddress()));
-        } catch(Exception e) {
+        } catch (RuntimeException e) {
             LOG.warn("Message serialization failed: {}", e.getMessage());
             Future<Void> newFailedFuture = ctx.newFailedFuture(e);
             wrapper.getListener().operationComplete(newFailedFuture);
@@ -47,10 +47,7 @@ public class OFDatagramPacketEncoder extends MessageToMessageEncoder<UdpMessageL
         }
     }
 
-    /**
-     * @param serializationFactory
-     */
     public void setSerializationFactory(SerializationFactory serializationFactory) {
         this.serializationFactory = serializationFactory;
     }
-}
\ No newline at end of file
+}
index 0eb2916165f2e29ca5ab07e6321d5483d7b74a11..ec56052f8274e19b6eba42dd9f553394dd880d18 100644 (file)
@@ -12,9 +12,7 @@ import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.socket.DatagramPacket;
 import io.netty.handler.codec.MessageToMessageDecoder;
-
 import java.util.List;
-
 import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactory;
@@ -26,23 +24,24 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * @author michal.polkorab
+ * Handler for datagram packets.
  *
+ * @author michal.polkorab
  */
 public class OFDatagramPacketHandler extends MessageToMessageDecoder<DatagramPacket> {
 
     private static final Logger LOG = LoggerFactory.getLogger(OFDatagramPacketHandler.class);
 
-    /** Length of OpenFlow 1.3 header */
+    /** Length of OpenFlow 1.3 header. */
     public static final byte LENGTH_OF_HEADER = 8;
     private static final byte LENGTH_INDEX_IN_HEADER = 2;
-    private ConnectionAdapterFactory adapterFactory = new ConnectionAdapterFactoryImpl();
-    private SwitchConnectionHandler connectionHandler;
+    private final ConnectionAdapterFactory adapterFactory = new ConnectionAdapterFactoryImpl();
+    private final SwitchConnectionHandler connectionHandler;
 
     /**
-     * Default constructor
-     * @param sch the switchConnectionHandler that decides
-     * what to do with incomming message / channel
+     * Default constructor.
+     *
+     * @param sch the switchConnectionHandler that decides what to do with incomming message / channel
      */
     public OFDatagramPacketHandler(SwitchConnectionHandler sch) {
         this.connectionHandler = sch;
@@ -91,7 +90,7 @@ public class OFDatagramPacketHandler extends MessageToMessageDecoder<DatagramPac
 
 
         byte version = bb.readByte();
-        if ((version == EncodeConstants.OF13_VERSION_ID) || (version == EncodeConstants.OF10_VERSION_ID)) {
+        if (version == EncodeConstants.OF13_VERSION_ID || version == EncodeConstants.OF10_VERSION_ID) {
             LOG.debug("detected version: {}", version);
             ByteBuf messageBuffer = bb.slice();
             out.add(new VersionMessageUdpWrapper(version, messageBuffer, msg.sender()));
index 90d0ab0227dffe084be247402b0caccf8bf55e2e..35e22830746cda833b9ef18166dd536aa97d1b50 100644 (file)
@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
 
 /**
  * Transforms OpenFlow Protocol messages to POJOs.
+ *
  * @author michal.polkorab
  */
 public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
@@ -33,11 +34,12 @@ public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
 
     public OFDecoder() {
         LOG.trace("Creating OFDecoder");
-           // TODO: pass as argument
+        // TODO: pass as argument
         statisticsCounter = StatisticsCounters.getInstance();
     }
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg, List<Object> out) throws Exception {
         statisticsCounter.incrementCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA);
         if (LOG.isDebugEnabled()) {
@@ -55,7 +57,7 @@ public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
                 out.add(dataObject);
                 statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_SUCCESS);
             }
-        } catch (Exception e) {
+        } catch (RuntimeException e) {
             LOG.warn("Message deserialization failed", e);
             statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL);
         } finally {
@@ -63,9 +65,6 @@ public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
         }
     }
 
-    /**
-     * @param deserializationFactory
-     */
     public void setDeserializationFactory(DeserializationFactory deserializationFactory) {
         this.deserializationFactory = deserializationFactory;
     }
index 2f356693773803aac9b87628f77588f19c0299e8..ce165579fd83445bc2bb026a67fa9c6b94880554 100644 (file)
@@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
 
 /**
  * Transforms OpenFlow Protocol messages to POJOs.
+ *
  * @author michal.polkorab
  * @author timotej.kubas
  */
@@ -31,23 +32,23 @@ public class OFEncoder extends MessageToByteEncoder<MessageListenerWrapper> {
     private SerializationFactory serializationFactory;
     private final StatisticsCounters statisticsCounters;
 
-    /** Constructor of class */
     public OFEncoder() {
         statisticsCounters = StatisticsCounters.getInstance();
         LOG.trace("Creating OFEncoder");
     }
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void encode(final ChannelHandlerContext ctx, final MessageListenerWrapper wrapper, final ByteBuf out)
             throws Exception {
         LOG.trace("Encoding");
         try {
             serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), out, wrapper.getMsg());
-            if(wrapper.getMsg() instanceof FlowModInput){
+            if (wrapper.getMsg() instanceof FlowModInput) {
                 statisticsCounters.incrementCounter(CounterEventTypes.DS_FLOW_MODS_SENT);
             }
             statisticsCounters.incrementCounter(CounterEventTypes.DS_ENCODE_SUCCESS);
-        } catch(final Exception e) {
+        } catch (RuntimeException e) {
             LOG.warn("Message serialization failed ", e);
             statisticsCounters.incrementCounter(CounterEventTypes.DS_ENCODE_FAIL);
             if (wrapper.getListener() != null) {
@@ -59,9 +60,6 @@ public class OFEncoder extends MessageToByteEncoder<MessageListenerWrapper> {
         }
     }
 
-    /**
-     * @param serializationFactory
-     */
     public void setSerializationFactory(final SerializationFactory serializationFactory) {
         this.serializationFactory = serializationFactory;
     }
index a9c5ecd252325af820af76a7fbd413223fe9e830..a095280a9de889800dac4b77796aa19af3d56c0b 100644 (file)
@@ -20,15 +20,16 @@ import org.slf4j.LoggerFactory;
 
 /**
  * Decodes incoming messages into message frames.
+ *
  * @author michal.polkorab
  */
 public class OFFrameDecoder extends ByteToMessageDecoder {
 
-    /** Length of OpenFlow header */
+    /** Length of OpenFlow header. */
     public static final byte LENGTH_OF_HEADER = 8;
     private static final byte LENGTH_INDEX_IN_HEADER = 2;
     private static final Logger LOG = LoggerFactory.getLogger(OFFrameDecoder.class);
-    private ConnectionFacade connectionFacade;
+    private final ConnectionFacade connectionFacade;
     private boolean firstTlsPass = false;
 
     /**
index 8e23566af1fef8bf5fda007668787aff26c58f97..7ca6bfd75551cfffba87e9aeeef37f4f1fe072a3 100644 (file)
@@ -22,12 +22,13 @@ import org.slf4j.LoggerFactory;
 
 /**
  * Detects version of used OpenFlow Protocol and discards unsupported version messages.
+ *
  * @author michal.polkorab
  */
 public class OFVersionDetector extends ByteToMessageDecoder {
 
     private static final Logger LOG = LoggerFactory.getLogger(OFVersionDetector.class);
-    /** IDs of accepted OpenFlow protocol versions */
+    /** IDs of accepted OpenFlow protocol versions. */
     private static final List<Byte> OF_VERSIONS = new ArrayList<>(Arrays.asList(
             EncodeConstants.OF10_VERSION_ID,
             EncodeConstants.OF13_VERSION_ID
index 93b39d4f6798290368d9fda621a40b1d8a2d5398..c167dfb7f469dd72b1976dcd341dee312c6f0a58 100644 (file)
@@ -12,13 +12,11 @@ package org.opendaylight.openflowjava.protocol.impl.core;
 import com.google.common.util.concurrent.ListenableFuture;
 
 /**
+ * OnlineProvider.
+ *
  * @author mirehak
  */
 public interface OnlineProvider {
 
-    /**
-     * @return the isOnlineFuture
-     */
     ListenableFuture<Boolean> getIsOnlineFuture();
-
 }
index 88144d47be163db2bbffb9303a11c8174508867a..fca0069a8b69bfba0aa098f9c9fe06ceadbde254 100644 (file)
@@ -16,48 +16,57 @@ package org.opendaylight.openflowjava.protocol.impl.core;
 public enum PipelineHandlers {
 
     /**
-     * Detects switch idle state
+     * Detects switch idle state.
      */
     IDLE_HANDLER,
+
     /**
-     * Component for handling TLS frames
+     * Component for handling TLS frames.
      */
     SSL_HANDLER,
+
     /**
-     * Decodes incoming messages into message frames
+     * Decodes incoming messages into message frames.
      */
     OF_FRAME_DECODER,
+
     /**
-     * Detects version of incoming OpenFlow Protocol message
+     * Detects version of incoming OpenFlow Protocol message.
      */
     OF_VERSION_DETECTOR,
+
     /**
-     * Transforms OpenFlow Protocol byte messages into POJOs
+     * Transforms OpenFlow Protocol byte messages into POJOs.
      */
     OF_DECODER,
+
     /**
-     * Transforms POJOs into OpenFlow Protocol byte messages
+     * Transforms POJOs into OpenFlow Protocol byte messages.
      */
     OF_ENCODER,
+
     /**
-     * Delegates translated POJOs into MessageConsumer
+     * Delegates translated POJOs into MessageConsumer.
      */
     DELEGATING_INBOUND_HANDLER,
+
     /**
-     * Performs configurable efficient flushing
+     * Performs configurable efficient flushing.
      */
     CHANNEL_OUTBOUND_QUEUE_MANAGER,
+
     /**
-     * Decodes incoming messages into message frames
-     * and filters them based on version supported
+     * Decodes incoming messages into message frames and filters them based on version supported.
      */
     OF_DATAGRAMPACKET_HANDLER,
+
     /**
-     * Transforms OpenFlow Protocol datagram messages into POJOs
+     * Transforms OpenFlow Protocol datagram messages into POJOs.
      */
     OF_DATAGRAMPACKET_DECODER,
+
     /**
-     * Transforms POJOs into OpenFlow Protocol datagrams
+     * Transforms POJOs into OpenFlow Protocol datagrams.
      */
     OF_DATAGRAMPACKET_ENCODER
-}
\ No newline at end of file
+}
index ec4ffd4a94ee6389afd11170a1c0a019f758daf8..58e7977a3b57ebd3d9a928c1697a1d47f58a3c3a 100644 (file)
@@ -16,6 +16,8 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.Deserializati
 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
 
 /**
+ * Initializer for protocol channels.
+ *
  * @param <C> Channel type
  * @author michal.polkorab
  */
@@ -30,6 +32,8 @@ public abstract class ProtocolChannelInitializer<C extends Channel>
     private boolean useBarrier;
 
     /**
+     * Sets the SwitchConnectionHandler.
+     *
      * @param switchConnectionHandler the switchConnectionHandler to set
      */
     public void setSwitchConnectionHandler(final SwitchConnectionHandler switchConnectionHandler) {
@@ -37,79 +41,51 @@ public abstract class ProtocolChannelInitializer<C extends Channel>
     }
 
     /**
+     * Sets the switch idle timeout.
+     *
      * @param switchIdleTimeout the switchIdleTimeout to set
      */
     public void setSwitchIdleTimeout(final long switchIdleTimeout) {
         this.switchIdleTimeout = switchIdleTimeout;
     }
 
-    /**
-     * @param serializationFactory
-     */
     public void setSerializationFactory(final SerializationFactory serializationFactory) {
         this.serializationFactory = serializationFactory;
     }
 
-    /**
-     * @param deserializationFactory
-     */
     public void setDeserializationFactory(final DeserializationFactory deserializationFactory) {
         this.deserializationFactory = deserializationFactory;
     }
 
-    /**
-     * @param tlsConfiguration
-     */
     public void setTlsConfiguration(final TlsConfiguration tlsConfiguration) {
         this.tlsConfiguration = tlsConfiguration;
     }
 
-    /**
-     * @return switch connection handler
-     */
     public SwitchConnectionHandler getSwitchConnectionHandler() {
         return switchConnectionHandler;
     }
 
-    /**
-     * @return switch idle timeout
-     */
     public long getSwitchIdleTimeout() {
         return switchIdleTimeout;
     }
 
-    /**
-     * @return serialization factory
-     */
     public SerializationFactory getSerializationFactory() {
         return serializationFactory;
     }
 
-    /**
-     * @return deserialization factory
-     */
     public DeserializationFactory getDeserializationFactory() {
         return deserializationFactory;
     }
 
-    /**
-     * @return TLS configuration
-     */
     public TlsConfiguration getTlsConfiguration() {
         return tlsConfiguration;
     }
 
-    /**
-     * @param useBarrier
-     */
     public void setUseBarrier(final boolean useBarrier) {
         this.useBarrier = useBarrier;
     }
 
-    /**
-     * @return useBarrrier
-     */
     public boolean useBarrier() {
         return useBarrier;
     }
-}
\ No newline at end of file
+}
index 560e910ea8520873bd3dd7f8c492d1cbc72ea642..18c80e34c268feb57dda1be68e6b576572a14073 100644 (file)
@@ -12,12 +12,15 @@ package org.opendaylight.openflowjava.protocol.impl.core;
 import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration;
 
 /**
+ * Server facade interface.
+ *
  * @author mirehak
  */
 public interface ServerFacade extends ShutdownProvider, OnlineProvider, Runnable {
 
     /**
-     * Sets thread configuration
+     * Sets thread configuration.
+     *
      * @param threadConfig desired thread configuration
      */
     void setThreadConfig(ThreadConfiguration threadConfig);
index 15978def520e0cdbac50b30590a71b03576de436..b6d6f73fd272fe938f95a24bdea28a185cc5d815 100644 (file)
@@ -13,13 +13,11 @@ import com.google.common.util.concurrent.ListenableFuture;
 
 
 /**
+ * Shutdown provider interface.
+ *
  * @author mirehak
  */
 public interface ShutdownProvider {
 
-    /**
-     * @return shutdown future
-     */
     ListenableFuture<Boolean> shutdown();
-
 }
index dbaa207022892125cd4167d2705a9723a259ea4b..993fbedea745dbff6dd3685b08bd71e94a793bbf 100644 (file)
@@ -9,15 +9,16 @@
 package org.opendaylight.openflowjava.protocol.impl.core;
 
 import java.io.IOException;
+import java.security.KeyManagementException;
 import java.security.KeyStore;
+import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 import java.security.Security;
+import java.security.UnrecoverableKeyException;
 import java.security.cert.CertificateException;
-
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.TrustManagerFactory;
-
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -32,12 +33,14 @@ public class SslContextFactory {
     // "TLS" - supports some version of TLS
     // Use "TLSv1", "TLSv1.1", "TLSv1.2" for specific TLS version
     private static final String PROTOCOL = "TLS";
-    private TlsConfiguration tlsConfig;
+    private final TlsConfiguration tlsConfig;
 
     private static final Logger LOG = LoggerFactory
             .getLogger(SslContextFactory.class);
 
     /**
+     * Sets the TlsConfiguration.
+     *
      * @param tlsConfig
      *            TLS configuration object, contains keystore locations +
      *            keystore types
@@ -46,9 +49,6 @@ public class SslContextFactory {
         this.tlsConfig = tlsConfig;
     }
 
-    /**
-     * @return servercontext
-     */
     public SSLContext getServerContext() {
         String algorithm = Security
                 .getProperty("ssl.KeyManagerFactory.algorithm");
@@ -80,7 +80,7 @@ public class SslContextFactory {
         } catch (CertificateException e) {
             LOG.warn("CertificateException - Unable to access certificate (check password)."
                     + " Failed to initialize the server-side SSLContext", e);
-        } catch (Exception e) {
+        } catch (KeyManagementException | KeyStoreException | UnrecoverableKeyException e) {
             LOG.warn("Exception - Failed to initialize the server-side SSLContext", e);
         }
         return serverContext;
index e4efea9f765dcfdcfc58cc46537148cba747b863..df25d57535f0e4ac6e2dbaadd99820b02051312b 100644 (file)
@@ -12,13 +12,12 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.InputStream;
-
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Class for storing keys
+ * Class for storing keys.
  *
  * @author michal.polkorab
  */
@@ -31,7 +30,8 @@ public final class SslKeyStore {
     }
 
     /**
-     * InputStream instance of key - key location is on classpath
+     * InputStream instance of key - key location is on classpath.
+     *
      * @param filename keystore location
      * @param pathType keystore location type - "classpath" or "path"
      *
@@ -40,26 +40,26 @@ public final class SslKeyStore {
     public static InputStream asInputStream(String filename, PathType pathType) {
         InputStream in;
         switch (pathType) {
-        case CLASSPATH:
-            in = SslKeyStore.class.getResourceAsStream(filename);
-            if (in == null) {
-                throw new IllegalStateException("KeyStore file not found: "
-                        + filename);
-            }
-            break;
-        case PATH:
-            LOG.debug("Current dir using System:"
-                    + System.getProperty("user.dir"));
-            File keystorefile = new File(filename);
-            try {
-                in = new FileInputStream(keystorefile);
-            } catch (FileNotFoundException e) {
-                throw new IllegalStateException("KeyStore file not found: "
-                        + filename,e);
-            }
-            break;
-        default:
-            throw new IllegalArgumentException("Unknown path type: " + pathType);
+            case CLASSPATH:
+                in = SslKeyStore.class.getResourceAsStream(filename);
+                if (in == null) {
+                    throw new IllegalStateException("KeyStore file not found: "
+                            + filename);
+                }
+                break;
+            case PATH:
+                LOG.debug("Current dir using System:"
+                        + System.getProperty("user.dir"));
+                File keystorefile = new File(filename);
+                try {
+                    in = new FileInputStream(keystorefile);
+                } catch (FileNotFoundException e) {
+                    throw new IllegalStateException("KeyStore file not found: "
+                            + filename,e);
+                }
+                break;
+            default:
+                throw new IllegalArgumentException("Unknown path type: " + pathType);
         }
         return in;
     }
index bf1dea3e3659df14b8f0d588078426e44e79aecc..4ad0097dc793dc9642492feef8de35e8b930e27e 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.openflowjava.protocol.impl.core;
 
 import com.google.common.base.MoreObjects;
-import com.google.common.base.Throwables;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.List;
@@ -64,13 +63,13 @@ public class SwitchConnectionProviderFactoryImpl implements SwitchConnectionProv
         private final SwitchConnectionConfig config;
         private InetAddress address;
 
-        private ConnectionConfigurationImpl(SwitchConnectionConfig config) {
+        ConnectionConfigurationImpl(SwitchConnectionConfig config) {
             this.config = config;
 
             try {
                 address = extractIpAddressBin(config.getAddress());
-            } catch(UnknownHostException e) {
-                Throwables.propagate(e);
+            } catch (UnknownHostException e) {
+                throw new RuntimeException(e);
             }
         }
 
@@ -92,7 +91,7 @@ public class SwitchConnectionProviderFactoryImpl implements SwitchConnectionProv
         @Override
         public TlsConfiguration getTlsConfiguration() {
             final Tls tlsConfig = config.getTls();
-            if(tlsConfig == null || !(TransportProtocol.TLS.equals(getTransferProtocol()))) {
+            if (tlsConfig == null || !TransportProtocol.TLS.equals(getTransferProtocol())) {
                 return null;
             }
 
@@ -101,38 +100,49 @@ public class SwitchConnectionProviderFactoryImpl implements SwitchConnectionProv
                 public KeystoreType getTlsTruststoreType() {
                     return MoreObjects.firstNonNull(tlsConfig.getTruststoreType(), null);
                 }
+
                 @Override
                 public String getTlsTruststore() {
                     return MoreObjects.firstNonNull(tlsConfig.getTruststore(), null);
                 }
+
                 @Override
                 public KeystoreType getTlsKeystoreType() {
                     return MoreObjects.firstNonNull(tlsConfig.getKeystoreType(), null);
                 }
+
                 @Override
                 public String getTlsKeystore() {
                     return MoreObjects.firstNonNull(tlsConfig.getKeystore(), null);
                 }
+
                 @Override
-                public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType getTlsKeystorePathType() {
+                public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType
+                        getTlsKeystorePathType() {
                     return MoreObjects.firstNonNull(tlsConfig.getKeystorePathType(), null);
                 }
+
                 @Override
-                public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType getTlsTruststorePathType() {
+                public org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType
+                        getTlsTruststorePathType() {
                     return MoreObjects.firstNonNull(tlsConfig.getTruststorePathType(), null);
                 }
+
                 @Override
                 public String getKeystorePassword() {
                     return MoreObjects.firstNonNull(tlsConfig.getKeystorePassword(), null);
                 }
+
                 @Override
                 public String getCertificatePassword() {
                     return MoreObjects.firstNonNull(tlsConfig.getCertificatePassword(), null);
                 }
+
                 @Override
                 public String getTruststorePassword() {
                     return MoreObjects.firstNonNull(tlsConfig.getTruststorePassword(), null);
                 }
+
                 @Override
                 public List<String> getCipherSuites() {
                     return tlsConfig.getCipherSuites();
@@ -153,7 +163,7 @@ public class SwitchConnectionProviderFactoryImpl implements SwitchConnectionProv
         @Override
         public ThreadConfiguration getThreadConfiguration() {
             final Threads threads = config.getThreads();
-            if(threads == null) {
+            if (threads == null) {
                 return null;
             }
 
index 7474a311222e3b532f42dad2df36ec30abe738ec..be60738b5f1e7fed2c6f21ddfd27021d8064681c 100755 (executable)
@@ -34,11 +34,11 @@ import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory;
 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
-import org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
@@ -52,7 +52,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Exposed class for server handling<br>
+ * Exposed class for server handling<br>
  * C - {@link MatchEntrySerializerKey} parameter representing oxm_class (see specification)<br>
  * F - {@link MatchEntrySerializerKey} parameter representing oxm_field (see specification)
  * @author mirehak
@@ -95,7 +95,7 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
     @Override
     public ListenableFuture<Boolean> shutdown() {
         LOG.debug("Shutdown summoned");
-        if(serverFacade == null){
+        if (serverFacade == null) {
             LOG.warn("Can not shutdown - not configured or started");
             throw new IllegalStateException("SwitchConnectionProvider is not started or not configured.");
         }
@@ -103,6 +103,7 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
     }
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public ListenableFuture<Boolean> startup() {
         LOG.debug("Startup summoned");
         ListenableFuture<Boolean> result = null;
@@ -113,7 +114,7 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
             }
             new Thread(serverFacade).start();
             result = serverFacade.getIsOnlineFuture();
-        } catch (final Exception e) {
+        } catch (RuntimeException e) {
             final SettableFuture<Boolean> exResult = SettableFuture.create();
             exResult.setException(e);
             result = exResult;
@@ -121,9 +122,6 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
         return result;
     }
 
-    /**
-     * @return
-     */
     private ServerFacade createAndConfigureServer() {
         LOG.debug("Configuring ..");
         ServerFacade server = null;
@@ -140,7 +138,7 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
         // TODO : Add option to disable Epoll.
         boolean isEpollEnabled = Epoll.isAvailable();
 
-        if ((TransportProtocol.TCP.equals(transportProtocol) || TransportProtocol.TLS.equals(transportProtocol))) {
+        if (TransportProtocol.TCP.equals(transportProtocol) || TransportProtocol.TLS.equals(transportProtocol)) {
             server = new TcpHandler(connConfig.getAddress(), connConfig.getPort());
             final TcpChannelInitializer channelInitializer = factory.createPublishingChannelInitializer();
             ((TcpHandler) server).setChannelInitializer(channelInitializer);
@@ -150,7 +148,7 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
             connectionInitializer = new TcpConnectionInitializer(workerGroupFromTcpHandler, isEpollEnabled);
             connectionInitializer.setChannelInitializer(channelInitializer);
             connectionInitializer.run();
-        } else if (TransportProtocol.UDP.equals(transportProtocol)){
+        } else if (TransportProtocol.UDP.equals(transportProtocol)) {
             server = new UdpHandler(connConfig.getAddress(), connConfig.getPort());
             ((UdpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration(), isEpollEnabled);
             ((UdpHandler) server).setChannelInitializer(factory.createUdpChannelInitializer());
@@ -161,9 +159,6 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
         return server;
     }
 
-    /**
-     * @return servers
-     */
     public ServerFacade getServerFacade() {
         return serverFacade;
     }
@@ -208,8 +203,8 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
     }
 
     @Override
-    public <C extends OxmClassBase, F extends MatchField> void registerMatchEntrySerializer(final MatchEntrySerializerKey<C, F> key,
-            final OFGeneralSerializer serializer) {
+    public <C extends OxmClassBase, F extends MatchField> void registerMatchEntrySerializer(
+            final MatchEntrySerializerKey<C, F> key, final OFGeneralSerializer serializer) {
         serializerRegistry.registerSerializer(key, serializer);
     }
 
@@ -227,13 +222,13 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
 
     @Override
     public void registerExperimenterMessageDeserializer(ExperimenterIdDeserializerKey key,
-                                                        OFDeserializer<? extends ExperimenterDataOfChoice> deserializer) {
+            OFDeserializer<? extends ExperimenterDataOfChoice> deserializer) {
         deserializerRegistry.registerDeserializer(key, deserializer);
     }
 
     @Override
     public void registerMultipartReplyMessageDeserializer(ExperimenterIdDeserializerKey key,
-                                                          OFDeserializer<? extends ExperimenterDataOfChoice> deserializer) {
+            OFDeserializer<? extends ExperimenterDataOfChoice> deserializer) {
         deserializerRegistry.registerDeserializer(key, deserializer);
     }
 
@@ -256,8 +251,9 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
     }
 
     @Override
-    public void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey<? extends ExperimenterDataOfChoice> key,
-                                                      OFSerializer<? extends ExperimenterDataOfChoice> serializer) {
+    public void registerExperimenterMessageSerializer(
+            ExperimenterIdSerializerKey<? extends ExperimenterDataOfChoice> key,
+            OFSerializer<? extends ExperimenterDataOfChoice> serializer) {
         serializerRegistry.registerSerializer(key, serializer);
     }
 
@@ -273,11 +269,13 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
         serializerRegistry.registerSerializer(key, serializer);
     }
 
-    @Override
     /**
-     * @deprecated Since we have used ExperimenterIdMeterSubTypeSerializerKey as MeterBandSerializer's key, in order to avoid
-     * the occurrence of an error, we should discard this function
+     * Deprecated.
+     *
+     * @deprecated Since we have used ExperimenterIdMeterSubTypeSerializerKey as MeterBandSerializer's key, in order
+     *     to avoid the occurrence of an error, we should discard this function.
      */
+    @Override
     @Deprecated
     public void registerMeterBandSerializer(final ExperimenterIdSerializerKey<MeterBandExperimenterCase> key,
             final OFSerializer<MeterBandExperimenterCase> serializer) {
@@ -285,8 +283,9 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
     }
 
     @Override
-    public void registerMeterBandSerializer(final ExperimenterIdMeterSubTypeSerializerKey<MeterBandExperimenterCase> key,
-                                            final OFSerializer<MeterBandExperimenterCase> serializer) {
+    public void registerMeterBandSerializer(
+            final ExperimenterIdMeterSubTypeSerializerKey<MeterBandExperimenterCase> key,
+            final OFSerializer<MeterBandExperimenterCase> serializer) {
         serializerRegistry.registerSerializer(key, serializer);
     }
 
@@ -300,14 +299,14 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
         return this.connConfig;
     }
 
-     @Override
+    @Override
     public <K> void registerSerializer(MessageTypeKey<K> key, OFGeneralSerializer serializer) {
         serializerRegistry.registerSerializer(key, serializer);
     }
 
     @Override
     public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer) {
-       deserializerRegistry.registerDeserializer(key, deserializer);
+        deserializerRegistry.registerDeserializer(key, deserializer);
     }
 
     @Override
index 9e6e2f1401e6c16e8206b9bd6c6a216e820d8b47..e7abda93fb11da7aeba82d029c1cffb7e2256d74 100644 (file)
@@ -13,7 +13,6 @@ import io.netty.channel.group.DefaultChannelGroup;
 import io.netty.channel.socket.SocketChannel;
 import io.netty.handler.ssl.SslHandler;
 import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.GenericFutureListener;
 import java.net.InetAddress;
 import java.util.Iterator;
 import java.util.List;
@@ -39,25 +38,27 @@ public class TcpChannelInitializer extends ProtocolChannelInitializer<SocketChan
      * Default constructor.
      */
     public TcpChannelInitializer() {
-        this( new DefaultChannelGroup("netty-receiver", null), new ConnectionAdapterFactoryImpl() );
+        this(new DefaultChannelGroup("netty-receiver", null), new ConnectionAdapterFactoryImpl());
     }
 
     /**
      * Testing constructor.
      */
-    protected TcpChannelInitializer( final DefaultChannelGroup channelGroup, final ConnectionAdapterFactory connAdaptorFactory ) {
-       allChannels = channelGroup ;
-       connectionAdapterFactory = connAdaptorFactory ;
+    protected TcpChannelInitializer(final DefaultChannelGroup channelGroup,
+            final ConnectionAdapterFactory connAdaptorFactory) {
+        allChannels = channelGroup;
+        connectionAdapterFactory = connAdaptorFactory;
     }
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void initChannel(final SocketChannel ch) {
         if (ch.remoteAddress() != null) {
             final InetAddress switchAddress = ch.remoteAddress().getAddress();
             final int port = ch.localAddress().getPort();
             final int remotePort = ch.remoteAddress().getPort();
             LOG.debug("Incoming connection from (remote address): {}:{} --> :{}",
-                           switchAddress.toString(), remotePort, port);
+                switchAddress.toString(), remotePort, port);
 
             if (!getSwitchConnectionHandler().accept(switchAddress)) {
                 ch.disconnect();
@@ -94,12 +95,7 @@ public class TcpChannelInitializer extends ProtocolChannelInitializer<SocketChan
                 final SslHandler ssl = new SslHandler(engine);
                 final Future<Channel> handshakeFuture = ssl.handshakeFuture();
                 final ConnectionFacade finalConnectionFacade = connectionFacade;
-                handshakeFuture.addListener(new GenericFutureListener<Future<? super Channel>>() {
-                    @Override
-                    public void operationComplete(final Future<? super Channel> future) throws Exception {
-                        finalConnectionFacade.fireConnectionReadyNotification();
-                    }
-                });
+                handshakeFuture.addListener(future -> finalConnectionFacade.fireConnectionReadyNotification());
                 ch.pipeline().addLast(PipelineHandlers.SSL_HANDLER.name(), ssl);
             }
             ch.pipeline().addLast(PipelineHandlers.OF_FRAME_DECODER.name(),
@@ -116,13 +112,15 @@ public class TcpChannelInitializer extends ProtocolChannelInitializer<SocketChan
             if (!tlsPresent) {
                 connectionFacade.fireConnectionReadyNotification();
             }
-        } catch (final Exception e) {
+        } catch (RuntimeException e) {
             LOG.warn("Failed to initialize channel", e);
             ch.close();
         }
     }
 
     /**
+     * Returns the connection iterator.
+     *
      * @return iterator through active connections
      */
     public Iterator<Channel> getConnectionIterator() {
@@ -130,6 +128,8 @@ public class TcpChannelInitializer extends ProtocolChannelInitializer<SocketChan
     }
 
     /**
+     * Returns the number of active channels.
+     *
      * @return amount of active channels
      */
     public int size() {
index d0a2fc63578fb79bbba2886c0f190a1bbb2aa98d..5d80d844f617f7e7994c3b687d81bae59d2b259e 100644 (file)
@@ -8,6 +8,9 @@
 
 package org.opendaylight.openflowjava.protocol.impl.core;
 
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.channel.EventLoopGroup;
 import io.netty.channel.epoll.EpollSocketChannel;
@@ -16,29 +19,26 @@ import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
-
 /**
- * Initializes (TCP) connection to device
- * @author martin.uhlir
+ * Initializes (TCP) connection to device.
  *
+ * @author martin.uhlir
  */
 public class TcpConnectionInitializer implements ServerFacade,
         ConnectionInitializer {
 
     private static final Logger LOG = LoggerFactory
             .getLogger(TcpConnectionInitializer.class);
-    private EventLoopGroup workerGroup;
+    private final EventLoopGroup workerGroup;
     private ThreadConfiguration threadConfig;
 
     private TcpChannelInitializer channelInitializer;
-    private Bootstrap b;
-    private boolean isEpollEnabled;
+    private Bootstrap bootstrap;
+    private final boolean isEpollEnabled;
 
     /**
-     * Constructor
+     * Constructor.
+     *
      * @param workerGroup - shared worker group
      */
     public TcpConnectionInitializer(EventLoopGroup workerGroup, boolean isEpollEnabled) {
@@ -49,12 +49,12 @@ public class TcpConnectionInitializer implements ServerFacade,
 
     @Override
     public void run() {
-        b = new Bootstrap();
-        if(isEpollEnabled) {
-            b.group(workerGroup).channel(EpollSocketChannel.class)
+        bootstrap = new Bootstrap();
+        if (isEpollEnabled) {
+            bootstrap.group(workerGroup).channel(EpollSocketChannel.class)
                     .handler(channelInitializer);
         } else {
-            b.group(workerGroup).channel(NioSocketChannel.class)
+            bootstrap.group(workerGroup).channel(NioSocketChannel.class)
                     .handler(channelInitializer);
         }
     }
@@ -79,15 +79,12 @@ public class TcpConnectionInitializer implements ServerFacade,
     @Override
     public void initiateConnection(String host, int port) {
         try {
-            b.connect(host, port).sync();
+            bootstrap.connect(host, port).sync();
         } catch (InterruptedException e) {
             LOG.error("Unable to initiate connection", e);
         }
     }
 
-    /**
-     * @param channelInitializer
-     */
     public void setChannelInitializer(TcpChannelInitializer channelInitializer) {
         this.channelInitializer = channelInitializer;
     }
index 9d36e931b82aac1db37ab007c5b4d6c1fe0a6d6d..0a48de11c2d37db1d14513091c39a53a7da7a001 100644 (file)
@@ -8,33 +8,27 @@
 
 package org.opendaylight.openflowjava.protocol.impl.core;
 
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
 import io.netty.bootstrap.ServerBootstrap;
 import io.netty.buffer.PooledByteBufAllocator;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
 import io.netty.channel.WriteBufferWaterMark;
+import io.netty.channel.epoll.EpollEventLoopGroup;
+import io.netty.channel.epoll.EpollServerSocketChannel;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.channel.socket.ServerSocketChannel;
 import io.netty.channel.socket.nio.NioServerSocketChannel;
 import io.netty.handler.logging.LogLevel;
 import io.netty.handler.logging.LoggingHandler;
-import io.netty.util.concurrent.GenericFutureListener;
-
-import io.netty.channel.epoll.Epoll;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.epoll.EpollEventLoopGroup;
-import io.netty.channel.epoll.EpollServerSocketChannel;
-
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
-
 import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
-
 /**
  * Class implementing server over TCP / TLS for handling incoming connections.
  *
@@ -103,8 +97,8 @@ public class TcpHandler implements ServerFacade {
 
         final ChannelFuture f;
         try {
-            ServerBootstrap b = new ServerBootstrap();
-            b.group(bossGroup, workerGroup)
+            ServerBootstrap bootstrap = new ServerBootstrap();
+            bootstrap.group(bossGroup, workerGroup)
                     .channel(socketChannelClass)
                     .handler(new LoggingHandler(LogLevel.DEBUG))
                     .childHandler(channelInitializer)
@@ -118,9 +112,9 @@ public class TcpHandler implements ServerFacade {
                     .childOption(ChannelOption.WRITE_SPIN_COUNT, DEFAULT_WRITE_SPIN_COUNT);
 
             if (startupAddress != null) {
-                f = b.bind(startupAddress.getHostAddress(), port).sync();
+                f = bootstrap.bind(startupAddress.getHostAddress(), port).sync();
             } else {
-                f = b.bind(port).sync();
+                f = bootstrap.bind(port).sync();
             }
         } catch (InterruptedException e) {
             LOG.error("Interrupted while binding port {}", port, e);
@@ -146,29 +140,24 @@ public class TcpHandler implements ServerFacade {
     }
 
     /**
-     * Shuts down {@link TcpHandler}}
+     * Shuts down {@link TcpHandler}}.
      */
     @Override
     public ListenableFuture<Boolean> shutdown() {
         final SettableFuture<Boolean> result = SettableFuture.create();
         workerGroup.shutdownGracefully();
         // boss will shutdown as soon, as worker is down
-        bossGroup.shutdownGracefully().addListener(new GenericFutureListener<io.netty.util.concurrent.Future<Object>>() {
-
-            @Override
-            public void operationComplete(
-                    final io.netty.util.concurrent.Future<Object> downResult) throws Exception {
-                result.set(downResult.isSuccess());
-                if (downResult.cause() != null) {
-                    result.setException(downResult.cause());
-                }
+        bossGroup.shutdownGracefully().addListener(downResult -> {
+            result.set(downResult.isSuccess());
+            if (downResult.cause() != null) {
+                result.setException(downResult.cause());
             }
-
         });
         return result;
     }
 
     /**
+     * Returns the number of connected clients / channels.
      *
      * @return number of connected clients / channels
      */
@@ -181,23 +170,14 @@ public class TcpHandler implements ServerFacade {
         return isOnlineFuture;
     }
 
-    /**
-     * @return the port
-     */
     public int getPort() {
         return port;
     }
 
-    /**
-     * @return the address
-     */
     public String getAddress() {
         return address;
     }
 
-    /**
-     * @param channelInitializer
-     */
     public void setChannelInitializer(TcpChannelInitializer channelInitializer) {
         this.channelInitializer = channelInitializer;
     }
@@ -208,12 +188,13 @@ public class TcpHandler implements ServerFacade {
     }
 
     /**
-     * Initiate event loop groups
+     * Initiate event loop groups.
+     *
      * @param threadConfiguration number of threads to be created, if not specified in threadConfig
      */
     public void initiateEventLoopGroups(ThreadConfiguration threadConfiguration, boolean isEpollEnabled) {
 
-        if(isEpollEnabled) {
+        if (isEpollEnabled) {
             initiateEpollEventLoopGroups(threadConfiguration);
         } else {
             initiateNioEventLoopGroups(threadConfiguration);
@@ -221,7 +202,8 @@ public class TcpHandler implements ServerFacade {
     }
 
     /**
-     * Initiate Nio event loop groups
+     * Initiate Nio event loop groups.
+     *
      * @param threadConfiguration number of threads to be created, if not specified in threadConfig
      */
     public void initiateNioEventLoopGroups(ThreadConfiguration threadConfiguration) {
@@ -237,14 +219,16 @@ public class TcpHandler implements ServerFacade {
     }
 
     /**
-     * Initiate Epoll event loop groups with Nio as fall back
-     * @param threadConfiguration
+     * Initiate Epoll event loop groups with Nio as fall back.
+     *
+     * @param threadConfiguration the ThreadConfiguration
      */
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void initiateEpollEventLoopGroups(ThreadConfiguration threadConfiguration) {
         try {
             socketChannelClass = EpollServerSocketChannel.class;
             if (threadConfiguration != null) {
-                    bossGroup = new EpollEventLoopGroup(threadConfiguration.getBossThreadCount());
+                bossGroup = new EpollEventLoopGroup(threadConfiguration.getBossThreadCount());
                 workerGroup = new EpollEventLoopGroup(threadConfiguration.getWorkerThreadCount());
             } else {
                 bossGroup = new EpollEventLoopGroup();
@@ -252,7 +236,7 @@ public class TcpHandler implements ServerFacade {
             }
             ((EpollEventLoopGroup)workerGroup).setIoRatio(100);
             return;
-        } catch (Throwable ex) {
+        } catch (RuntimeException ex) {
             LOG.debug("Epoll initiation failed");
         }
 
@@ -260,11 +244,7 @@ public class TcpHandler implements ServerFacade {
         initiateNioEventLoopGroups(threadConfiguration);
     }
 
-    /**
-     * @return workerGroup
-     */
     public EventLoopGroup getWorkerGroup() {
         return workerGroup;
     }
-
 }
index ccb8b06c7c95e8dc1fba73a15770135f5724477a..959dadb725118d0b59abf0bf569a90bb292c0d87 100644 (file)
@@ -11,8 +11,9 @@ package org.opendaylight.openflowjava.protocol.impl.core;
 import io.netty.channel.socket.DatagramChannel;
 
 /**
- * @author michal.polkorab
+ * UDP implementation of ChannelInitializer.
  *
+ * @author michal.polkorab
  */
 public class UdpChannelInitializer extends ProtocolChannelInitializer<DatagramChannel> {
 
@@ -28,4 +29,4 @@ public class UdpChannelInitializer extends ProtocolChannelInitializer<DatagramCh
         ofDatagramPacketEncoder.setSerializationFactory(getSerializationFactory());
         ch.pipeline().addLast(PipelineHandlers.OF_ENCODER.name(), ofDatagramPacketEncoder);
     }
-}
\ No newline at end of file
+}
index d23d5ada1c63d46ec99ba47dd64d54d6a4579de1..826685559e501d616f2ad2de03a997bd594c59a5 100644 (file)
@@ -11,12 +11,11 @@ package org.opendaylight.openflowjava.protocol.impl.core;
 import java.net.InetSocketAddress;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-
 import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer;
 
 /**
  * As UDP communication is handled only by one channel, it is needed
- * to store MessageConsumers, so that we know which consumer handles which channel
+ * to store MessageConsumers, so that we know which consumer handles which channel.
 
  * @author michal.polkorab
  */
@@ -29,34 +28,40 @@ public final class UdpConnectionMap {
     }
 
     /**
+     * Gets the MessageConsumer for the given address.
+     *
      * @param address sender's address
      * @return corresponding MessageConsumer
      */
     public static MessageConsumer getMessageConsumer(InetSocketAddress address) {
-        if(address == null){
+        if (address == null) {
             throw new IllegalArgumentException("Address can not be null");
         }
         return connectionMap.get(address);
     }
 
     /**
+     * Adds a connection.
+     *
      * @param address sender's address
      * @param consumer MessageConsumer to be added / paired with specified address
      */
     public static void addConnection(InetSocketAddress address, MessageConsumer consumer) {
-        if(address == null){
+        if (address == null) {
             throw new IllegalArgumentException("Address can not be null");
         }
         connectionMap.put(address, consumer);
     }
 
     /**
+     * Removes a connection.
+     *
      * @param address sender's address
      */
     public static void removeConnection(InetSocketAddress address) {
-        if(address == null){
+        if (address == null) {
             throw new IllegalArgumentException("Address can not be null");
         }
         connectionMap.remove(address);
     }
-}
\ No newline at end of file
+}
index 1dac7a593f6eb2414ad17fe7d5b4b3267bb27e38..144037dab7e8be32d94904024adb53e9e886e5fc 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.openflowjava.protocol.impl.core;
 
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelOption;
@@ -17,18 +19,12 @@ import io.netty.channel.epoll.EpollEventLoopGroup;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.channel.socket.DatagramChannel;
 import io.netty.channel.socket.nio.NioDatagramChannel;
-import io.netty.util.concurrent.GenericFutureListener;
-
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
-
 import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
-
 /**
  * Class implementing server over UDP for handling incoming connections.
  *
@@ -70,16 +66,14 @@ public final class UdpHandler implements ServerFacade {
     public void run() {
         final ChannelFuture f;
         try {
-            Bootstrap b = new Bootstrap();
-            b.group(group)
-             .channel(datagramChannelClass)
-             .option(ChannelOption.SO_BROADCAST, false)
-             .handler(channelInitializer);
+            Bootstrap bootstrap = new Bootstrap();
+            bootstrap.group(group).channel(datagramChannelClass).option(ChannelOption.SO_BROADCAST, false)
+                .handler(channelInitializer);
 
             if (startupAddress != null) {
-                f = b.bind(startupAddress.getHostAddress(), port).sync();
+                f = bootstrap.bind(startupAddress.getHostAddress(), port).sync();
             } else {
-                f = b.bind(port).sync();
+                f = bootstrap.bind(port).sync();
             }
         } catch (InterruptedException e) {
             LOG.error("Interrupted while binding port {}", port, e);
@@ -107,17 +101,11 @@ public final class UdpHandler implements ServerFacade {
     @Override
     public ListenableFuture<Boolean> shutdown() {
         final SettableFuture<Boolean> result = SettableFuture.create();
-        group.shutdownGracefully().addListener(new GenericFutureListener<io.netty.util.concurrent.Future<Object>>() {
-
-            @Override
-            public void operationComplete(
-                    final io.netty.util.concurrent.Future<Object> downResult) throws Exception {
-                result.set(downResult.isSuccess());
-                if (downResult.cause() != null) {
-                    result.setException(downResult.cause());
-                }
+        group.shutdownGracefully().addListener(downResult -> {
+            result.set(downResult.isSuccess());
+            if (downResult.cause() != null) {
+                result.setException(downResult.cause());
             }
-
         });
         return result;
     }
@@ -127,16 +115,10 @@ public final class UdpHandler implements ServerFacade {
         return isOnlineFuture;
     }
 
-    /**
-     * @return the port
-     */
     public int getPort() {
         return port;
     }
 
-    /**
-     * @param channelInitializer
-     */
     public void setChannelInitializer(UdpChannelInitializer channelInitializer) {
         this.channelInitializer = channelInitializer;
     }
@@ -147,12 +129,13 @@ public final class UdpHandler implements ServerFacade {
     }
 
     /**
-     * Initiate event loop groups
+     * Initiate event loop groups.
+     *
      * @param threadConfiguration number of threads to be created, if not specified in threadConfig
      */
     public void initiateEventLoopGroups(ThreadConfiguration threadConfiguration, boolean isEpollEnabled) {
 
-        if(isEpollEnabled) {
+        if (isEpollEnabled) {
             initiateEpollEventLoopGroups(threadConfiguration);
         } else {
             initiateNioEventLoopGroups(threadConfiguration);
@@ -160,7 +143,8 @@ public final class UdpHandler implements ServerFacade {
     }
 
     /**
-     * Initiate Nio event loop groups
+     * Initiate Nio event loop groups.
+     *
      * @param threadConfiguration number of threads to be created, if not specified in threadConfig
      */
     public void initiateNioEventLoopGroups(ThreadConfiguration threadConfiguration) {
@@ -173,9 +157,11 @@ public final class UdpHandler implements ServerFacade {
     }
 
     /**
-     * Initiate Epoll event loop groups with Nio as fall back
-     * @param threadConfiguration
+     * Initiate Epoll event loop groups with Nio as fall back.
+     *
+     * @param threadConfiguration the ThreadConfiguration
      */
+    @SuppressWarnings("checkstyle:IllegalCatch")
     protected void initiateEpollEventLoopGroups(ThreadConfiguration threadConfiguration) {
         try {
             datagramChannelClass = EpollDatagramChannel.class;
@@ -185,11 +171,11 @@ public final class UdpHandler implements ServerFacade {
                 group = new EpollEventLoopGroup();
             }
             return;
-        } catch (Throwable ex) {
+        } catch (RuntimeException ex) {
             LOG.debug("Epoll initiation failed");
         }
 
         //Fallback mechanism
         initiateNioEventLoopGroups(threadConfiguration);
     }
-}
\ No newline at end of file
+}
index 8f8d06413fb4f8ea19fd3744070651f01b8b83d6..fa2765330ea6ed681897809e0824115a9439c79b 100644 (file)
@@ -12,14 +12,16 @@ import io.netty.buffer.ByteBuf;
 import java.net.InetSocketAddress;
 
 /**
- * Wraps received messages (includes version) and sender address
-
+ * Wraps received messages (includes version) and sender address.
+ *
  * @author michal.polkorab
  */
 public class VersionMessageUdpWrapper extends VersionMessageWrapper {
     private final InetSocketAddress address;
 
     /**
+     * Constructor.
+     *
      * @param version Openflow wire version
      * @param messageBuffer ByteBuf containing binary message
      * @param address sender address
@@ -29,10 +31,7 @@ public class VersionMessageUdpWrapper extends VersionMessageWrapper {
         this.address = address;
     }
 
-    /**
-     * @return sender address
-     */
     public InetSocketAddress getAddress() {
         return address;
     }
-}
\ No newline at end of file
+}
index cdbe419c92866c5d658e5757686ece3ea238b3c6..825e385d9f8291e3f536a439a2e64b496c930d67 100644 (file)
@@ -12,7 +12,8 @@ import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 
 /**
- * Wraps received messages (includes version)
+ * Wraps received messages (includes version).
+ *
  * @author michal.polkorab
  */
 public class VersionMessageWrapper {
@@ -20,7 +21,8 @@ public class VersionMessageWrapper {
     private final ByteBuf messageBuffer;
 
     /**
-     * Constructor
+     * Constructor.
+     *
      * @param version version decoded in {@link OFVersionDetector}
      * @param messageBuffer message received from {@link OFFrameDecoder}
      */
@@ -30,6 +32,8 @@ public class VersionMessageWrapper {
     }
 
     /**
+     * Returns the version version decoded in {@link OFVersionDetector}.
+     *
      * @return the version version decoded in {@link OFVersionDetector}
      */
     public short getVersion() {
@@ -37,6 +41,8 @@ public class VersionMessageWrapper {
     }
 
     /**
+     * Returns the messageBuffer message received from {@link OFFrameDecoder}.
+     *
      * @return the messageBuffer message received from {@link OFFrameDecoder}
      */
     public ByteBuf getMessageBuffer() {
index 57f1498c8f32657b699bf697f60f7a3cf96d4f4b..db5229c91be83a49882ada690fcbf6c869037369 100644 (file)
@@ -14,12 +14,10 @@ import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.RemovalCause;
 import com.google.common.cache.RemovalListener;
-import com.google.common.cache.RemovalNotification;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
-import io.netty.util.concurrent.GenericFutureListener;
 import java.net.InetSocketAddress;
 import java.util.concurrent.Future;
 import java.util.concurrent.RejectedExecutionException;
@@ -68,7 +66,7 @@ abstract class AbstractConnectionAdapter implements ConnectionAdapter {
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractConnectionAdapter.class);
 
-    /** after this time, RPC future response objects will be thrown away (in minutes) */
+    /** after this time, RPC future response objects will be thrown away (in minutes). */
     private static final int RPC_RESPONSE_EXPIRATION = 1;
 
     private static final Exception QUEUE_FULL_EXCEPTION = new RejectedExecutionException("Output queue is full");
@@ -79,21 +77,19 @@ abstract class AbstractConnectionAdapter implements ConnectionAdapter {
      */
     private static final int DEFAULT_QUEUE_DEPTH = 1024;
 
-    protected static final RemovalListener<RpcResponseKey, ResponseExpectedRpcListener<?>> REMOVAL_LISTENER = new RemovalListener<RpcResponseKey, ResponseExpectedRpcListener<?>>() {
-        @Override
-        public void onRemoval(final RemovalNotification<RpcResponseKey, ResponseExpectedRpcListener<?>> notification) {
+    protected static final RemovalListener<RpcResponseKey, ResponseExpectedRpcListener<?>> REMOVAL_LISTENER =
+        notification -> {
             if (!notification.getCause().equals(RemovalCause.EXPLICIT)) {
                 notification.getValue().discard();
             }
-        }
-    };
+        };
 
     protected final Channel channel;
     protected final InetSocketAddress address;
     protected boolean disconnectOccured = false;
     protected final ChannelOutboundQueue output;
 
-    /** expiring cache for future rpcResponses */
+    /** expiring cache for future rpcResponses. */
     protected Cache<RpcResponseKey, ResponseExpectedRpcListener<?>> responseCache;
 
 
@@ -234,7 +230,8 @@ abstract class AbstractConnectionAdapter implements ConnectionAdapter {
     }
 
     /**
-     * Used only for testing purposes
+     * Used only for testing purposes.
+     *
      * @param cache replacement
      */
     @VisibleForTesting
@@ -243,15 +240,14 @@ abstract class AbstractConnectionAdapter implements ConnectionAdapter {
     }
 
     /**
-     * Return cached RpcListener or {@code null} if not cached
-     * @return
+     * Return cached RpcListener or {@code null} if not cached.
      */
     protected ResponseExpectedRpcListener<?> findRpcResponse(final RpcResponseKey key) {
         return responseCache.getIfPresent(key);
     }
 
     /**
-     * sends given message to switch, sending result or switch response will be reported via return value
+     * Sends given message to switch, sending result or switch response will be reported via return value.
      *
      * @param input message to send
      * @param responseClazz type of response
@@ -269,16 +265,17 @@ abstract class AbstractConnectionAdapter implements ConnectionAdapter {
      *         </li>
      *         </ul>
      */
-    protected <IN extends OfHeader, OUT extends OfHeader> ListenableFuture<RpcResult<OUT>> sendToSwitchExpectRpcResultFuture(
-            final IN input, final Class<OUT> responseClazz, final String failureInfo) {
+    protected <I extends OfHeader, O extends OfHeader> ListenableFuture<RpcResult<O>>
+            sendToSwitchExpectRpcResultFuture(final I input, final Class<O> responseClazz,
+                    final String failureInfo) {
         final RpcResponseKey key = new RpcResponseKey(input.getXid(), responseClazz.getName());
-        final ResponseExpectedRpcListener<OUT> listener = new ResponseExpectedRpcListener<>(input, failureInfo,
+        final ResponseExpectedRpcListener<O> listener = new ResponseExpectedRpcListener<>(input, failureInfo,
                 responseCache, key);
         return enqueueMessage(listener);
     }
 
     /**
-     * sends given message to switch, sending result will be reported via return value
+     * Sends given message to switch, sending result will be reported via return value.
      *
      * @param input message to send
      * @param failureInfo describes, what type of message caused failure by sending
@@ -305,25 +302,14 @@ abstract class AbstractConnectionAdapter implements ConnectionAdapter {
         return promise.getResult();
     }
 
-    /**
-     * @param resultFuture
-     * @param failureInfo
-     * @param errorSeverity
-     * @param message
-     * @return
-     */
     private static SettableFuture<Boolean> handleTransportChannelFuture(final ChannelFuture resultFuture) {
 
         final SettableFuture<Boolean> transportResult = SettableFuture.create();
 
-        resultFuture.addListener(new GenericFutureListener<io.netty.util.concurrent.Future<? super Void>>() {
-
-            @Override
-            public void operationComplete(final io.netty.util.concurrent.Future<? super Void> future) throws Exception {
-                transportResult.set(future.isSuccess());
-                if (!future.isSuccess()) {
-                    transportResult.setException(future.cause());
-                }
+        resultFuture.addListener(future -> {
+            transportResult.set(future.isSuccess());
+            if (!future.isSuccess()) {
+                transportResult.setException(future.cause());
             }
         });
         return transportResult;
index 20627b04c229c345f37f6168ed8e76d235401ce1..4a7a57785b3bd84bad6a063f09b3608b9c1214db 100644 (file)
@@ -42,8 +42,8 @@ abstract class AbstractConnectionAdapterStatistics extends AbstractConnectionAda
     }
 
     @Override
-    protected <IN extends OfHeader, OUT extends OfHeader> ListenableFuture<RpcResult<OUT>> sendToSwitchExpectRpcResultFuture(
-            final IN input, final Class<OUT> responseClazz, final String failureInfo) {
+    protected <I extends OfHeader, O extends OfHeader> ListenableFuture<RpcResult<O>> sendToSwitchExpectRpcResultFuture(
+            final I input, final Class<O> responseClazz, final String failureInfo) {
         statisticsCounters.incrementCounter(CounterEventTypes.DS_ENTERED_OFJAVA);
         return super.sendToSwitchExpectRpcResultFuture(input, responseClazz, failureInfo);
     }
@@ -69,7 +69,7 @@ abstract class AbstractConnectionAdapterStatistics extends AbstractConnectionAda
     /**
      * Method is equivalent to {@link MessageConsumer#consume(DataObject)} to prevent missing method
      * in every children of {@link AbstractConnectionAdapterStatistics} class, because we overriding
-     * original method for {@link StatisticsCounters}
+     * original method for {@link StatisticsCounters}.
      *
      * @param message from device to processing
      */
index f609610afcc5d3ac17902a9f208da91d1613b193..2252ab58f36963c05b2040f3547e90f523f6e7f5 100644 (file)
@@ -35,7 +35,7 @@ abstract class AbstractOutboundQueueManager<T extends OutboundQueueHandler, O ex
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractOutboundQueueManager.class);
 
-    private static enum PipelineState {
+    private enum PipelineState {
         /**
          * Netty thread is potentially idle, no assumptions
          * can be made about its state.
@@ -79,12 +79,7 @@ abstract class AbstractOutboundQueueManager<T extends OutboundQueueHandler, O ex
     protected boolean shuttingDown;
 
     // Passed to executor to request triggering of flush
-    protected final Runnable flushRunnable = new Runnable() {
-        @Override
-        public void run() {
-            flush();
-        }
-    };
+    protected final Runnable flushRunnable = () -> flush();
 
     AbstractOutboundQueueManager(final ConnectionAdapterImpl parent, final InetSocketAddress address, final T handler) {
         this.parent = Preconditions.checkNotNull(parent);
@@ -98,7 +93,7 @@ abstract class AbstractOutboundQueueManager<T extends OutboundQueueHandler, O ex
     }
 
     /**
-     * Method has to initialize some child of {@link AbstractStackedOutboundQueue}
+     * Method has to initialize some child of {@link AbstractStackedOutboundQueue}.
      *
      * @return correct implementation of StacketOutboundqueue
      */
@@ -224,15 +219,15 @@ abstract class AbstractOutboundQueueManager<T extends OutboundQueueHandler, O ex
         final PipelineState localState = state;
         LOG.debug("Synchronize on pipeline state {}", localState);
         switch (localState) {
-        case READING:
-            // Netty thread is currently reading, it will flush the pipeline once it
-            // finishes reading. This is a no-op situation.
-            break;
-        case WRITING:
-        case IDLE:
-        default:
-            // We cannot rely on the change being flushed, schedule a request
-            scheduleFlush();
+            case READING:
+                // Netty thread is currently reading, it will flush the pipeline once it
+                // finishes reading. This is a no-op situation.
+                break;
+            case WRITING:
+            case IDLE:
+            default:
+                // We cannot rely on the change being flushed, schedule a request
+                scheduleFlush();
         }
     }
 
@@ -251,9 +246,6 @@ abstract class AbstractOutboundQueueManager<T extends OutboundQueueHandler, O ex
      * Wraps outgoing message and includes listener attached to this message
      * which is send to OFEncoder for serialization. Correct wrapper is
      * selected by communication pipeline.
-     *
-     * @param message
-     * @param now
      */
     void writeMessage(final OfHeader message, final long now) {
         final Object wrapper = makeMessageListenerWrapper(message);
@@ -264,8 +256,6 @@ abstract class AbstractOutboundQueueManager<T extends OutboundQueueHandler, O ex
      * Wraps outgoing message and includes listener attached to this message
      * which is send to OFEncoder for serialization. Correct wrapper is
      * selected by communication pipeline.
-     *
-     * @return
      */
     protected Object makeMessageListenerWrapper(@Nonnull final OfHeader msg) {
         Preconditions.checkArgument(msg != null);
@@ -277,15 +267,9 @@ abstract class AbstractOutboundQueueManager<T extends OutboundQueueHandler, O ex
     }
 
     /* NPE are coming from {@link OFEncoder#encode} from catch block and we don't wish to lost it */
-    private static final GenericFutureListener<Future<Void>> LOG_ENCODER_LISTENER = new GenericFutureListener<Future<Void>>() {
-
-        private final Logger LOG = LoggerFactory.getLogger(GenericFutureListener.class);
-
-        @Override
-        public void operationComplete(final Future<Void> future) throws Exception {
-            if (future.cause() != null) {
-                LOG.warn("Message encoding fail !", future.cause());
-            }
+    private static final GenericFutureListener<Future<Void>> LOG_ENCODER_LISTENER = future -> {
+        if (future.cause() != null) {
+            LOG.warn("Message encoding fail !", future.cause());
         }
     };
 
@@ -302,10 +286,10 @@ abstract class AbstractOutboundQueueManager<T extends OutboundQueueHandler, O ex
         } else {
             close();
             if (currentQueue.finishShutdown(parent.getChannel())) {
-               LOG.debug("Channel {} shutdown complete", parent.getChannel());
+                LOG.debug("Channel {} shutdown complete", parent.getChannel());
             } else {
-               LOG.trace("Channel {} current queue not completely flushed yet", parent.getChannel());
-               rescheduleFlush();
+                LOG.trace("Channel {} current queue not completely flushed yet", parent.getChannel());
+                rescheduleFlush();
             }
         }
     }
index 7579cbd63057ed19141aaba0a9e6847a7095fc2b..15e12f18e3aa2b42e0dc0b7fb760925e956278f0 100644 (file)
@@ -24,7 +24,8 @@ import org.slf4j.LoggerFactory;
  * A MessageHolder (used in queue) and the actual listener. It is not a thing of beauty,
  * but it keeps us from allocating unnecessary objects in the egress path.
  */
-abstract class AbstractRpcListener<T> implements GenericFutureListener<Future<Void>>, ChannelOutboundQueue.MessageHolder<Object> {
+abstract class AbstractRpcListener<T> implements GenericFutureListener<Future<Void>>,
+        ChannelOutboundQueue.MessageHolder<Object> {
     private static final Logger LOG = LoggerFactory.getLogger(AbstractRpcListener.class);
     private static final String APPLICATION_TAG = "OPENFLOW_LIBRARY";
     private static final String TAG = "OPENFLOW";
@@ -33,12 +34,13 @@ abstract class AbstractRpcListener<T> implements GenericFutureListener<Future<Vo
     private Object message;
 
     /**
-     * Create RcpError object
-     * @param info
+     * Create RcpError object.
+     *
+     * @param info error info
      * @param severity - error severity
-     * @param message
+     * @param message error message
      * @param cause - details of reason
-     * @return
+     * @return RpcError
      */
     static RpcError buildRpcError(final String info, final String message, final Throwable cause) {
         return RpcResultBuilder.newError(ErrorType.RPC, TAG, message, APPLICATION_TAG, info, cause);
index b4356ee41ef03d88bcea34a5db87137fab95d8a5..774e62237b0bd84f84929465eca60be2a41f808c 100644 (file)
@@ -11,31 +11,24 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Verify;
 import com.google.common.util.concurrent.FutureCallback;
-
 import io.netty.channel.Channel;
-
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicLongFieldUpdater;
-import java.util.function.Function;
-
 import javax.annotation.Nonnull;
 import javax.annotation.concurrent.GuardedBy;
-
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 abstract class AbstractStackedOutboundQueue implements OutboundQueue {
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractStackedOutboundQueue.class);
-    protected static final AtomicLongFieldUpdater<AbstractStackedOutboundQueue> LAST_XID_OFFSET_UPDATER = AtomicLongFieldUpdater
-            .newUpdater(AbstractStackedOutboundQueue.class, "lastXid");
+    protected static final AtomicLongFieldUpdater<AbstractStackedOutboundQueue> LAST_XID_OFFSET_UPDATER =
+            AtomicLongFieldUpdater.newUpdater(AbstractStackedOutboundQueue.class, "lastXid");
 
     @GuardedBy("unflushedSegments")
     protected volatile StackedSegment firstSegment;
@@ -70,10 +63,12 @@ abstract class AbstractStackedOutboundQueue implements OutboundQueue {
     @GuardedBy("unflushedSegments")
     protected void ensureSegment(final StackedSegment first, final int offset) {
         final int segmentOffset = offset / StackedSegment.SEGMENT_SIZE;
-        LOG.debug("Queue {} slow offset {} maps to {} segments {}", this, offset, segmentOffset, unflushedSegments.size());
+        LOG.debug("Queue {} slow offset {} maps to {} segments {}", this, offset, segmentOffset,
+                unflushedSegments.size());
 
         for (int i = unflushedSegments.size(); i <= segmentOffset; ++i) {
-            final StackedSegment newSegment = StackedSegment.create(first.getBaseXid() + (StackedSegment.SEGMENT_SIZE * i));
+            final StackedSegment newSegment = StackedSegment.create(first.getBaseXid()
+                    + StackedSegment.SEGMENT_SIZE * i);
             LOG.debug("Adding segment {}", newSegment);
             unflushedSegments.add(newSegment);
         }
@@ -127,7 +122,7 @@ abstract class AbstractStackedOutboundQueue implements OutboundQueue {
      * in the corresponding EventLoop.
      *
      * @param channel Channel onto which we are writing
-     * @param now
+     * @param now time stamp
      * @return Number of entries written out
      */
     int writeEntries(@Nonnull final Channel channel, final long now) {
@@ -138,7 +133,8 @@ abstract class AbstractStackedOutboundQueue implements OutboundQueue {
         while (channel.isWritable()) {
             final OutboundQueueEntry entry = segment.getEntry(flushOffset);
             if (!entry.isCommitted()) {
-                LOG.debug("Queue {} XID {} segment {} offset {} not committed yet", this, segment.getBaseXid() + flushOffset, segment, flushOffset);
+                LOG.debug("Queue {} XID {} segment {} offset {} not committed yet", this, segment.getBaseXid()
+                        + flushOffset, segment, flushOffset);
                 break;
             }
 
@@ -279,7 +275,8 @@ abstract class AbstractStackedOutboundQueue implements OutboundQueue {
 
     /**
      * Checks if the shutdown is in final phase -> all allowed entries (number of entries < shutdownOffset) are flushed
-     * and fails all not completed entries (if in final phase)
+     * and fails all not completed entries (if in final phase).
+     *
      * @param channel netty channel
      * @return true if in final phase, false if a flush is needed
      */
@@ -303,7 +300,8 @@ abstract class AbstractStackedOutboundQueue implements OutboundQueue {
     protected OutboundQueueEntry getEntry(final Long xid) {
         final StackedSegment fastSegment = firstSegment;
         final long calcOffset = xid - fastSegment.getBaseXid();
-        Preconditions.checkArgument(calcOffset >= 0, "Commit of XID %s does not match up with base XID %s", xid, fastSegment.getBaseXid());
+        Preconditions.checkArgument(calcOffset >= 0, "Commit of XID %s does not match up with base XID %s",
+                xid, fastSegment.getBaseXid());
 
         Verify.verify(calcOffset <= Integer.MAX_VALUE);
         final int fastOffset = (int) calcOffset;
@@ -324,14 +322,16 @@ abstract class AbstractStackedOutboundQueue implements OutboundQueue {
             }
 
             final int segOffset = slowOffset % StackedSegment.SEGMENT_SIZE;
-            LOG.debug("Queue {} slow commit of XID {} completed at offset {} (segment {} offset {})", this, xid, slowOffset, segment, segOffset);
+            LOG.debug("Queue {} slow commit of XID {} completed at offset {} (segment {} offset {})", this,
+                    xid, slowOffset, segment, segOffset);
             return segment.getEntry(segOffset);
         }
         return fastSegment.getEntry(fastOffset);
     }
 
     /**
-     * Fails not completed entries in segments and frees completed segments
+     * Fails not completed entries in segments and frees completed segments.
+     *
      * @param iterator list of segments to be failed
      * @return number of failed entries
      */
@@ -352,5 +352,4 @@ abstract class AbstractStackedOutboundQueue implements OutboundQueue {
 
         return entries;
     }
-
 }
index 5845dff85ae683f18bf3282df11243576414339d..d9a30ffa9973df4dfde67442cf26133aaa2c0452 100644 (file)
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
  * writes to be enqueued from any thread, it then schedules a task pipeline task,
  * which shuffles messages from the queue into the pipeline.
  *
+ * <p>
  * Note this is an *Inbound* handler, as it reacts to channel writability changing,
  * which in the Netty vocabulary is an inbound event. This has already changed in
  * the Netty 5.0.0 API, where Handlers are unified.
@@ -75,12 +76,7 @@ final class ChannelOutboundQueue extends ChannelInboundHandlerAdapter {
     private static final Logger LOG = LoggerFactory.getLogger(ChannelOutboundQueue.class);
 
     // Passed to executor to request triggering of flush
-    private final Runnable flushRunnable = new Runnable() {
-        @Override
-        public void run() {
-            ChannelOutboundQueue.this.flush();
-        }
-    };
+    private final Runnable flushRunnable = () -> ChannelOutboundQueue.this.flush();
 
     /*
      * Instead of using an AtomicBoolean object, we use these two. It saves us
@@ -95,7 +91,7 @@ final class ChannelOutboundQueue extends ChannelInboundHandlerAdapter {
     private final Channel channel;
     private final InetSocketAddress address;
 
-    public ChannelOutboundQueue(final Channel channel, final int queueDepth, final InetSocketAddress address) {
+    ChannelOutboundQueue(final Channel channel, final int queueDepth, final InetSocketAddress address) {
         Preconditions.checkArgument(queueDepth > 0, "Queue depth has to be positive");
 
         /*
@@ -156,6 +152,12 @@ final class ChannelOutboundQueue extends ChannelInboundHandlerAdapter {
         scheduleFlush(channel.pipeline().lastContext().executor());
     }
 
+    private void conditionalFlush(final ChannelHandlerContext ctx) {
+        Preconditions.checkState(ctx.channel().equals(channel),
+                "Inconsistent channel %s with context %s", channel, ctx);
+        conditionalFlush();
+    }
+
     /*
      * The synchronized keyword should be unnecessary, really, but it enforces
      * queue order should something go terribly wrong. It should be completely
@@ -200,7 +202,7 @@ final class ChannelOutboundQueue extends ChannelInboundHandlerAdapter {
              *      should be able to perform dynamic adjustments here.
              *      is that additional complexity needed, though?
              */
-            if ((messages % WORKTIME_RECHECK_MSGS) == 0 && System.nanoTime() >= deadline) {
+            if (messages % WORKTIME_RECHECK_MSGS == 0 && System.nanoTime() >= deadline) {
                 LOG.trace("Exceeded allotted work time {}us",
                         TimeUnit.NANOSECONDS.toMicros(maxWorkTime));
                 break;
@@ -234,11 +236,6 @@ final class ChannelOutboundQueue extends ChannelInboundHandlerAdapter {
         conditionalFlush();
     }
 
-    private void conditionalFlush(final ChannelHandlerContext ctx) {
-        Preconditions.checkState(ctx.channel().equals(channel), "Inconsistent channel %s with context %s", channel, ctx);
-        conditionalFlush();
-    }
-
     @Override
     public void channelActive(final ChannelHandlerContext ctx) throws Exception {
         super.channelActive(ctx);
index 1b0a83a7a3e9e7fbd20fffe19dec3cb68784104f..00d2b160114d5491d38081a9d51a85c6d05a11b1 100644 (file)
@@ -13,15 +13,19 @@ import io.netty.channel.Channel;
 import java.net.InetSocketAddress;
 
 /**
+ * Factory for creating ConnectionFacade instances.
+ *
  * @author mirehak
  * @author michal.polkorab
  */
 public interface ConnectionAdapterFactory {
 
     /**
+     * Creates a ConnectionFacade.
+     *
      * @param ch {@link Channel} channel
      * @param address {@link InetSocketAddress}
-     * @param useBarrier
+     * @param useBarrier true to use a barrier, false otherwise
      * @return connection adapter tcp-implementation
      */
     ConnectionFacade createConnectionFacade(Channel ch, InetSocketAddress address, boolean useBarrier);
index 91871580ec4905c2d11e12fc72645c67a7fed25b..5ba136601154871f520c4bfb9c2e6b527dd33823 100644 (file)
@@ -13,19 +13,16 @@ import io.netty.channel.Channel;
 import java.net.InetSocketAddress;
 
 /**
+ * Implementation of ConnectionAdapterFactory.
+ *
  * @author mirehak
  * @author michal.polkorab
  */
 public class ConnectionAdapterFactoryImpl implements ConnectionAdapterFactory {
 
-    /**
-     * @param ch
-     * @return connection adapter tcp-implementation
-     */
-       @Override
+    @Override
     public ConnectionFacade createConnectionFacade(final Channel ch, final InetSocketAddress address,
             final boolean useBarrier) {
         return new ConnectionAdapterImpl(ch, address, useBarrier);
     }
-
 }
index c56ab4843e0c1a7c09efe0609874ba9cf56f28a0..86a200114128462dda3c3273787d96b1da11d6d2 100644 (file)
@@ -12,6 +12,8 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 
 /**
+ * Unifying super interface for a connection.
+ *
  * @author michal.polkorab
  */
 public interface ConnectionFacade extends MessageConsumer, ConnectionAdapter {
index 84c45cee91647f9c80fd28575932dc72c8ef1c9e..298b25ced26f89b54be903908160e7c8aff32a42 100644 (file)
@@ -12,11 +12,15 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
 /**
+ * Interface for a message consumer.
+ *
  * @author mirehak
  */
 public interface MessageConsumer {
 
     /**
+     * Invoked to consume a message.
+     *
      * @param message to process
      */
     void consume(DataObject message);
index 4b98fd8cfece67a7853356f8acc1a72dbfd357bf..daead2b130954e67d593822c14e8340ac28fa81a 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection;
 
 import io.netty.util.concurrent.Future;
 import io.netty.util.concurrent.GenericFutureListener;
-
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 
 /**
@@ -21,10 +20,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class MessageListenerWrapper {
 
-    private OfHeader msg;
-    private GenericFutureListener<Future<Void>> listener;
+    private final OfHeader msg;
+    private final GenericFutureListener<Future<Void>> listener;
 
     /**
+     * Constructor.
+     *
      * @param msg outgoing message
      * @param listener listener attached to channel.write(msg) Future
      */
@@ -34,6 +35,8 @@ public class MessageListenerWrapper {
     }
 
     /**
+     * Returns the outgoing message.
+     *
      * @return outgoing message (downstream)
      */
     public OfHeader getMsg() {
@@ -42,9 +45,11 @@ public class MessageListenerWrapper {
 
 
     /**
+     * Returns the listener listening on message sending success / failure.
+     *
      * @return listener listening on message sending success / failure
      */
     public GenericFutureListener<Future<Void>> getListener() {
         return listener;
     }
-}
\ No newline at end of file
+}
index d88566b8d3635efc24309b4c28ed791577ac7331..8881cad460cbaa081ef4598283bfab0e925008be 100644 (file)
@@ -45,22 +45,22 @@ final class OutboundQueueEntry {
     private OutboundQueueException lastException = null;
     private Function<OfHeader, Boolean> isCompletedFunction = DEFAULT_IS_COMPLETE;
 
-    void commit(final OfHeader message, final FutureCallback<OfHeader> callback) {
-        commit(message, callback, DEFAULT_IS_COMPLETE);
+    void commit(final OfHeader messageToCommit, final FutureCallback<OfHeader> commitCallback) {
+        commit(messageToCommit, commitCallback, DEFAULT_IS_COMPLETE);
     }
 
-    void commit(final OfHeader message, final FutureCallback<OfHeader> callback,
-            final Function<OfHeader, Boolean> isCompletedFunction) {
+    void commit(final OfHeader messageToCommit, final FutureCallback<OfHeader> commitCallback,
+            final Function<OfHeader, Boolean> isCommitCompletedFunction) {
         if (this.completed) {
             LOG.warn("Can't commit a completed message.");
-            if (callback != null) {
-                callback.onFailure(lastException);
+            if (commitCallback != null) {
+                commitCallback.onFailure(lastException);
             }
         } else {
-            this.message = message;
-            this.callback = callback;
-            this.barrier = message instanceof BarrierInput;
-            this.isCompletedFunction = isCompletedFunction;
+            this.message = messageToCommit;
+            this.callback = commitCallback;
+            this.barrier = messageToCommit instanceof BarrierInput;
+            this.isCompletedFunction = isCommitCompletedFunction;
 
             // Volatile write, needs to be last
             this.committed = true;
index 697d2ddd2197050a1b06dc0d71318d52909466e7..f70a50efd803dbea09616d7f7100e0ffbdd9ee45 100644 (file)
@@ -11,7 +11,8 @@ import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandle
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
 
-abstract class OutboundQueueHandlerRegistrationImpl<T extends OutboundQueueHandler> extends AbstractObjectRegistration<T> implements OutboundQueueHandlerRegistration<T> {
+abstract class OutboundQueueHandlerRegistrationImpl<T extends OutboundQueueHandler>
+        extends AbstractObjectRegistration<T> implements OutboundQueueHandlerRegistration<T> {
     protected OutboundQueueHandlerRegistrationImpl(final T instance) {
         super(instance);
     }
index 1fc514735d51b286db5efaeedac9838e009b71c4..621da0d7842b3bc84df709a37da486ba0118d3aa 100644 (file)
@@ -11,14 +11,11 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection;
 import java.net.InetSocketAddress;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler;
 
-/**
- *
- * @param <T>
- */
 public class OutboundQueueManagerNoBarrier<T extends OutboundQueueHandler> extends
         AbstractOutboundQueueManager<T, StackedOutboundQueueNoBarrier> {
 
-    OutboundQueueManagerNoBarrier(final ConnectionAdapterImpl parent, final InetSocketAddress address, final T handler) {
+    OutboundQueueManagerNoBarrier(final ConnectionAdapterImpl parent, final InetSocketAddress address,
+            final T handler) {
         super(parent, address, handler);
     }
 
index 15df265de0ae9bbc82dbc831689f5d77fa39ba7e..6a60375765b18565f42e5d878c2da9b110fda290 100644 (file)
@@ -7,15 +7,13 @@
  */
 package org.opendaylight.openflowjava.protocol.impl.core.connection;
 
+import com.google.common.base.Preconditions;
+import com.google.common.cache.Cache;
 import java.util.concurrent.TimeoutException;
-
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-import com.google.common.cache.Cache;
-
 final class ResponseExpectedRpcListener<T extends OfHeader> extends AbstractRpcListener<T> {
     private static final Logger LOG = LoggerFactory.getLogger(ResponseExpectedRpcListener.class);
     private final Cache<RpcResponseKey, ResponseExpectedRpcListener<?>> cache;
index 050f3cf76bdaea0261a94c48dadeade37db35c77..1b283419a70513c89bf4c17e19c115d9c0585886 100644 (file)
@@ -9,33 +9,30 @@
 
 package org.opendaylight.openflowjava.protocol.impl.core.connection;
 
-
-
 /**
+ * RPC response key.
+ *
  * @author mirehak
  */
 public class RpcResponseKey {
 
     private final long xid;
     private final String outputClazz;
-    /**
-     * @param xid
-     * @param outputClazz
-     */
+
     public RpcResponseKey(long xid, String outputClazz) {
         this.xid = xid;
         this.outputClazz = outputClazz;
     }
 
     /**
-     * @return the xid
+     * Returns the xid.
      */
     public long getXid() {
         return xid;
     }
 
     /**
-     * @return the outputClazz
+     * Return the outputClazz.
      */
     public String getOutputClazz() {
         return outputClazz;
@@ -46,7 +43,7 @@ public class RpcResponseKey {
         final int prime = 31;
         int result = 1;
         result = prime * result
-                + ((outputClazz == null) ? 0 : outputClazz.hashCode());
+                + (outputClazz == null ? 0 : outputClazz.hashCode());
         return result;
     }
 
@@ -79,4 +76,4 @@ public class RpcResponseKey {
         return "RpcResultKey [xid=" + xid + ", outputClazz=" + outputClazz
                 + "]";
     }
-}
\ No newline at end of file
+}
index fc7386322778d6dccb5051e9158ba9a7a20768ba..011d32f6f0937c6ea7364b47767493662aae42b0 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.openflowjava.protocol.impl.core.connection;
 
 final class SimpleRpcListener extends AbstractRpcListener<Void> {
-    public SimpleRpcListener(final Object message, final String failureInfo) {
+    SimpleRpcListener(final Object message, final String failureInfo) {
         super(message, failureInfo);
     }
 
index dd1e952002a74e3a5933ace7f3e48fbf8f819bea..50621ab186138b50fef7756e9d12bba4ea7ee64c 100644 (file)
@@ -8,18 +8,16 @@
 package org.opendaylight.openflowjava.protocol.impl.core.connection;
 
 import com.google.common.util.concurrent.FutureCallback;
-
 import java.util.concurrent.atomic.AtomicLongFieldUpdater;
 import java.util.function.Function;
-
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 final class StackedOutboundQueue extends AbstractStackedOutboundQueue {
     private static final Logger LOG = LoggerFactory.getLogger(StackedOutboundQueue.class);
-    private static final AtomicLongFieldUpdater<StackedOutboundQueue> BARRIER_XID_UPDATER = AtomicLongFieldUpdater.newUpdater(StackedOutboundQueue.class, "barrierXid");
+    private static final AtomicLongFieldUpdater<StackedOutboundQueue> BARRIER_XID_UPDATER =
+            AtomicLongFieldUpdater.newUpdater(StackedOutboundQueue.class, "barrierXid");
 
     private volatile long barrierXid = -1;
 
index 76b1243a7b5def846049bd5512639571074f003d..faddce6f8fec4877f154fb76ac310c74c19f871d 100644 (file)
@@ -9,17 +9,11 @@
 package org.opendaylight.openflowjava.protocol.impl.core.connection;
 
 import com.google.common.util.concurrent.FutureCallback;
-
 import io.netty.channel.Channel;
-
 import java.util.function.Function;
-
 import javax.annotation.Nonnull;
-
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
index 43aa002ac7f6c8f9d7fa92e7900d3b44b76e3464..d9aae5eeafc68aaa5b91f9a183ba9bf1717bff1f 100644 (file)
@@ -34,7 +34,7 @@ final class StackedSegment {
     }
 
     /**
-     * Size of each individual segment
+     * Size of each individual segment.
      */
     static final int SEGMENT_SIZE = 4096;
 
@@ -84,7 +84,8 @@ final class StackedSegment {
 
     @Override
     public String toString() {
-        return MoreObjects.toStringHelper(this).add("baseXid", baseXid).add("endXid", endXid).add("completeCount", completeCount).toString();
+        return MoreObjects.toStringHelper(this).add("baseXid", baseXid).add("endXid", endXid)
+                .add("completeCount", completeCount).toString();
     }
 
     long getBaseXid() {
@@ -106,7 +107,8 @@ final class StackedSegment {
     private static boolean completeEntry(final OutboundQueueEntry entry, final OfHeader response) {
         if (response instanceof Error) {
             final Error err = (Error)response;
-            LOG.debug("Device-reported request XID {} failed {}:{}", response.getXid(), err.getTypeString(), err.getCodeString());
+            LOG.debug("Device-reported request XID {} failed {}:{}", response.getXid(), err.getTypeString(),
+                    err.getCodeString());
             entry.fail(new DeviceRequestFailedException("Device-side failure", err));
             return true;
         }
@@ -143,7 +145,8 @@ final class StackedSegment {
             //      If this assumption is changed, this logic will need to be expanded
             //      to ensure that the requests implied by the barrier are reported as
             //      completed *after* the barrier.
-            LOG.trace("Barrier XID {} completed, cascading completion to XIDs {} to {}", xid, baseXid + lastBarrierOffset + 1, xid - 1);
+            LOG.trace("Barrier XID {} completed, cascading completion to XIDs {} to {}", xid,
+                    baseXid + lastBarrierOffset + 1, xid - 1);
             completeRequests(offset);
             lastBarrierOffset = offset;
 
index e783dc42aee7ab706251d489f1305e6aabe09501..6ac49024c97706e99e88afcf8b830360ba67ee62 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowjava.protocol.impl.core.connection;
 
 import io.netty.util.concurrent.Future;
 import io.netty.util.concurrent.GenericFutureListener;
-
 import java.net.InetSocketAddress;
 
 /**
@@ -23,9 +22,11 @@ import java.net.InetSocketAddress;
  */
 public class UdpMessageListenerWrapper extends MessageListenerWrapper {
 
-    private InetSocketAddress address;
+    private final InetSocketAddress address;
 
     /**
+     * Constructor.
+     *
      * @param msg message to be sent
      * @param listener listener attached to channel.write(msg) Future
      * @param address recipient's address
@@ -37,9 +38,9 @@ public class UdpMessageListenerWrapper extends MessageListenerWrapper {
     }
 
     /**
-     * @return recipient address
+     * Returns recipient address.
      */
     public InetSocketAddress getAddress() {
         return address;
     }
-}
\ No newline at end of file
+}
index 1c6c5d203763f1554bfb119b0decb9d2be6203cd..3dd1c956a7c8a734bfc71ee347460b9874aa253f 100644 (file)
@@ -41,8 +41,9 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13Se
 import org.opendaylight.openflowjava.protocol.impl.util.ActionDeserializerRegistryHelper;
 
 /**
- * @author michal.polkorab
+ * Helper for registering action deserializer initializers.
  *
+ * @author michal.polkorab
  */
 public final class ActionDeserializerInitializer {
 
@@ -51,7 +52,8 @@ public final class ActionDeserializerInitializer {
     }
 
     /**
-     * Registers action deserializers
+     * Registers action deserializers.
+     *
      * @param registry registry to be filled with deserializers
      */
     public static void registerDeserializers(DeserializerRegistry registry) {
@@ -89,4 +91,4 @@ public final class ActionDeserializerInitializer {
         helper.registerDeserializer(26, new OF13PushPbbActionDeserializer());
         helper.registerDeserializer(27, new OF13PopPbbActionDeserializer());
     }
-}
\ No newline at end of file
+}
index 33fc1ac138da9fb80653b5a2be812e080d8dc384..249cae88f38203f010db5b7e7394f148962c0507 100644 (file)
@@ -49,9 +49,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 
 /**
  * Util class for init registration of additional deserializers.
+ *
  * @author giuseppex.petralia@intel.com
  */
-public class AdditionalMessageDeserializerInitializer {
+public final class AdditionalMessageDeserializerInitializer {
     private AdditionalMessageDeserializerInitializer() {
         throw new UnsupportedOperationException("Utility class shouldn't be instantiated");
     }
index de631b11fa0ec52f09f367af04335b27bb26c897..b2d2a4381b10062483dc5ae88a6b3c939b613a54 100644 (file)
@@ -19,6 +19,8 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
 /**
+ * Factory for deserialization.
+ *
  * @author michal.polkorab
  * @author timotej.kubas
  * @author giuseppex.petralia@intel.com
@@ -28,9 +30,6 @@ public class DeserializationFactory {
     private final Map<TypeToClassKey, Class<?>> messageClassMap = new ConcurrentHashMap<>();
     private DeserializerRegistry registry;
 
-    /**
-     * Constructor
-     */
     public DeserializationFactory() {
         TypeToClassMapInitializer.initializeTypeToClassMap(messageClassMap);
 
@@ -39,9 +38,9 @@ public class DeserializationFactory {
     }
 
     /**
-     * Transforms ByteBuf into correct POJO message
+     * Transforms ByteBuf into correct POJO message.
      *
-     * @param rawMessage
+     * @param rawMessage the message
      * @param version
      *            version decoded from OpenFlow protocol message
      * @return correct POJO as DataObject
@@ -57,7 +56,8 @@ public class DeserializationFactory {
     }
 
     /**
-     * Register new type to class mapping used to assign return type when deserializing message
+     * Register new type to class mapping used to assign return type when deserializing message.
+     *
      * @param key type to class key
      * @param clazz return class
      */
@@ -66,7 +66,8 @@ public class DeserializationFactory {
     }
 
     /**
-     * Unregister type to class mapping used to assign return type when deserializing message
+     * Unregister type to class mapping used to assign return type when deserializing message.
+     *
      * @param key type to class key
      * @return true if mapping was successfully removed
      */
@@ -78,9 +79,6 @@ public class DeserializationFactory {
         return messageClassMap.remove(key) != null;
     }
 
-    /**
-     * @param registry
-     */
     public void setRegistry(final DeserializerRegistry registry) {
         this.registry = registry;
     }
index 7ba0f2c393ef78127f4fa8bf2a95ec30ac60930c..368e3b2dd85f53a1ab37ea86ebbe840ebaf2f14a 100644 (file)
@@ -23,7 +23,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Stores and registers deserializers
+ * Stores and registers deserializers.
  *
  * @author michal.polkorab
  */
@@ -33,7 +33,7 @@ public class DeserializerRegistryImpl implements DeserializerRegistry {
     private Map<MessageCodeKey, OFGeneralDeserializer> registry;
 
     /**
-     * Decoder table provisioning
+     * Decoder table provisioning.
      */
     @Override
     public void init() {
@@ -74,7 +74,7 @@ public class DeserializerRegistryImpl implements DeserializerRegistry {
 
     @Override
     public void registerDeserializer(MessageCodeKey key, OFGeneralDeserializer deserializer) {
-        if ((key == null) || (deserializer == null)) {
+        if (key == null || deserializer == null) {
             throw new IllegalArgumentException("MessageCodeKey or Deserializer is null");
         }
         OFGeneralDeserializer desInRegistry = registry.put(key, deserializer);
index 40cae2c4bb79a9e5a815f7a088b38b8b4ea13f2f..60e684a9ded74fd777a13f1ce16304e09a448720 100644 (file)
@@ -19,8 +19,9 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.W
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionDeserializerRegistryHelper;
 
 /**
- * @author michal.polkorab
+ * Utilities for registering nstruction deserializer initializers.
  *
+ * @author michal.polkorab
  */
 public final class InstructionDeserializerInitializer {
 
@@ -29,7 +30,8 @@ public final class InstructionDeserializerInitializer {
     }
 
     /**
-     * Registers instruction deserializers
+     * Registers instruction deserializers.
+     *
      * @param registry registry to be filled with deserializers
      */
     public static void registerDeserializers(DeserializerRegistry registry) {
@@ -43,4 +45,4 @@ public final class InstructionDeserializerInitializer {
         helper.registerDeserializer(5, new ClearActionsInstructionDeserializer());
         helper.registerDeserializer(6, new MeterInstructionDeserializer());
     }
-}
\ No newline at end of file
+}
index d623297e732c5d93930d53c2bf575a2a28881032..6fc496e29ed1596372ab050d924d3bb79055e3f0 100644 (file)
@@ -10,7 +10,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization;
 
 
 /**
- * Class used as a key in {@link DeserializerRegistryImpl}
+ * Class used as a key in {@link DeserializerRegistryImpl}.
+ *
  * @author michal.polkorab
  * @author timotej.kubas
  */
@@ -20,6 +21,8 @@ public class MessageTypeCodeKey {
     private final short msgVersion;
 
     /**
+     * Constructor.
+     *
      * @param msgVersion protocol version
      * @param msgType type code of message
      */
@@ -29,14 +32,14 @@ public class MessageTypeCodeKey {
     }
 
     /**
-     * @return the msgType
+     * Returns the msgType.
      */
     public short getMsgType() {
         return msgType;
     }
 
     /**
-     * @return the msgVersion
+     * Returns the msgVersion.
      */
     public short getMsgVersion() {
         return msgVersion;
@@ -71,4 +74,4 @@ public class MessageTypeCodeKey {
         }
         return true;
     }
-}
\ No newline at end of file
+}
index 61fe027f6263f72cf3bf33215ee3860fe0eda095..ec0cac66118054ce8995a0366fd45e2063b2e62f 100644 (file)
@@ -8,9 +8,9 @@
 package org.opendaylight.openflowjava.protocol.impl.deserialization;
 
 import java.util.Map;
+import org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassInitHelper;
-import org.opendaylight.openflowjava.protocol.api.keys.TypeToClassKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput;