Fix checkstyle violations in samples 66/67766/5
authorTom Pantelis <tompantelis@gmail.com>
Wed, 31 Jan 2018 04:06:41 +0000 (23:06 -0500)
committerAnil Vishnoi <vishnoianil@gmail.com>
Thu, 15 Feb 2018 10:13:07 +0000 (10:13 +0000)
Change-Id: I5879e9d420c57c252d301ce7a5c296f8b5b914a6
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
42 files changed:
samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/DataTreeChangeListenerRegistrationHolder.java
samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowCommitWrapper.java
samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowCommitWrapperImpl.java
samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowUtils.java
samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/InstanceIdentifierUtils.java
samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchHandler.java
samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchHandlerSimpleImpl.java
samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchManager.java
samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/LearningSwitchManagerSimpleImpl.java
samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/PacketUtils.java
samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/WakeupOnNode.java
samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/multi/LearningSwitchManagerMultiImpl.java
samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/multi/MultipleLearningSwitchHandlerFacadeImpl.java
samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/multi/PacketInDispatcherImpl.java
samples/sample-bundles/src/main/java/org/opendaylight/openflowplugin/samples/sample/bundles/Activator.java
samples/sample-consumer/src/main/java/org/opendaylight/openflowplugin/openflow/samples/consumer/Activator.java
samples/sample-consumer/src/main/java/org/opendaylight/openflowplugin/openflow/samples/consumer/SimpleDropFirewallCli.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/CallableClient.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientEvent.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslContextFactory.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslKeyStore.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslTrustStore.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/EventType.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ListeningSimpleClient.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/Scenario.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioService.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioServiceImpl.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/Scenarios.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClient.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientFramer.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SleepEvent.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/Step.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClient.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientFramer.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/UdpSimpleClientInitializer.java
samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java

index 34593097cfa0dedb3bf0dd56b0c3985ef133d01d..1fa1ef2e9a1d5b39d53e10b733005fd7e393ddc5 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration;
 public interface DataTreeChangeListenerRegistrationHolder {
 
     /**
-     * @return the DataTreeChangeListenerRegistration
+     * Returns the DataTreeChangeListenerRegistration.
      */
     ListenerRegistration<DataTreeChangeListener> getDataTreeChangeListenerRegistration();
 
index e1c5dfa8b805cf6fce4f7971b5774629d99d14a0..265ee7be91be0521677fa3664fd19fff2e546e4e 100644 (file)
@@ -13,20 +13,16 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFaile
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-/**
- * 
- */
 public interface FlowCommitWrapper {
 
     /**
-     * Starts and commits data change transaction which 
-     * modifies provided flow path with supplied body.
-     * 
-     * @param flowPath 
-     * @param flowBody 
-     * @return transaction commit 
-     * 
+     * Starts and commits data change transaction which  modifies provided flow path with supplied body.
+     *
+     * @param flowPath the flow path
+     * @param flowBody the flow body
+     * @return transaction commit
      */
-    CheckedFuture<Void, TransactionCommitFailedException> writeFlowToConfig(InstanceIdentifier<Flow> flowPath, Flow flowBody);
+    CheckedFuture<Void, TransactionCommitFailedException> writeFlowToConfig(
+            InstanceIdentifier<Flow> flowPath, Flow flowBody);
 
 }
index 4652a4e01a899e4a0aa19fb64d59265f924691e6..e1da864a8a8b3548a75868bb89ca7513cf4ca16c 100644 (file)
@@ -16,16 +16,10 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFaile
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-/**
- *
- */
 public class FlowCommitWrapperImpl implements FlowCommitWrapper {
 
-    private DataBroker dataBrokerService;
+    private final DataBroker dataBrokerService;
 
-    /**
-     * @param dataBrokerService
-     */
     public FlowCommitWrapperImpl(DataBroker dataBrokerService) {
         this.dataBrokerService = dataBrokerService;
     }
index e9eb2993fff9b75abc474aa3f26c8de2b6d9771b..82e3077ae14681ff7a9e9edefdc4173f02c460be 100644 (file)
@@ -40,18 +40,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
 
-public class FlowUtils {
+public final class FlowUtils {
     private FlowUtils() {
         //prohibite to instantiate util class
     }
 
     /**
-     * @param tableId
-     * @param priority
-     * @param srcMac
-     * @param dstMac
-     * @param dstPort
-     * @return {@link FlowBuilder} forwarding all packets to controller port
+     * Returns a {@link FlowBuilder} forwarding all packets to controller port.
      */
     public static FlowBuilder createDirectMacToMacFlow(final Short tableId, final int priority, final MacAddress srcMac,
             final MacAddress dstMac, final NodeConnectorRef dstPort) {
@@ -115,17 +110,10 @@ public class FlowUtils {
     }
 
     /**
-     * @param tableId
-     * @param priority
-     * @param flowId
-     * @return {@link FlowBuilder} forwarding all packets to controller port
+     * Returns a{@link FlowBuilder} forwarding all packets to controller port.
      */
-    public static FlowBuilder createFwdAllToControllerFlow(final Short tableId, final int priority, final FlowId flowId) {
-        FlowBuilder allToCtrlFlow = new FlowBuilder().setTableId(tableId).setFlowName("allPacketsToCtrl").setId(flowId)
-                .setKey(new FlowKey(flowId));
-
-        MatchBuilder matchBuilder = new MatchBuilder();
-
+    public static FlowBuilder createFwdAllToControllerFlow(final Short tableId, final int priority,
+            final FlowId flowId) {
         // Create output action -> send to controller
         OutputActionBuilder output = new OutputActionBuilder();
         output.setMaxLength(Integer.valueOf(0xffff));
@@ -137,7 +125,7 @@ public class FlowUtils {
         ab.setOrder(0);
         ab.setKey(new ActionKey(0));
 
-        List<Action> actionList = new ArrayList<Action>();
+        List<Action> actionList = new ArrayList<>();
         actionList.add(ab.build());
 
         // Create an Apply Action
@@ -152,10 +140,13 @@ public class FlowUtils {
 
         // Put our Instruction in a list of Instructions
         InstructionsBuilder isb = new InstructionsBuilder();
-        List<Instruction> instructions = new ArrayList<Instruction>();
+        List<Instruction> instructions = new ArrayList<>();
         instructions.add(ib.build());
         isb.setInstruction(instructions);
 
+        MatchBuilder matchBuilder = new MatchBuilder();
+        FlowBuilder allToCtrlFlow = new FlowBuilder().setTableId(tableId).setFlowName("allPacketsToCtrl").setId(flowId)
+                .setKey(new FlowKey(flowId));
         allToCtrlFlow
             .setMatch(matchBuilder.build())
             .setInstructions(isb.build())
index d99a0e7a51d9d0e98ca3327ff8ffe91917b43974..fa3b3f2d9342481ae324332b1b280671d57f7431 100644 (file)
@@ -21,19 +21,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-public class InstanceIdentifierUtils {
+public final class InstanceIdentifierUtils {
 
     private InstanceIdentifierUtils() {
         //hiding constructor for util class
     }
 
     /**
-     * Creates an Instance Identifier (path) for node with specified id
+     * Creates an Instance Identifier (path) for node with specified id.
      *
-     * @param nodeId
-     * @return
+     * @param nodeId the NodeId
      */
-    public static final InstanceIdentifier<Node> createNodePath(final NodeId nodeId) {
+    public static InstanceIdentifier<Node> createNodePath(final NodeId nodeId) {
         return InstanceIdentifier.builder(Nodes.class)
                 .child(Node.class, new NodeKey(nodeId))
                 .build();
@@ -43,20 +42,19 @@ public class InstanceIdentifierUtils {
      * Shorten's node child path to node path.
      *
      * @param nodeChild child of node, from which we want node path.
-     * @return
      */
-    public static final InstanceIdentifier<Node> getNodePath(final InstanceIdentifier<?> nodeChild) {
+    public static InstanceIdentifier<Node> getNodePath(final InstanceIdentifier<?> nodeChild) {
         return nodeChild.firstIdentifierOf(Node.class);
     }
 
     /**
-     * Creates a table path by appending table specific location to node path
+     * Creates a table path by appending table specific location to node path.
      *
-     * @param nodePath
-     * @param tableKey
-     * @return
+     * @param nodePath the node path
+     * @param tableKey the table yey
      */
-    public static final InstanceIdentifier<Table> createTablePath(final InstanceIdentifier<Node> nodePath,final TableKey tableKey) {
+    public static InstanceIdentifier<Table> createTablePath(final InstanceIdentifier<Node> nodePath,
+            final TableKey tableKey) {
         return nodePath.augmentation(FlowCapableNode.class).child(Table.class, tableKey);
     }
 
@@ -64,19 +62,19 @@ public class InstanceIdentifierUtils {
      * Creates a path for particular flow, by appending flow-specific information
      * to table path.
      *
-     * @param tablePath
-     * @param flowKey
+     * @param tablePath the table path
+     * @param flowKey the flow key
      * @return path to flow
      */
-    public static InstanceIdentifier<Flow> createFlowPath(final InstanceIdentifier<Table> tablePath, final FlowKey flowKey) {
+    public static InstanceIdentifier<Flow> createFlowPath(final InstanceIdentifier<Table> tablePath,
+            final FlowKey flowKey) {
         return tablePath.child(Flow.class, flowKey);
     }
 
     /**
      * Extract table id from table path.
      *
-     * @param tablePath
-     * @return
+     * @param tablePath the table path
      */
     public static Short getTableId(final InstanceIdentifier<Table> tablePath) {
         return tablePath.firstKeyOf(Table.class, TableKey.class).getId();
@@ -89,7 +87,8 @@ public class InstanceIdentifierUtils {
         return nodeConnectorPath.firstKeyOf(NodeConnector.class, NodeConnectorKey.class);
     }
 
-    public static final InstanceIdentifier<NodeConnector> createNodeConnectorPath(final InstanceIdentifier<Node> nodeKey,final NodeConnectorKey nodeConnectorKey) {
+    public static InstanceIdentifier<NodeConnector> createNodeConnectorPath(final InstanceIdentifier<Node> nodeKey,
+            final NodeConnectorKey nodeConnectorKey) {
         return nodeKey.child(NodeConnector.class,nodeConnectorKey);
     }
 }
index 238c09be649b339d3453e751ed208f58b0fe69b2..48689701d10533e2dc2e6725dbda19b521b2b532 100644 (file)
@@ -11,28 +11,33 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-/**
- * 
- */
 public interface LearningSwitchHandler {
 
     /**
-     * @param tablePath 
+     * Invoked when a switch appears.
+     *
+     * @param tablePath the table path
      */
     void onSwitchAppeared(InstanceIdentifier<Table> tablePath);
 
     /**
+     * Sets the PacketProcessingService.
+     *
      * @param packetProcessingService the packetProcessingService to set
      */
-   void setPacketProcessingService(PacketProcessingService packetProcessingService);
+    void setPacketProcessingService(PacketProcessingService packetProcessingService);
 
    /**
+    * Sets the data store accessor.
+    *
     * @param dataStoreAccessor the dataStoreAccessor to set
     */
-   void setDataStoreAccessor(FlowCommitWrapper dataStoreAccessor);
+    void setDataStoreAccessor(FlowCommitWrapper dataStoreAccessor);
 
    /**
+    * Sets the DataTreeChangeListener registration publisher.
+    *
     * @param registrationPublisher the registrationPublisher to set
     */
-   void setRegistrationPublisher(DataTreeChangeListenerRegistrationHolder registrationPublisher);
+    void setRegistrationPublisher(DataTreeChangeListenerRegistrationHolder registrationPublisher);
 }
index 7a953f53e6756676483f5fd4319949e02c3fd1d9..9c4163676ee07e91d5705f20995126ae4d0b5381 100644 (file)
@@ -53,11 +53,11 @@ public class LearningSwitchHandlerSimpleImpl implements LearningSwitchHandler, P
     private FlowCommitWrapper dataStoreAccessor;
     private PacketProcessingService packetProcessingService;
 
-    private boolean iAmLearning = false;
+    private boolean isLearning = false;
 
     private NodeId nodeId;
-    private AtomicLong flowIdInc = new AtomicLong();
-    private AtomicLong flowCookieInc = new AtomicLong(0x2a00000000000000L);
+    private final AtomicLong flowIdInc = new AtomicLong();
+    private final AtomicLong flowCookieInc = new AtomicLong(0x2a00000000000000L);
 
     private InstanceIdentifier<Node> nodePath;
     private InstanceIdentifier<Table> tablePath;
@@ -67,7 +67,7 @@ public class LearningSwitchHandlerSimpleImpl implements LearningSwitchHandler, P
 
     @Override
     public synchronized void onSwitchAppeared(InstanceIdentifier<Table> appearedTablePath) {
-        if (iAmLearning) {
+        if (isLearning) {
             LOG.debug("already learning a node, skipping {}", nodeId.getValue());
             return;
         }
@@ -76,16 +76,11 @@ public class LearningSwitchHandlerSimpleImpl implements LearningSwitchHandler, P
 
         // disable listening - simple learning handles only one node (switch)
         if (registrationPublisher != null) {
-            try {
-                LOG.debug("closing dataTreeChangeListenerRegistration");
-                registrationPublisher.getDataTreeChangeListenerRegistration().close();
-            } catch (Exception e) {
-                LOG.warn("closing registration upon flowCapable node update listener failed: {}", e.getMessage());
-                LOG.debug("closing registration upon flowCapable node update listener failed.. ", e);
-            }
+            LOG.debug("closing dataTreeChangeListenerRegistration");
+            registrationPublisher.getDataTreeChangeListenerRegistration().close();
         }
 
-        iAmLearning = true;
+        isLearning = true;
 
         tablePath = appearedTablePath;
         nodePath = tablePath.firstIdentifierOf(Node.class);
@@ -125,7 +120,7 @@ public class LearningSwitchHandlerSimpleImpl implements LearningSwitchHandler, P
 
     @Override
     public void onPacketReceived(PacketReceived notification) {
-        if (!iAmLearning) {
+        if (!isLearning) {
             // ignoring packets - this should not happen
             return;
         }
@@ -185,11 +180,6 @@ public class LearningSwitchHandlerSimpleImpl implements LearningSwitchHandler, P
 
     }
 
-    /**
-     * @param srcMac
-     * @param dstMac
-     * @param destNodeConnector
-     */
     private void addBridgeFlow(MacAddress srcMac, MacAddress dstMac, NodeConnectorRef destNodeConnector) {
         synchronized (coveredMacPaths) {
             String macPath = srcMac.toString() + dstMac.toString();
@@ -217,7 +207,8 @@ public class LearningSwitchHandlerSimpleImpl implements LearningSwitchHandler, P
 
     private void flood(byte[] payload, NodeConnectorRef ingress) {
         NodeConnectorKey nodeConnectorKey = new NodeConnectorKey(nodeConnectorId("0xfffffffb"));
-        InstanceIdentifier<?> nodeConnectorPath = InstanceIdentifierUtils.createNodeConnectorPath(nodePath, nodeConnectorKey);
+        InstanceIdentifier<?> nodeConnectorPath = InstanceIdentifierUtils.createNodeConnectorPath(
+                nodePath, nodeConnectorKey);
         NodeConnectorRef egressConnectorRef = new NodeConnectorRef(nodeConnectorPath);
 
         sendPacketOut(payload, ingress, egressConnectorRef);
index 56c577899f2aa818c46fd8cfdb5f4b374dc64254..fb9f6fc454f4b9ba3494188c43e489a7e0c95821 100644 (file)
@@ -12,59 +12,54 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.sal.binding.api.NotificationService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
 
-/**
- *
- */
 public interface LearningSwitchManager {
 
     /**
-     * stop manager
+     * Stops this manager.
      */
     void stop();
 
     /**
-     * start manager
+     * Starts this manager.
      */
     void start();
 
     /**
      * Set's Data Broker dependency.
+     *
      * <p>
-     * Data Broker is used to access overal operational and configuration
-     * tree.
+     * Data Broker is used to access overall operational and configuration tree.
+     *
      * <p>
      * In simple Learning Switch handler, data broker is used to listen
      * for changes in Openflow tables and to configure flows which will
      * be provisioned down to the Openflow switch.
+     *
      * <p>
      * inject {@link DataBroker}
-     *
-     * @param data
      */
     void setDataBroker(DataBroker data);
 
     /**
      * Set's Packet Processing dependency.
+     *
      * <p>
-     * Packet Processing service is used to send packet Out on Openflow
-     * switch.
+     * Packet Processing service is used to send packet Out on Openflow switch.
+     *
      * <p>
      * inject {@link PacketProcessingService}
-     *
-     * @param packetProcessingService
      */
     void setPacketProcessingService(
             PacketProcessingService packetProcessingService);
 
     /**
      * Set's Notification service dependency.
+     *
      * <p>
-     * Notification service is used to register for listening
-     * packet-in notifications.
+     * Notification service is used to register for listening packet-in notifications.
+     *
      * <p>
      * inject {@link NotificationService}
-     *
-     * @param notificationService
      */
     void setNotificationService(NotificationService notificationService);
 }
index b0195e6ab6e4ff68a5f443437cbb65ce124d7b09..6dc9c9ae17a83120559f650d1880d37f232c4f32 100644 (file)
@@ -24,7 +24,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Listens to packetIn notification and
+ * Listens to packetIn notification.
  * <ul>
  * <li>in HUB mode simply floods all switch ports (except ingress port)</li>
  * <li>in LSWITCH mode collects source MAC address of packetIn and bind it with ingress port.
@@ -32,7 +32,8 @@ import org.slf4j.LoggerFactory;
  * corresponding MACs)</li>
  * </ul>
  */
-public class LearningSwitchManagerSimpleImpl implements DataTreeChangeListenerRegistrationHolder, LearningSwitchManager {
+public class LearningSwitchManagerSimpleImpl
+        implements DataTreeChangeListenerRegistrationHolder, LearningSwitchManager {
 
     private static final Logger LOG = LoggerFactory.getLogger(LearningSwitchManagerSimpleImpl.class);
     private NotificationService notificationService;
@@ -42,6 +43,8 @@ public class LearningSwitchManagerSimpleImpl implements DataTreeChangeListenerRe
     private ListenerRegistration<DataTreeChangeListener> dataTreeChangeListenerRegistration;
 
     /**
+     * Sets the NotificationService.
+     *
      * @param notificationService the notificationService to set
      */
     @Override
@@ -50,6 +53,8 @@ public class LearningSwitchManagerSimpleImpl implements DataTreeChangeListenerRe
     }
 
     /**
+     * Sets the PacketProcessingService.
+     *
      * @param packetProcessingService the packetProcessingService to set
      */
     @Override
@@ -59,15 +64,15 @@ public class LearningSwitchManagerSimpleImpl implements DataTreeChangeListenerRe
     }
 
     /**
-     * @param data the data to set
+     * Sets the DataBroker.
      */
     @Override
-    public void setDataBroker(DataBroker data) {
-        this.data = data;
+    public void setDataBroker(DataBroker broker) {
+        this.data = broker;
     }
 
     /**
-     * starting learning switch
+     * Starts learning switch.
      */
     @Override
     public void start() {
@@ -86,30 +91,24 @@ public class LearningSwitchManagerSimpleImpl implements DataTreeChangeListenerRe
                 .child(Node.class)
                 .augmentation(FlowCapableNode.class)
                 .child(Table.class);
-        final DataTreeIdentifier<Table> dataTreeIdentifier = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, instanceIdentifier);
+        final DataTreeIdentifier<Table> dataTreeIdentifier =
+                new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, instanceIdentifier);
         dataTreeChangeListenerRegistration = data.registerDataTreeChangeListener(dataTreeIdentifier, wakeupListener);
         LOG.debug("start() <--");
     }
 
     /**
-     * stopping learning switch
+     * Stops the learning switch.
      */
     @Override
     public void stop() {
         LOG.debug("stop() -->");
         //TODO: remove flow (created in #start())
-        try {
-            packetInRegistration.close();
-        } catch (Exception e) {
-            LOG.warn("closing packetInRegistration failed: {}", e.getMessage());
-            LOG.debug("closing packetInRegistration failed..", e);
-        }
-        try {
-            dataTreeChangeListenerRegistration.close();
-        } catch (Exception e) {
-            LOG.warn("failed to close dataTreeChangeListenerRegistration: {}", e.getMessage());
-            LOG.debug("failed to close dataTreeChangeListenerRegistration..", e);
-        }
+
+        packetInRegistration.close();
+
+        dataTreeChangeListenerRegistration.close();
+
         LOG.debug("stop() <--");
     }
 
index 9c073fcbb74e68c535c81b32d38fee98f81429c6..d86e1f2331f708d12f369c4cf4a1dc3146b1f007 100644 (file)
@@ -18,43 +18,40 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-/**
- *
- */
 public abstract class PacketUtils {
 
     /**
-     * size of MAC address in octets (6*8 = 48 bits)
+     * size of MAC address in octets (6*8 = 48 bits).
      */
     private static final int MAC_ADDRESS_SIZE = 6;
 
     /**
-     * start position of destination MAC address in array
+     * start position of destination MAC address in array.
      */
     private static final int DST_MAC_START_POSITION = 0;
 
     /**
-     * end position of destination MAC address in array
+     * end position of destination MAC address in array.
      */
     private static final int DST_MAC_END_POSITION = 6;
 
     /**
-     * start position of source MAC address in array
+     * start position of source MAC address in array.
      */
     private static final int SRC_MAC_START_POSITION = 6;
 
     /**
-     * end position of source MAC address in array
+     * end position of source MAC address in array.
      */
     private static final int SRC_MAC_END_POSITION = 12;
 
     /**
-     * start position of ethernet type in array
+     * start position of ethernet type in array.
      */
     private static final int ETHER_TYPE_START_POSITION = 12;
 
     /**
-     * end position of ethernet type in array
+     * end position of ethernet type in array.
      */
     private static final int ETHER_TYPE_END_POSITION = 14;
 
@@ -63,7 +60,9 @@ public abstract class PacketUtils {
     }
 
     /**
-     * @param payload
+     * Extracts the destination MAC address.
+     *
+     * @param payload the payload bytes
      * @return destination MAC address
      */
     public static byte[] extractDstMac(final byte[] payload) {
@@ -71,7 +70,9 @@ public abstract class PacketUtils {
     }
 
     /**
-     * @param payload
+     * Extracts the source MAC address.
+     *
+     * @param payload the payload bytes
      * @return source MAC address
      */
     public static byte[] extractSrcMac(final byte[] payload) {
@@ -79,7 +80,9 @@ public abstract class PacketUtils {
     }
 
     /**
-     * @param payload
+     * Extracts the ethernet type.
+     *
+     * @param payload the payload bytes
      * @return source MAC address
      */
     public static byte[] extractEtherType(final byte[] payload) {
@@ -87,9 +90,10 @@ public abstract class PacketUtils {
     }
 
     /**
-     * @param rawMac
-     * @return {@link MacAddress} wrapping string value, baked upon binary MAC
-     *         address
+     * Converts a raw MAC bytes to a MacAddress.
+     *
+     * @param rawMac the raw bytes
+     * @return {@link MacAddress} wrapping string value, baked upon binary MAC address
      */
     public static MacAddress rawMacToMac(final byte[] rawMac) {
         MacAddress mac = null;
@@ -104,15 +108,13 @@ public abstract class PacketUtils {
     }
 
     /**
-     * @param nodeInstId
-     * @param nodeKey
-     * @param port
-     * @return port wrapped into {@link NodeConnectorRef}
+     * Returns the port wrapped into {@link NodeConnectorRef}.
      */
-    public static NodeConnectorRef createNodeConnRef(final InstanceIdentifier<Node> nodeInstId, final NodeKey nodeKey, final String port) {
-        StringBuilder sBuild = new StringBuilder(nodeKey.getId().getValue()).append(':').append(port);
-        NodeConnectorKey nConKey = new NodeConnectorKey(new NodeConnectorId(sBuild.toString()));
-        InstanceIdentifier<NodeConnector> portPath = nodeInstId.child(NodeConnector.class, nConKey);
+    public static NodeConnectorRef createNodeConnRef(final InstanceIdentifier<Node> nodeInstId, final NodeKey nodeKey,
+            final String port) {
+        StringBuilder builder = new StringBuilder(nodeKey.getId().getValue()).append(':').append(port);
+        NodeConnectorKey connKey = new NodeConnectorKey(new NodeConnectorId(builder.toString()));
+        InstanceIdentifier<NodeConnector> portPath = nodeInstId.child(NodeConnector.class, connKey);
         return new NodeConnectorRef(portPath);
     }
 }
index a8fd52c5d164ad3a300a2392950ec8e18982798f..fc101a07b1564b1fc84386d6a67964cdca78aec0 100644 (file)
@@ -19,9 +19,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- *
- */
 public class WakeupOnNode implements DataTreeChangeListener<Table> {
 
     private static final Logger LOG = LoggerFactory.getLogger(WakeupOnNode.class);
@@ -40,7 +37,8 @@ public class WakeupOnNode implements DataTreeChangeListener<Table> {
                     LOG.trace("table: {}", table);
 
                     if (requiredTableId.equals(tableSure.getId())) {
-                        InstanceIdentifier<Table> tablePath = (InstanceIdentifier<Table>) modification.getRootPath().getRootIdentifier();
+                        InstanceIdentifier<Table> tablePath =
+                                modification.getRootPath().getRootIdentifier();
                         learningSwitchHandler.onSwitchAppeared(tablePath);
                     }
                 }
@@ -49,11 +47,12 @@ public class WakeupOnNode implements DataTreeChangeListener<Table> {
     }
 
     /**
+     * Sets the LearningSwitchHandler.
+     *
      * @param learningSwitchHandler the learningSwitchHandler to set
      */
     public void setLearningSwitchHandler(
             LearningSwitchHandler learningSwitchHandler) {
         this.learningSwitchHandler = learningSwitchHandler;
     }
-
 }
index 4092753fdcb8a525644555512161f50854d38f54..68f513d2855d34399fd6519ff1c1ed1abd9e5d97 100644 (file)
@@ -29,7 +29,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Listens to packetIn notification and
+ * Listens to packetIn notification.
  * <ul>
  * <li>in HUB mode simply floods all switch ports (except ingress port)</li>
  * <li>in LSWITCH mode collects source MAC address of packetIn and bind it with ingress port.
@@ -47,6 +47,8 @@ public class LearningSwitchManagerMultiImpl implements DataTreeChangeListenerReg
     private ListenerRegistration<DataTreeChangeListener> dataTreeChangeListenerRegistration;
 
     /**
+     * Sets the NotificationService.
+     *
      * @param notificationService the notificationService to set
      */
     @Override
@@ -55,6 +57,8 @@ public class LearningSwitchManagerMultiImpl implements DataTreeChangeListenerReg
     }
 
     /**
+     * Sets the PacketProcessingService.
+     *
      * @param packetProcessingService the packetProcessingService to set
      */
     @Override
@@ -64,15 +68,17 @@ public class LearningSwitchManagerMultiImpl implements DataTreeChangeListenerReg
     }
 
     /**
-     * @param data the data to set
+     * Sets the DataBroker.
+     *
+     * @param broker the data to set
      */
     @Override
-    public void setDataBroker(DataBroker data) {
-        this.data = data;
+    public void setDataBroker(DataBroker broker) {
+        this.data = broker;
     }
 
     /**
-     * starting learning switch
+     * Starts learning switch.
      */
     @Override
     public void start() {
@@ -93,30 +99,23 @@ public class LearningSwitchManagerMultiImpl implements DataTreeChangeListenerReg
                 .child(Node.class)
                 .augmentation(FlowCapableNode.class)
                 .child(Table.class);
-        final DataTreeIdentifier<Table> dataTreeIdentifier = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, instanceIdentifier);
+        final DataTreeIdentifier<Table> dataTreeIdentifier =
+                new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, instanceIdentifier);
         dataTreeChangeListenerRegistration = data.registerDataTreeChangeListener(dataTreeIdentifier, wakeupListener);
         LOG.debug("start() <--");
     }
 
     /**
-     * stopping learning switch
+     * Stops learning switch.
      */
     @Override
     public void stop() {
         LOG.debug("stop() -->");
         //TODO: remove flow (created in #start())
-        try {
-            packetInRegistration.close();
-        } catch (Exception e) {
-            LOG.warn("Error unregistering packet in listener: {}", e.getMessage());
-            LOG.debug("Error unregistering packet in listener.. ", e);
-        }
-        try {
-            dataTreeChangeListenerRegistration.close();
-        } catch (Exception e) {
-            LOG.warn("Error unregistering data change listener: {}", e.getMessage());
-            LOG.debug("Error unregistering data change listener.. ", e);
-        }
+
+        packetInRegistration.close();
+
+        dataTreeChangeListenerRegistration.close();
         LOG.debug("stop() <--");
     }
 
index 7f08744af8f77276c78ce97f8295f462e61569da..88ee493811b5115dc3851d7c3f2a229ecbfa0059 100644 (file)
@@ -78,9 +78,6 @@ public class MultipleLearningSwitchHandlerFacadeImpl implements LearningSwitchHa
         this.packetProcessingService = packetProcessingService;
     }
 
-    /**
-     * @param packetInDispatcher
-     */
     public void setPacketInDispatcher(PacketInDispatcherImpl packetInDispatcher) {
         this.packetInDispatcher = packetInDispatcher;
     }
index b8058c964b6bc9c2842e5c3c33db2b6d12addb91..35a8e208ccefc3e384534c14547f80bf72242fff 100644 (file)
@@ -17,10 +17,10 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class PacketInDispatcherImpl implements PacketProcessingListener {
 
-    private Map<InstanceIdentifier<Node>, PacketProcessingListener> handlerMapping;
+    private final Map<InstanceIdentifier<Node>, PacketProcessingListener> handlerMapping;
 
     /**
-     * default constructor
+     * default constructor.
      */
     public PacketInDispatcherImpl() {
         handlerMapping = new HashMap<>();
@@ -29,7 +29,7 @@ public class PacketInDispatcherImpl implements PacketProcessingListener {
     @Override
     public void onPacketReceived(PacketReceived notification) {
         // find corresponding handler
-        /**
+        /*
          * Notification contains reference to ingress port
          * in a form of path in inventory: /nodes/node/node-connector
          *
@@ -52,9 +52,6 @@ public class PacketInDispatcherImpl implements PacketProcessingListener {
         }
     }
 
-    /**
-     * @return the handlerMapping
-     */
     public Map<InstanceIdentifier<Node>, PacketProcessingListener> getHandlerMapping() {
         return handlerMapping;
     }
index 61c72f0fa31079306d65bb4967e345ae391970f1..fd3d87a95530f667dc5739ef92ea570fe5b38886 100644 (file)
@@ -89,9 +89,10 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Sample bundles activator
+ * Sample bundles activator.
  */
-public class Activator extends AbstractBrokerAwareActivator implements BindingAwareConsumer, ClusteredDataTreeChangeListener<FlowCapableNode>, AutoCloseable {
+public class Activator extends AbstractBrokerAwareActivator implements BindingAwareConsumer,
+        ClusteredDataTreeChangeListener<FlowCapableNode>, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
 
@@ -112,9 +113,10 @@ public class Activator extends AbstractBrokerAwareActivator implements BindingAw
         LOG.debug("inSessionInitialized() passing");
         dataBroker = consumerContext.getSALService(DataBroker.class);
 
-        final InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class).
-                augmentation(FlowCapableNode.class);
-        final DataTreeIdentifier<FlowCapableNode> identifier = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, path);
+        final InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class)
+                .augmentation(FlowCapableNode.class);
+        final DataTreeIdentifier<FlowCapableNode> identifier =
+                new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, path);
 
         dataBroker.registerDataTreeChangeListener(identifier, Activator.this);
         bundleService = consumerContext.getRpcService(SalBundleService.class);
@@ -124,9 +126,11 @@ public class Activator extends AbstractBrokerAwareActivator implements BindingAw
     public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<FlowCapableNode>> modifications) {
         for (DataTreeModification modification : modifications) {
             if (modification.getRootNode().getModificationType() == ModificationType.WRITE) {
-                LOG.info("Node connected:  {}", modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class));
+                LOG.info("Node connected:  {}",
+                        modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class));
 
-                final NodeRef nodeRef = new NodeRef(modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class));
+                final NodeRef nodeRef =
+                        new NodeRef(modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class));
 
                 final ControlBundleInput openBundleInput = new ControlBundleInputBuilder()
                         .setNode(nodeRef)
@@ -152,23 +156,26 @@ public class Activator extends AbstractBrokerAwareActivator implements BindingAw
                         .build();
 
                 makeCompletableFuture(bundleService.controlBundle(openBundleInput))
-                        .thenComposeAsync(voidRpcResult -> {
-                            LOG.debug("Open successful: {}, msg: {}", voidRpcResult.isSuccessful(), voidRpcResult.getErrors());
-
-                            final CompletableFuture<RpcResult<Void>> addFuture =
-                                    makeCompletableFuture(bundleService.addBundleMessages(addBundleMessagesInput));
-
-                            return addFuture;
-                        }).thenComposeAsync(voidRpcResult -> {
-                            LOG.debug("AddBundleMessages successful: {}, msg: {}", voidRpcResult.isSuccessful(), voidRpcResult.getErrors());
-
-                            final CompletableFuture<RpcResult<Void>> controlCommitFuture =
-                                    makeCompletableFuture(bundleService.controlBundle(commitBundleInput));
-
-                            return controlCommitFuture;
-                        }).thenAccept(voidRpcResult -> {
-                            LOG.debug("Commit successful: {}, msg: {}", voidRpcResult.isSuccessful(), voidRpcResult.getErrors());
-                });
+                    .thenComposeAsync(voidRpcResult -> {
+                        LOG.debug("Open successful: {}, msg: {}", voidRpcResult.isSuccessful(),
+                                voidRpcResult.getErrors());
+
+                        final CompletableFuture<RpcResult<Void>> addFuture =
+                                makeCompletableFuture(bundleService.addBundleMessages(addBundleMessagesInput));
+
+                        return addFuture;
+                    }).thenComposeAsync(voidRpcResult -> {
+                        LOG.debug("AddBundleMessages successful: {}, msg: {}", voidRpcResult.isSuccessful(),
+                                voidRpcResult.getErrors());
+
+                        final CompletableFuture<RpcResult<Void>> controlCommitFuture =
+                                makeCompletableFuture(bundleService.controlBundle(commitBundleInput));
+
+                        return controlCommitFuture;
+                    }).thenAccept(voidRpcResult -> {
+                        LOG.debug("Commit successful: {}, msg: {}", voidRpcResult.isSuccessful(),
+                                voidRpcResult.getErrors());
+                    });
             }
         }
     }
@@ -193,17 +200,16 @@ public class Activator extends AbstractBrokerAwareActivator implements BindingAw
         List<Message> messages  = new ArrayList<>();
 
 
-        messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(
-                new BundleAddGroupCaseBuilder()
-                        .setAddGroupCaseData(new AddGroupCaseDataBuilder(createGroup(1l)).build()).build()).build());
+        messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(new BundleAddGroupCaseBuilder()
+            .setAddGroupCaseData(new AddGroupCaseDataBuilder(createGroup(1L)).build()).build()).build());
 
-        messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(
-                new BundleAddFlowCaseBuilder()
-                        .setAddFlowCaseData(new AddFlowCaseDataBuilder(createFlow("42", 1l, 1, (short) 1)).build()).build()).build());
+        messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(new BundleAddFlowCaseBuilder()
+                .setAddFlowCaseData(new AddFlowCaseDataBuilder(createFlow("42", 1L, 1, (short) 1)).build()).build())
+                .build());
 
-        messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(
-                new BundleAddFlowCaseBuilder()
-                        .setAddFlowCaseData(new AddFlowCaseDataBuilder(createFlow("43", 1l, 2, (short) 2)).build()).build()).build());
+        messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(new BundleAddFlowCaseBuilder()
+                .setAddFlowCaseData(new AddFlowCaseDataBuilder(createFlow("43", 1L, 2, (short) 2)).build()).build())
+                .build());
 
         LOG.debug("createMessages() passing {}", messages);
 
@@ -214,7 +220,7 @@ public class Activator extends AbstractBrokerAwareActivator implements BindingAw
         MatchBuilder matchBuilder = new MatchBuilder();
         matchBuilder.setEthernetMatch(new EthernetMatchBuilder()
                 .setEthernetType(new EthernetTypeBuilder()
-                        .setType(new EtherType(2048l)).build()).build());
+                        .setType(new EtherType(2048L)).build()).build());
 
         FlowBuilder flowBuilder = new FlowBuilder();
         flowBuilder.setMatch(matchBuilder.build());
@@ -250,7 +256,6 @@ public class Activator extends AbstractBrokerAwareActivator implements BindingAw
     }
 
     private static BucketsBuilder createBuckets() {
-        List<Bucket> bucketList = new ArrayList<>();
         List<Action> actionList = new ArrayList<>();
 
         actionList.add(new ActionBuilder()
@@ -260,9 +265,10 @@ public class Activator extends AbstractBrokerAwareActivator implements BindingAw
                         .build()).build());
 
         BucketBuilder bucketBuilder = new BucketBuilder();
-        bucketBuilder.setBucketId(new BucketId(12l));
+        bucketBuilder.setBucketId(new BucketId(12L));
         bucketBuilder.setAction(actionList);
 
+        List<Bucket> bucketList = new ArrayList<>();
         bucketList.add(bucketBuilder.build());
 
         actionList = new ArrayList<>();
@@ -291,7 +297,7 @@ public class Activator extends AbstractBrokerAwareActivator implements BindingAw
                 .build());
 
         bucketBuilder = new BucketBuilder();
-        bucketBuilder.setBucketId(new BucketId(13l));
+        bucketBuilder.setBucketId(new BucketId(13L));
         bucketBuilder.setAction(actionList);
 
         bucketList.add(bucketBuilder.build());
@@ -303,7 +309,6 @@ public class Activator extends AbstractBrokerAwareActivator implements BindingAw
     }
 
     private static InstructionsBuilder createGroupInstructions(long groupId) {
-        List<Action> actionList = new ArrayList<>();
         ActionBuilder actionBuilder = new ActionBuilder();
 
         GroupActionBuilder groupActionBuilder = new GroupActionBuilder();
@@ -312,13 +317,15 @@ public class Activator extends AbstractBrokerAwareActivator implements BindingAw
         actionBuilder.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionBuilder.build()).build());
         actionBuilder.setOrder(1);
         actionBuilder.setKey(new ActionKey(0));
+        List<Action> actionList = new ArrayList<>();
         actionList.add(actionBuilder.build());
 
         ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
         applyActionsBuilder.setAction(actionList);
 
         InstructionBuilder instructionBuilder = new InstructionBuilder();
-        instructionBuilder.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(applyActionsBuilder.build()).build());
+        instructionBuilder.setInstruction(new ApplyActionsCaseBuilder()
+                .setApplyActions(applyActionsBuilder.build()).build());
         instructionBuilder.setOrder(0);
         instructionBuilder.setKey(new InstructionKey(0));
 
index 7e2ab062776053102c352f04e1012ad1819e3590..f615e734f0d30ff1347042e65651b1d168fe7477 100644 (file)
@@ -17,15 +17,14 @@ public class Activator extends AbstractBindingAwareConsumer {
     SimpleDropFirewall service;
     private SalFlowService flowService;
     private SimpleDropFirewallCli cliAdapter;
-    
-    
+
     @Override
     protected void startImpl(BundleContext context) {
         service = new SimpleDropFirewall();
-        
+
         cliAdapter.setService(service);
     }
-    
+
     @Override
     public void onSessionInitialized(ConsumerContext session) {
         service.setContext(session);
index 06141fb4c0591ca4b82c873463d95d556ef25e3a..d0137d7c965c28b3005307385373adab4d443f87 100644 (file)
@@ -35,13 +35,10 @@ public class SimpleDropFirewallCli {
     }
 
     /**
-     * Form of input is:
-     *
-     * node name node-connector number source ip-address destinatinon ip-address
+     * Form of input is: node name node-connector number source ip-address destinatinon ip-address.
      *
      * @param cliInput
      *            Parsed input from CLI
-     * @return
      */
     public AddFlowInput createTcpFlow(final List<String> cliInput) {
         AddFlowInputBuilder ret = new AddFlowInputBuilder();
@@ -76,7 +73,7 @@ public class SimpleDropFirewallCli {
 
         List<Instruction> isntructions = Collections.singletonList(instructionBldr.build());
         InstructionsBuilder instructionsBldr = new InstructionsBuilder();
-               instructionsBldr.setInstruction(isntructions);
+        instructionsBldr.setInstruction(isntructions);
 
         ret.setInstructions(instructionsBldr.build());
 
index 67142e389faed21ec9537f68ba7e5e719f335c74..f7d278f8b4d0766286f99343feb3af9a1ccd24f4 100644 (file)
@@ -7,22 +7,21 @@
  */
 package org.opendaylight.openflowjava.protocol.impl.clients;
 
-import java.net.InetAddress;
-import java.util.concurrent.Callable;
-
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.SettableFuture;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.channel.EventLoopGroup;
 import io.netty.channel.socket.nio.NioSocketChannel;
+import java.net.InetAddress;
+import java.util.concurrent.Callable;
 import org.slf4j.LoggerFactory;
 
 
 /**
- * Callable client class, inspired by SimpleClient class
- * Simulating device/switch connected to controller
+ * Callable client class, inspired by SimpleClient class.
+ * Simulating device/switch connected to controller.
+ *
  * @author Jozef Bacigal
- * Date: 4.3.2016.
  */
 public class CallableClient implements Callable<Boolean>, OFClient {
 
@@ -81,6 +80,7 @@ public class CallableClient implements Callable<Boolean>, OFClient {
 
 
     @Override
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public Boolean call() throws Exception {
         Preconditions.checkNotNull(bootstrap);
         Preconditions.checkNotNull(workerGroup);
@@ -99,7 +99,7 @@ public class CallableClient implements Callable<Boolean>, OFClient {
                     scenarioHandler.wait();
                 }
             }
-        } catch (Exception ex) {
+        } catch (RuntimeException ex) {
             LOG.error(ex.getMessage(), ex);
             return false;
         }
index 8538d7ba75a5148111da12a396f44bcc3dbbd498..13babaa5106c66b68690386ef399346951d12726 100644 (file)
@@ -9,14 +9,15 @@
 package org.opendaylight.openflowjava.protocol.impl.clients;
 
 /**
- * Uniting interface used for scenario support
- * @author michal.polkorab
+ * Uniting interface used for scenario support.
  *
+ * @author michal.polkorab
  */
 public interface ClientEvent {
 
     /**
-     * Common method for triggering events
+     * Common method for triggering events.
+     *
      * @return true if event executed successfully
      */
     boolean eventExecuted();
index 64217d8e37895bc5700cc2ee47191d65c08ddb37..284a2654b9ae8c485a843a0102c93282cb687dc7 100644 (file)
@@ -8,9 +8,14 @@
 
 package org.opendaylight.openflowjava.protocol.impl.clients;
 
+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;
@@ -55,7 +60,8 @@ public final class ClientSslContextFactory {
 
             clientContext = SSLContext.getInstance(PROTOCOL);
             clientContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
-        } catch (Exception e) {
+        } catch (KeyStoreException | NoSuchAlgorithmException | CertificateException | IOException
+                | UnrecoverableKeyException | KeyManagementException e) {
             throw new Error(
                     "Failed to initialize the client-side SSLContext", e);
         }
@@ -64,9 +70,9 @@ public final class ClientSslContextFactory {
     }
 
     /**
-     * @return client context
+     * Returns the client context.
      */
     public static SSLContext getClientContext() {
         return CLIENT_CONTEXT;
     }
-}
\ No newline at end of file
+}
index e3e6069770523291cce6f027b33de2b1cba8e634..8328b3cac1706a8cdfbbba811e5ba02d631a8694 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.openflowjava.protocol.impl.clients;
 import java.io.InputStream;
 
 /**
- * Class for storing keys
+ * Class for storing keys.
  *
  * @author michal.polkorab
  */
@@ -24,7 +24,7 @@ public final class ClientSslKeyStore {
     }
 
     /**
-     * InputStream instance of key
+     * InputStream instance of key.
      *
      * @return key as InputStream
      */
@@ -37,16 +37,16 @@ public final class ClientSslKeyStore {
     }
 
     /**
-     * @return certificate password as char[]
+     * Returns the certificate password as char[].
      */
     public static char[] getCertificatePassword() {
         return "opendaylight".toCharArray();
     }
 
     /**
-     * @return KeyStore password as char[]
+     * Returns the KeyStore password as char[].
      */
     public static char[] getKeyStorePassword() {
         return "opendaylight".toCharArray();
     }
-}
\ No newline at end of file
+}
index 5f7929f686366a4c19d366e972f21abe4127d373..6d0fe39b41337d94b94889cf3d229f063408353c 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.openflowjava.protocol.impl.clients;
 import java.io.InputStream;
 
 /**
- * Class for storing keys
+ * Class for storing keys.
  *
  * @author michal.polkorab
  */
@@ -24,7 +24,7 @@ public final class ClientSslTrustStore {
     }
 
     /**
-     * InputStream instance of key
+     * InputStream instance of key.
      *
      * @return key as InputStream
      */
@@ -37,16 +37,16 @@ public final class ClientSslTrustStore {
     }
 
     /**
-     * @return certificate password as char[]
+     * Returns the certificate password as char[].
      */
     public static char[] getCertificatePassword() {
         return "opendaylight".toCharArray();
     }
 
     /**
-     * @return KeyStore password as char[]
+     * Returns the KeyStore password as char[].
      */
     public static char[] getKeyStorePassword() {
         return "opendaylight".toCharArray();
     }
-}
\ No newline at end of file
+}
index 2b7440f4102d95b76f390a3ea584324a22e5505c..874e7a956d5b39376258a865063ce34b57d7f66f 100644 (file)
@@ -13,7 +13,7 @@ import javax.xml.bind.annotation.XmlType;
 
 
 /**
- * <p>Java class for eventType.
+ * Java class for eventType.
  */
 @XmlType(name = "eventType")
 @XmlEnum
@@ -27,21 +27,21 @@ public enum EventType {
     SEND_EVENT("sendEvent");
     private final String value;
 
-    EventType(String v) {
-        value = v;
+    EventType(String val) {
+        value = val;
     }
 
     public String value() {
         return value;
     }
 
-    public static EventType fromValue(String v) {
+    public static EventType fromValue(String val) {
         for (EventType c: EventType.values()) {
-            if (c.value.equals(v)) {
+            if (c.value.equals(val)) {
                 return c;
             }
         }
-        throw new IllegalArgumentException(v);
+        throw new IllegalArgumentException(val);
     }
 
 }
index 5afb039f17443a4592b61b35d0cae30969de2146..d19f655757817e5efa269f2be9334460caad61ca 100644 (file)
@@ -7,25 +7,22 @@
  */
 package org.opendaylight.openflowjava.protocol.impl.clients;
 
+import com.google.common.util.concurrent.SettableFuture;
 import io.netty.bootstrap.ServerBootstrap;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.EventLoopGroup;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.channel.socket.nio.NioServerSocketChannel;
 import io.netty.util.concurrent.Future;
-
 import java.net.InetSocketAddress;
 import java.util.concurrent.ExecutionException;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.util.concurrent.SettableFuture;
-
 /**
- * Listening client for testing purposes
- * @author martin.uhlir
+ * Listening client for testing purposes.
  *
+ * @author martin.uhlir
  */
 public class ListeningSimpleClient implements OFClient {
 
@@ -38,7 +35,7 @@ public class ListeningSimpleClient implements OFClient {
     private ScenarioHandler scenarioHandler;
 
     /**
-     * Constructor of the class
+     * Constructor of the class.
      *
      * @param port host listening port
      */
@@ -53,7 +50,7 @@ public class ListeningSimpleClient implements OFClient {
     }
 
     /**
-     * Starting class of {@link ListeningSimpleClient}
+     * Starting class of {@link ListeningSimpleClient}.
      */
     @Override
     public void run() {
@@ -62,14 +59,14 @@ public class ListeningSimpleClient implements OFClient {
         SimpleClientInitializer clientInitializer = new SimpleClientInitializer(isOnlineFuture, securedClient);
         clientInitializer.setScenario(scenarioHandler);
         try {
-            ServerBootstrap b = new ServerBootstrap();
-            b.group(bossGroup, workerGroup)
+            ServerBootstrap bootstrap = new ServerBootstrap();
+            bootstrap.group(bossGroup, workerGroup)
                 .channel(NioServerSocketChannel.class)
                 .childHandler(clientInitializer);
 
-            ChannelFuture f = b.bind(port).sync();
+            ChannelFuture future = bootstrap.bind(port).sync();
             // Update port, as it may have been specified as 0
-            this.port = ((InetSocketAddress) f.channel().localAddress()).getPort();
+            this.port = ((InetSocketAddress) future.channel().localAddress()).getPort();
             isOnlineFuture.set(true);
 
             synchronized (scenarioHandler) {
@@ -78,7 +75,7 @@ public class ListeningSimpleClient implements OFClient {
                     scenarioHandler.wait();
                 }
             }
-        } catch (Exception ex) {
+        } catch (InterruptedException ex) {
             LOG.error(ex.getMessage(), ex);
         } finally {
             LOG.debug("listening client shutting down");
@@ -94,6 +91,8 @@ public class ListeningSimpleClient implements OFClient {
     }
 
     /**
+     * Disconnect.
+     *
      * @return close future
      */
     public Future<?> disconnect() {
@@ -122,7 +121,7 @@ public class ListeningSimpleClient implements OFClient {
     }
 
     /**
-     * @return actual port number
+     * Returns the actual port number.
      */
     public int getPort() {
         return this.port;
index 169395c6fbd52b92ebe4b3550d73ef6164fc82e4..ce25859e23dcaf3ec607c49c697952e6030536f1 100644 (file)
@@ -11,30 +11,33 @@ package org.opendaylight.openflowjava.protocol.impl.clients;
 import com.google.common.util.concurrent.SettableFuture;
 
 /**
- * Unifying interface for simple clients / switch simulators
+ * Unifying interface for simple clients / switch simulators.
  *
  * @author michal.polkorab
  */
 public interface OFClient extends Runnable {
 
     /**
-     * @return the isOnlineFuture which is set when client is started
+     * Returns the isOnlineFuture which is set when client is started.
      */
     SettableFuture<Boolean> getIsOnlineFuture();
 
     /**
-     * @return the scenarioDone when scenario is successfully finished
+     * Returns the scenarioDone when scenario is successfully finished.
      */
     SettableFuture<Boolean> getScenarioDone();
 
     /**
+     * Sets the ScenarioHandler.
+     *
      * @param scenario list of desired actions
      */
     void setScenarioHandler(ScenarioHandler scenario);
 
     /**
-     * @param securedClient true is client should use encrypted communication,
-     * false otherwise
+     * Sets wether client should use encrypted communication.
+     *
+     * @param securedClient true is client should use encrypted communication, false otherwise
      */
     void setSecuredClient(boolean securedClient);
-}
\ No newline at end of file
+}
index deb953a9d067e9f168683e727ae051d31e7ace55..700cefc6c25383a8e88b7bd69e7273fdfabd659d 100644 (file)
@@ -17,12 +17,12 @@ import javax.xml.bind.annotation.XmlType;
 
 
 /**
- * <p>Java class for scenarioType complex type.
+ * Java class for scenarioType complex type.
  */
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "scenario", propOrder = {
     "step"
-})
+    })
 public class Scenario {
 
     @XmlElement(required = true)
index 3e01cfa543a758bb21b602ff3aa4d5cfbc1a5c96..76fc3e6cef808a1cf211ad2ba6aadf5096b559d9 100644 (file)
@@ -12,14 +12,12 @@ import java.io.IOException;
 import java.util.ArrayDeque;
 import java.util.Deque;
 import java.util.Map;
-
+import javax.xml.bind.JAXBException;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.xml.sax.SAXException;
 
-import javax.xml.bind.JAXBException;
-
 /**
- * Class for providing prepared handshake scenario
+ * Class for providing prepared handshake scenario.
  *
  * @author michal.polkorab
  */
@@ -62,23 +60,28 @@ public final class ScenarioFactory {
     public static Deque<ClientEvent> createHandshakeScenarioWithBarrier() {
         Deque<ClientEvent> stack = new ArrayDeque<>();
         stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 01")));
-        stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 10 00 00 00 15 00 01 00 08 00 00 00 12"))); //Hello message 21
+        stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes(
+                "04 00 00 10 00 00 00 15 00 01 00 08 00 00 00 12"))); //Hello message 21
         stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 02")));
         stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 02 "
                 + "00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 00 01 02 03 00 01 02 03")));
-        stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 14 00 08 00 00 00 00"))); //Barrier request
+        stack.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes(
+                "04 14 00 08 00 00 00 00"))); //Barrier request
         stack.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 15 00 08 00 00 00 04"))); //Barrier reply
         return stack;
     }
 
     /**
-     * Creates stack from XML file
+     * Creates stack from XML file.
+     *
      * @return stack filled with Handshake messages
      */
-    public static Deque<ClientEvent> getScenarioFromXml(String scenarioName, String scenarioFile) throws JAXBException, SAXException, IOException {
+    public static Deque<ClientEvent> getScenarioFromXml(String scenarioName, String scenarioFile)
+            throws JAXBException, SAXException, IOException {
         ScenarioService scenarioService = new ScenarioServiceImpl(scenarioFile);
         Deque<ClientEvent> stack = new ArrayDeque<>();
-        for (Map.Entry<Integer, ClientEvent> clientEvent : scenarioService.getEventsFromScenario(scenarioService.unMarshallData(scenarioName)).entrySet()) {
+        for (Map.Entry<Integer, ClientEvent> clientEvent : scenarioService.getEventsFromScenario(
+                scenarioService.unMarshallData(scenarioName)).entrySet()) {
             stack.addFirst(clientEvent.getValue());
         }
         return stack;
@@ -101,7 +104,8 @@ public final class ScenarioFactory {
         queue.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 00 00 08 00 00 00 02")));
         queue.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 05 00 08 00 00 00 03")));
         queue.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 06 00 20 00 00 00 03 "
-                + "00 01 02 03 04 05 06 07 00 01 02 03 01 " + String.format("%02x ", auxiliaryId) + " 00 00 00 01 02 03 00 01 02 03")));
+                + "00 01 02 03 04 05 06 07 00 01 02 03 01 " + String.format("%02x ", auxiliaryId)
+                + " 00 00 00 01 02 03 00 01 02 03")));
         return queue;
     }
 
index 88fd9b64bcf0904cb49f9cb030e2dc17c3f42ba6..7787924441035bdfe9421d0c01e57697e606da2d 100644 (file)
@@ -9,19 +9,17 @@
 package org.opendaylight.openflowjava.protocol.impl.clients;
 
 import io.netty.channel.ChannelHandlerContext;
-
 import java.util.Deque;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
+ * Scenario handler thread.
  *
  * @author michal.polkorab
- *
  */
 public class ScenarioHandler extends Thread {
 
@@ -36,6 +34,7 @@ public class ScenarioHandler extends Thread {
     private boolean finishedOK = true;
 
     /**
+     * Constructor.
      *
      * @param scenario {@link Deque}
      */
@@ -44,7 +43,7 @@ public class ScenarioHandler extends Thread {
         ofMsg = new LinkedBlockingQueue<>();
     }
 
-    public ScenarioHandler(Deque<ClientEvent> scenario, int freeze, long sleepBetweenTries){
+    public ScenarioHandler(Deque<ClientEvent> scenario, int freeze, long sleepBetweenTries) {
         this.scenario = scenario;
         ofMsg = new LinkedBlockingQueue<>();
         this.sleepBetweenTries = sleepBetweenTries;
@@ -100,20 +99,22 @@ public class ScenarioHandler extends Thread {
     }
 
     /**
-     * @return true if scenario is done / empty
+     * Returns true if scenario is done / empty.
      */
     public boolean isEmpty() {
         return scenario.isEmpty();
     }
 
     /**
-     * @return scenario
+     * Returns the scenario.
      */
     public Deque<ClientEvent> getScenario() {
         return scenario;
     }
 
     /**
+     * Sets the scenario.
+     *
      * @param scenario scenario filled with desired events
      */
     public void setScenario(Deque<ClientEvent> scenario) {
@@ -121,6 +122,8 @@ public class ScenarioHandler extends Thread {
     }
 
     /**
+     * Sets the ChannelHandlerContext.
+     *
      * @param ctx context which will be used for sending messages (SendEvents)
      */
     public void setCtx(ChannelHandlerContext ctx) {
@@ -128,6 +131,8 @@ public class ScenarioHandler extends Thread {
     }
 
     /**
+     * Adds a message.
+     *
      * @param message received message that is compared to expected message
      */
     public void addOfMsg(byte[] message) {
@@ -135,7 +140,7 @@ public class ScenarioHandler extends Thread {
     }
 
     /**
-     * @return true is scenario is finished
+     * Returns true is scenario is finished.
      */
     public boolean isScenarioFinished() {
         return scenarioFinished;
index 8087998e022344f6cfcc47dea1c209c5fedc7240..15dd637955ea1ae01a03c89e65d56e1d169838fa 100644 (file)
@@ -7,16 +7,15 @@
  */
 package org.opendaylight.openflowjava.protocol.impl.clients;
 
-import org.xml.sax.SAXException;
-
-import javax.xml.bind.JAXBException;
 import java.io.IOException;
 import java.util.SortedMap;
+import javax.xml.bind.JAXBException;
+import org.xml.sax.SAXException;
 
 /**
+ * Interface for a scenario service.
  *
  * @author Jozef Bacigal
- * Date: 8.3.2016
  */
 interface ScenarioService {
 
@@ -30,8 +29,6 @@ interface ScenarioService {
      * Method to load data from XML configuration file. Each configuration has a name.
      * @param scenarioName {@link String}
      * @return scenarios
-     * @throws SAXException
-     * @throws JAXBException
      */
     Scenario unMarshallData(String scenarioName) throws SAXException, JAXBException;
 
index 175255541d42a2e120e27b95d5734a938e6cfe5f..703e97b508644a8de90c1b603102e2bafd16ec9f 100644 (file)
@@ -24,18 +24,19 @@ import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
 
 /**
+ * Implementation of ScenarioService.
+ *
  * @author Jozef Bacigal
- *         Date: 9.3.2016
  */
 public class ScenarioServiceImpl implements ScenarioService {
 
     private static final Logger LOG = LoggerFactory.getLogger(ScenarioServiceImpl.class);
 
-    private String XML_FILE_PATH_WITH_FILE_NAME = SIMPLE_CLIENT_SRC_MAIN_RESOURCES + SCENARIO_XML;
+    private String xmlFilePathWithFileName = SIMPLE_CLIENT_SRC_MAIN_RESOURCES + SCENARIO_XML;
 
-    public ScenarioServiceImpl(String scenarioFile){
+    public ScenarioServiceImpl(String scenarioFile) {
         if (null != scenarioFile && !scenarioFile.isEmpty()) {
-            this.XML_FILE_PATH_WITH_FILE_NAME = scenarioFile;
+            this.xmlFilePathWithFileName = scenarioFile;
         }
     }
 
@@ -50,8 +51,9 @@ public class ScenarioServiceImpl implements ScenarioService {
         Unmarshaller unmarshaller = jc.createUnmarshaller();
         unmarshaller.setSchema(schema);
 
-        Scenarios scenarios = (Scenarios) unmarshaller.unmarshal(new File(XML_FILE_PATH_WITH_FILE_NAME));
-        LOG.debug("Scenarios ({}) are un-marshaled from {}", scenarios.getScenario().size(), XML_FILE_PATH_WITH_FILE_NAME);
+        Scenarios scenarios = (Scenarios) unmarshaller.unmarshal(new File(xmlFilePathWithFileName));
+        LOG.debug("Scenarios ({}) are un-marshaled from {}", scenarios.getScenario().size(),
+                xmlFilePathWithFileName);
 
         boolean foundConfiguration = false;
         Scenario scenarioType = null;
@@ -75,11 +77,20 @@ public class ScenarioServiceImpl implements ScenarioService {
         SortedMap<Integer, ClientEvent> events = new TreeMap<>();
         Integer counter = 0;
         for (Step step : scenario.getStep()) {
-            LOG.debug("Step {}: {}, type {}, bytes {}", step.getOrder(), step.getName(), step.getEvent().value(), step.getBytes().toArray());
+            LOG.debug("Step {}: {}, type {}, bytes {}", step.getOrder(), step.getName(), step.getEvent().value(),
+                    step.getBytes().toArray());
             switch (step.getEvent()) {
-                case SLEEP_EVENT: events.put(counter++, new SleepEvent(1000)); break;
-                case SEND_EVENT: events.put(counter++, new SendEvent(ByteBufUtils.serializeList(step.getBytes()))); break;
-                case WAIT_FOR_MESSAGE_EVENT: events.put(counter++, new WaitForMessageEvent(ByteBufUtils.serializeList(step.getBytes()))); break;
+                case SLEEP_EVENT:
+                    events.put(counter++, new SleepEvent(1000));
+                    break;
+                case SEND_EVENT:
+                    events.put(counter++, new SendEvent(ByteBufUtils.serializeList(step.getBytes())));
+                    break;
+                case WAIT_FOR_MESSAGE_EVENT:
+                    events.put(counter++, new WaitForMessageEvent(ByteBufUtils.serializeList(step.getBytes())));
+                    break;
+                default:
+                    break;
             }
         }
         return events;
index 48b3373e9575a20269ce391d15ee662860e9b005..bef582b68a60c71f2a18430e2a1558c1dce8d50b 100644 (file)
@@ -17,12 +17,12 @@ import javax.xml.bind.annotation.XmlType;
 
 
 /**
- * <p>Java class for anonymous complex type.
+ * Java class for anonymous complex type.
  */
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "", propOrder = {
     "scenario"
-})
+    })
 @XmlRootElement(name = "scenarios")
 public class Scenarios {
 
@@ -43,6 +43,7 @@ public class Scenarios {
      * <pre>
      *    getScenario().add(newItem);
      * </pre>
+     *
      * <p>
      * Objects of the following type(s) are allowed in the list
      * {@link Scenario }
index 98934f08d70c13f2c149c096d699b9227ecb4839..d5885ef62aff0ab433dd7cf535268981ee794cfa 100644 (file)
@@ -10,13 +10,12 @@ package org.opendaylight.openflowjava.protocol.impl.clients;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
-
 import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Class representing sending message event
+ * Class representing sending message event.
  *
  * @author michal.polkorab
  */
@@ -27,6 +26,8 @@ public class SendEvent implements ClientEvent {
     protected ChannelHandlerContext ctx;
 
     /**
+     * Constructor.
+     *
      * @param msgToSend message to be sent
      */
     public SendEvent(byte[] msgToSend) {
@@ -50,6 +51,8 @@ public class SendEvent implements ClientEvent {
     }
 
     /**
+     * Sets the ChannelHandlerContext.
+     *
      * @param ctx context which will be used for sending messages (SendEvents)
      */
     public void setCtx(ChannelHandlerContext ctx) {
index fb0fda091eff18268c39dd9f1ede432fa84198e5..8bbcd85a0e667d2cbc1d4f03a5db8c7cac5249eb 100644 (file)
@@ -8,22 +8,19 @@
 
 package org.opendaylight.openflowjava.protocol.impl.clients;
 
+import com.google.common.util.concurrent.SettableFuture;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.channel.EventLoopGroup;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.channel.socket.nio.NioSocketChannel;
 import io.netty.util.concurrent.Future;
-
 import java.net.InetAddress;
 import java.util.concurrent.ExecutionException;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.util.concurrent.SettableFuture;
-
 /**
- * Simple client for testing purposes
+ * Simple client for testing purposes.
  *
  * @author michal.polkorab
  */
@@ -39,7 +36,7 @@ public class SimpleClient implements OFClient {
     private ScenarioHandler scenarioHandler;
 
     /**
-     * Constructor of class
+     * Constructor of class.
      *
      * @param host address of host
      * @param port host listening port
@@ -56,7 +53,7 @@ public class SimpleClient implements OFClient {
     }
 
     /**
-     * Starting class of {@link SimpleClient}
+     * Starting class of {@link SimpleClient}.
      */
     @Override
     public void run() {
@@ -64,12 +61,12 @@ public class SimpleClient implements OFClient {
         SimpleClientInitializer clientInitializer = new SimpleClientInitializer(isOnlineFuture, securedClient);
         clientInitializer.setScenario(scenarioHandler);
         try {
-            Bootstrap b = new Bootstrap();
-            b.group(group)
+            Bootstrap bootstrap = new Bootstrap();
+            bootstrap.group(group)
                 .channel(NioSocketChannel.class)
                 .handler(clientInitializer);
 
-            b.connect(host, port).sync();
+            bootstrap.connect(host, port).sync();
 
             synchronized (scenarioHandler) {
                 LOG.debug("WAITING FOR SCENARIO");
@@ -77,7 +74,7 @@ public class SimpleClient implements OFClient {
                     scenarioHandler.wait();
                 }
             }
-        } catch (Exception ex) {
+        } catch (InterruptedException ex) {
             LOG.error(ex.getMessage(), ex);
         } finally {
             LOG.debug("shutting down");
@@ -92,6 +89,8 @@ public class SimpleClient implements OFClient {
     }
 
     /**
+     * Disconnect.
+     *
      * @return close future
      */
     public Future<?> disconnect() {
@@ -105,10 +104,7 @@ public class SimpleClient implements OFClient {
     }
 
     /**
-     * Sets up {@link SimpleClient} and fires run()
-     *
-     * @param args
-     * @throws Exception
+     * Sets up {@link SimpleClient} and fires run().
      */
     public static void main(String[] args) throws Exception {
         String host;
index 02c9cd98d85a0c7b5560d82027be538c0c8e6943..dbf479c701f25d2a7dc05ba004653f15db999fd7 100644 (file)
@@ -12,9 +12,7 @@ package org.opendaylight.openflowjava.protocol.impl.clients;
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.ByteToMessageDecoder;
-
 import java.util.List;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -25,7 +23,7 @@ import org.slf4j.LoggerFactory;
  */
 public class SimpleClientFramer extends ByteToMessageDecoder {
 
-    /** 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 static final Logger LOG = LoggerFactory.getLogger(SimpleClientFramer.class);
index 863f9aebada634e3e4c4e2e4b1b50d8d1015144b..eac94db3d1079df1edb3565e5a4f755af25e09cf 100644 (file)
@@ -9,17 +9,16 @@
 
 package org.opendaylight.openflowjava.protocol.impl.clients;
 
+import com.google.common.util.concurrent.SettableFuture;
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelInboundHandlerAdapter;
-
 import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.util.concurrent.SettableFuture;
-
 /**
+ * Simple client handler.
  *
  * @author michal.polkorab
  */
@@ -31,6 +30,8 @@ public class SimpleClientHandler extends ChannelInboundHandlerAdapter {
     protected ScenarioHandler scenarioHandler;
 
     /**
+     * Constructor.
+     *
      * @param isOnlineFuture future notifier of connected channel
      * @param scenarioHandler handler of scenario events
      */
@@ -66,10 +67,12 @@ public class SimpleClientHandler extends ChannelInboundHandlerAdapter {
     }
 
     /**
-     * @param scenarioHandler handler of scenario events
+     * Sets the ScenarioHandler.
+     *
+     * @param handler handler of scenario events
      */
-    public void setScenario(ScenarioHandler scenarioHandler) {
-        this.scenarioHandler = scenarioHandler;
+    public void setScenario(ScenarioHandler handler) {
+        this.scenarioHandler = handler;
     }
 
 }
index 21afc08b558c4296a5eca9b37da27e092cfd69c5..fd3821e8c35fb9ba81d229c103ab45e9425c79c4 100644 (file)
@@ -9,16 +9,15 @@
 
 package org.opendaylight.openflowjava.protocol.impl.clients;
 
+import com.google.common.util.concurrent.SettableFuture;
 import io.netty.channel.ChannelInitializer;
 import io.netty.channel.ChannelPipeline;
 import io.netty.channel.socket.SocketChannel;
 import io.netty.handler.ssl.SslHandler;
-
 import javax.net.ssl.SSLEngine;
 
-import com.google.common.util.concurrent.SettableFuture;
-
-/** Initializes secured {@link SimpleClient} pipeline
+/**
+ * Initializes secured {@link SimpleClient} pipeline.
  *
  * @author michal.polkorab
  */
@@ -29,6 +28,8 @@ public class SimpleClientInitializer extends ChannelInitializer<SocketChannel> {
     private ScenarioHandler scenarioHandler;
 
     /**
+     * Constructor.
+     *
      * @param isOnlineFuture future notifier of connected channel
      * @param secured true if {@link SimpleClient} should use encrypted communication
      */
@@ -55,9 +56,11 @@ public class SimpleClientInitializer extends ChannelInitializer<SocketChannel> {
     }
 
     /**
-     * @param scenarioHandler handler of scenario events
+     * Sets the ScenarioHandler.
+     *
+     * @param handler handler of scenario events
      */
-    public void setScenario(ScenarioHandler scenarioHandler) {
-        this.scenarioHandler = scenarioHandler;
+    public void setScenario(ScenarioHandler handler) {
+        this.scenarioHandler = handler;
     }
-}
\ No newline at end of file
+}
index 19229abce3f5684888cb29776d228048bdbbb889..9017a5195c2af451a53f0a0de356ce3a1c236da1 100644 (file)
@@ -12,16 +12,17 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Class representing sleep (wait) event
+ * Class representing sleep (wait) event.
  *
  * @author michal.polkorab
  */
 public class SleepEvent implements ClientEvent {
 
     private static final Logger LOG = LoggerFactory.getLogger(SleepEvent.class);
-    private long sleepTime;
+    private final long sleepTime;
 
     /**
+     * Constructor.
      *
      * @param sleepTime time of {@link Thread#sleep(long)} in milliseconds
      */
index e581c92af7664b5c4ce208eaed2e4b12cdd0e087..350944d51c61d14454a0d44032aec6f5b7f44e38 100644 (file)
@@ -18,7 +18,7 @@ import javax.xml.bind.annotation.XmlType;
 
 
 /**
- * <p>Java class for stepType complex type.
+ * Java class for stepType complex type.
  */
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "step", propOrder = {
@@ -26,7 +26,7 @@ import javax.xml.bind.annotation.XmlType;
     "name",
     "event",
     "bytes"
-})
+    })
 public class Step {
 
     protected short order;
@@ -100,6 +100,7 @@ public class Step {
      * <pre>
      *    getBytes().add(newItem);
      * </pre>
+     *
      * <p>
      * Objects of the following type(s) are allowed in the list
      * {@link Short }
index f7ff0a619899c16e188701d025613b6bd73f8308..d18438f04f2e03d2f856f96a66f731c2cff1e785 100644 (file)
@@ -8,23 +8,20 @@
 
 package org.opendaylight.openflowjava.protocol.impl.clients;
 
+import com.google.common.util.concurrent.SettableFuture;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.channel.ChannelOption;
 import io.netty.channel.EventLoopGroup;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.channel.socket.nio.NioDatagramChannel;
 import io.netty.util.concurrent.Future;
-
 import java.net.InetAddress;
 import java.util.concurrent.ExecutionException;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.util.concurrent.SettableFuture;
-
 /**
- * Simple client for testing purposes
+ * Simple client for testing purposes.
  *
  * @author michal.polkorab
  */
@@ -39,7 +36,7 @@ public class UdpSimpleClient implements OFClient {
     private ScenarioHandler scenarioHandler;
 
     /**
-     * Constructor of class
+     * Constructor of class.
      *
      * @param host address of host
      * @param port host listening port
@@ -56,7 +53,7 @@ public class UdpSimpleClient implements OFClient {
     }
 
     /**
-     * Starting class of {@link UdpSimpleClient}
+     * Starting class of {@link UdpSimpleClient}.
      */
     @Override
     public void run() {
@@ -64,13 +61,13 @@ public class UdpSimpleClient implements OFClient {
         UdpSimpleClientInitializer clientInitializer = new UdpSimpleClientInitializer(isOnlineFuture);
         clientInitializer.setScenario(scenarioHandler);
         try {
-            Bootstrap b = new Bootstrap();
-            b.group(group)
+            Bootstrap bootstrap = new Bootstrap();
+            bootstrap.group(group)
                 .channel(NioDatagramChannel.class)
                 .option(ChannelOption.SO_BROADCAST, false)
                 .handler(clientInitializer);
 
-            b.connect(host, port).sync();
+            bootstrap.connect(host, port).sync();
 
             synchronized (scenarioHandler) {
                 LOG.debug("WAITING FOR SCENARIO");
@@ -78,7 +75,7 @@ public class UdpSimpleClient implements OFClient {
                     scenarioHandler.wait();
                 }
             }
-        } catch (Exception ex) {
+        } catch (InterruptedException ex) {
             LOG.error(ex.getMessage(), ex);
         } finally {
             LOG.debug("shutting down");
@@ -93,6 +90,8 @@ public class UdpSimpleClient implements OFClient {
     }
 
     /**
+     * Disconnect.
+     *
      * @return close future
      */
     public Future<?> disconnect() {
@@ -101,10 +100,7 @@ public class UdpSimpleClient implements OFClient {
     }
 
     /**
-     * Sets up {@link UdpSimpleClient} and fires run()
-     *
-     * @param args
-     * @throws Exception
+     * Sets up {@link UdpSimpleClient} and fires run().
      */
     public static void main(String[] args) throws Exception {
         String host;
index b893a8f346c137b2fad81c694c6b022a7a3ae086..287276fe9b600f8ce46459b4bda8173e415a5852 100644 (file)
@@ -13,9 +13,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.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -26,7 +24,7 @@ import org.slf4j.LoggerFactory;
  */
 public class UdpSimpleClientFramer extends MessageToMessageDecoder<DatagramPacket> {
 
-    /** 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 static final Logger LOG = LoggerFactory.getLogger(UdpSimpleClientFramer.class);
index a68b6ab795bd42d73ce15b95fe365d6095ebb57e..4504eac413e067515b1b7cf036bf7446fec8f756 100644 (file)
@@ -9,13 +9,13 @@
 
 package org.opendaylight.openflowjava.protocol.impl.clients;
 
+import com.google.common.util.concurrent.SettableFuture;
 import io.netty.channel.ChannelInitializer;
 import io.netty.channel.ChannelPipeline;
 import io.netty.channel.socket.DatagramChannel;
 
-import com.google.common.util.concurrent.SettableFuture;
-
-/** Initializes udp pipeline
+/**
+ * Initializes udp pipeline.
  *
  * @author michal.polkorab
  */
@@ -25,6 +25,8 @@ public class UdpSimpleClientInitializer extends ChannelInitializer<DatagramChann
     private ScenarioHandler scenarioHandler;
 
     /**
+     * Constructor.
+     *
      * @param isOnlineFuture future notifier of connected channel
      */
     public UdpSimpleClientInitializer(SettableFuture<Boolean> isOnlineFuture) {
@@ -42,9 +44,11 @@ public class UdpSimpleClientInitializer extends ChannelInitializer<DatagramChann
     }
 
     /**
-     * @param scenarioHandler handler of scenario events
+     * Sets the ScenarioHandler.
+     *
+     * @param handler handler of scenario events
      */
-    public void setScenario(ScenarioHandler scenarioHandler) {
-        this.scenarioHandler = scenarioHandler;
+    public void setScenario(ScenarioHandler handler) {
+        this.scenarioHandler = handler;
     }
-}
\ No newline at end of file
+}
index 0854a27989a2bf4d36f946086414cb4aaaad74af..0e74e8aae8c5d4a5f9437af1b5495979f00f84ed 100644 (file)
@@ -9,22 +9,24 @@
 package org.opendaylight.openflowjava.protocol.impl.clients;
 
 import java.util.Arrays;
-
 import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Class representing waiting on message
+ * Class representing waiting on message.
+ *
  * @author michal.polkorab
  */
 public class WaitForMessageEvent implements ClientEvent {
 
     private static final Logger LOG = LoggerFactory.getLogger(WaitForMessageEvent.class);
-    private byte[] headerExpected;
+    private final byte[] headerExpected;
     private byte[] headerReceived;
 
     /**
+     * Constructor.
+     *
      * @param headerExpected header (first 8 bytes) of expected message
      */
     public WaitForMessageEvent(byte[] headerExpected) {
@@ -49,6 +51,8 @@ public class WaitForMessageEvent implements ClientEvent {
     }
 
     /**
+     * Sets the received header.
+     *
      * @param headerReceived header (first 8 bytes) of expected message
      */
     public void setHeaderReceived(byte[] headerReceived) {