Improved logging in ScenarioHandler 03/2103/1
authorMichal Polkorab <michal.polkorab@pantheon.sk>
Wed, 23 Oct 2013 13:32:27 +0000 (15:32 +0200)
committerMichal Polkorab <michal.polkorab@pantheon.sk>
Wed, 23 Oct 2013 13:32:39 +0000 (15:32 +0200)
Removed warnings from SimpleClient and IntegrationTest bundles

Signed-off-by: Michal Polkorab <michal.polkorab@pantheon.sk>
12 files changed:
openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/IntegrationTest.java
openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/MockPlugin.java
openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/TestingConnConfigImpl.java
openflow-protocol-it/src/test/resources/log4j.xml
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientEvent.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioFactory.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SendEvent.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientHandler.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SimpleClientInitializer.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/SleepEvent.java
simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/WaitForMessageEvent.java

index 75e5a72a6eaba5170c43ffdf39b8d43d8a956e6f..31c9c6354018a56e1fb3083586f59b144d0eed03 100644 (file)
@@ -28,18 +28,15 @@ import org.slf4j.LoggerFactory;
 \r
 /**\r
  * @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
  */\r
 public class IntegrationTest {\r
 \r
-    /** Name of file in which OpenFLow protocol messages are stored in binary format */\r
+    private static final Logger LOGGER = LoggerFactory\r
+            .getLogger(IntegrationTest.class);\r
     private static int port;\r
     private static final FEATURE_SUPPORT DEFAULT_TLS_SUPPORT = FEATURE_SUPPORT.NOT_SUPPORTED;\r
     private static final int SWITCH_IDLE_TIMEOUT = 2000;\r
-\r
-    protected static final Logger LOGGER = LoggerFactory\r
-            .getLogger(IntegrationTest.class);\r
-\r
     private static final long CONNECTION_TIMEOUT = 2000;\r
     private InetAddress startupAddress;\r
     private MockPlugin mockPlugin;\r
@@ -64,13 +61,16 @@ public class IntegrationTest {
         port = server.getPort();\r
     }\r
 \r
+    /**\r
+     * @throws Exception\r
+     */\r
     @After\r
     public void tearDown() throws Exception {\r
         Thread.sleep(500);\r
     }\r
 \r
     /**\r
-     * Library integration and communication test\r
+     * Library integration and communication test with handshake\r
      * @throws Exception \r
      */\r
     @Test\r
@@ -86,7 +86,7 @@ public class IntegrationTest {
     }\r
 \r
     /**\r
-     * Library integration and communication test\r
+     * Library integration and communication test with handshake + echo exchange\r
      * @throws Exception \r
      */\r
     @Test\r
@@ -117,11 +117,10 @@ public class IntegrationTest {
     /**\r
      * @param amountOfCLients \r
      * @return new clients up and running\r
-     * @throws InterruptedException\r
-     * @throws ExecutionException\r
+     * @throws ExecutionException if some client could not start\r
      */\r
     private List<SimpleClient> createAndStartClient(int amountOfCLients, ScenarioHandler scenarioHandler)\r
-            throws InterruptedException, ExecutionException {\r
+            throws ExecutionException {\r
         List<SimpleClient> clientsHorde = new ArrayList<>();\r
         for (int i = 0; i < amountOfCLients; i++) {\r
             LOGGER.debug("startup address in createclient: " + startupAddress.getHostAddress());\r
index 3ba78a42be5baac6ae612ee057a444cc3cf11b1c..73d88fa5e9de8f7722a57364250563b81d13024c 100644 (file)
@@ -47,7 +47,8 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
     private ConnectionAdapter adapter;\r
     private SettableFuture<Void> finishedFuture;\r
     private int idleCounter = 0;\r
-    \r
+\r
+    /** Creates MockPlugin */\r
     public MockPlugin() {\r
         LOGGER.info("Creating MockPlugin");\r
         finishedFuture = SettableFuture.create();\r
@@ -182,6 +183,9 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
         LOGGER.debug("adapter: "+adapter);\r
     }\r
 \r
+    /**\r
+     * @return finishedFuture object\r
+     */\r
     public SettableFuture<Void> getFinishedFuture() {\r
         return finishedFuture;\r
     }\r
@@ -191,7 +195,10 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
         LOGGER.debug("switch status: "+notification.getInfo());\r
         idleCounter ++;\r
     }\r
-    \r
+\r
+    /**\r
+     * @return number of occured idleEvents\r
+     */\r
     public int getIdleCounter() {\r
         return idleCounter;\r
     }\r
index a7e9ef0ebaa27ba383d0cf9b364edb53b19da71c..3a9bd55b2ef75125863d6f2c93f1e95e78416f9a 100644 (file)
@@ -16,15 +16,21 @@ public class TestingConnConfigImpl implements ConnectionConfiguration {
     private Object transferProtocol;\r
     private FEATURE_SUPPORT tlsSupport;\r
     private long switchIdleTimeout;\r
-    \r
-    // TODO - implement transferProtocol\r
+\r
+    /**\r
+     * Creates {@link TestingConnConfigImpl}\r
+     * @param address \r
+     * @param port\r
+     * @param tlsSupport\r
+     * @param switchIdleTimeout\r
+     */\r
     public TestingConnConfigImpl(InetAddress address, int port, FEATURE_SUPPORT tlsSupport, long switchIdleTimeout) {\r
         this.address = address;\r
         this.port = port;\r
         this.tlsSupport = tlsSupport;\r
         this.switchIdleTimeout = switchIdleTimeout;\r
     }\r
-    \r
+\r
     @Override\r
     public InetAddress getAddress() {\r
         return address;\r
index c06081f05e6323f142db13c4dfd4a8676ce0a526..23b1b663af6ea90cec0bde764656fb859c5ccbaf 100644 (file)
         <level value="DEBUG" />\r
         <appender-ref ref="console" />\r
     </logger>\r
+    <logger name="org.opendaylight.openflowjava.protocol.impl.clients" additivity="false">\r
+        <level value="DEBUG" />\r
+        <appender-ref ref="console" />\r
+    </logger>\r
 \r
     <root>\r
         <priority value="INFO" />\r
index d5b5332aaeee5e2f59169e24e249db79dbea40e2..2f2d80ba4fdee71db457f3b2efaf3c2d73413575 100644 (file)
@@ -1,8 +1,16 @@
 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
 package org.opendaylight.openflowjava.protocol.impl.clients;
 
-
+/**
+ * Uniting interface used for scenario support
+ * @author michal.polkorab
+ *
+ */
 public interface ClientEvent {
 
+    /**
+     * Common method for triggering events
+     * @return true if event executed successfully
+     */
     public boolean eventExecuted();
 }
index 633bc7ca20112271c474b7c22feb3a2614bd00cc..25091960429a1a74412fdac666d9eabf2ec4ae1c 100644 (file)
@@ -6,8 +6,9 @@ import java.util.Stack;
 import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
 
 /**
+ * Class for providing prepared handshake scenario
+ * 
  * @author michal.polkorab
- *
  */
 public class ScenarioFactory {
 
index 45c1ef99b9cce2032c0eec2f10229c7484e2d55e..29244dba6484d8b34ae9d564f9010d05d6711d86 100644 (file)
@@ -11,13 +11,18 @@ import java.util.concurrent.TimeUnit;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
+/**
+ * 
+ * @author michal.polkorab
+ *
+ */
 public class ScenarioHandler extends Thread {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(ScenarioHandler.class);
     private Stack<ClientEvent> scenario;
     private BlockingQueue<byte[]> ofMsg;
     private ChannelHandlerContext ctx;
+    private int eventNumber;
 
     /**
      * 
@@ -32,6 +37,7 @@ public class ScenarioHandler extends Thread {
     public void run() {
         int freezeCounter = 0;
         while (!scenario.isEmpty()) {
+            LOGGER.debug("Running event #" + eventNumber);
             ClientEvent peek = scenario.peek();
             if (peek instanceof WaitForMessageEvent) {
                 LOGGER.debug("WaitForMessageEvent");
@@ -49,6 +55,7 @@ public class ScenarioHandler extends Thread {
             }
             if (peek.eventExecuted()) {
                 scenario.pop();
+                eventNumber++;
                 freezeCounter = 0;
             } else {
                 freezeCounter++;
@@ -68,23 +75,38 @@ public class ScenarioHandler extends Thread {
             this.notify();
         }
     }
-
+    
+    /**
+     * @return true if scenario is done / empty
+     */
     public boolean isEmpty() {
         return scenario.isEmpty();
     }
 
+    /**
+     * @return scenario
+     */
     public Stack<ClientEvent> getScenario() {
         return scenario;
     }
 
+    /**
+     * @param scenario scenario filled with desired events
+     */
     public void setScenario(Stack<ClientEvent> scenario) {
         this.scenario = scenario;
     }
 
+    /**
+     * @param ctx context which will be used for sending messages (SendEvents)
+     */
     public void setCtx(ChannelHandlerContext ctx) {
         this.ctx = ctx;
     }
 
+    /**
+     * @param message received message that is compared to expected message
+     */
     public void addOfMsg(byte[] message) {
         ofMsg.add(message);
     }
index 57445bd6655bdc65c32095555cedde451f66fcb1..d0ec8b9f560769905c00b3fed8c6150c8e1f98b7 100644 (file)
@@ -8,13 +8,20 @@ import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
+/**
+ * Class representing sending message event
+ * 
+ * @author michal.polkorab
+ */
 public class SendEvent implements ClientEvent {
 
     protected static final Logger LOGGER = LoggerFactory.getLogger(SendEvent.class);
     protected byte[] msgToSend;
     protected ChannelHandlerContext ctx;
 
+    /**
+     * @param msgToSend message to be sent
+     */
     public SendEvent(byte[] msgToSend) {
         this.msgToSend = msgToSend;
     }
@@ -42,6 +49,9 @@ public class SendEvent implements ClientEvent {
         return true;
     }
 
+    /**
+     * @param ctx context which will be used for sending messages (SendEvents)
+     */
     public void setCtx(ChannelHandlerContext ctx) {
         this.ctx = ctx;
     }
index f0990dae1869399f0d7c546b363030a5f33816a2..110570cdd842c0cd372be4c48a05a2a8522e1ff9 100644 (file)
@@ -24,6 +24,7 @@ public class SimpleClientHandler extends ChannelInboundHandlerAdapter {
 \r
     /**\r
      * @param isOnlineFuture future notifier of connected channel\r
+     * @param scenarioHandler handler of scenario events\r
      */\r
     public SimpleClientHandler(SettableFuture<Boolean> isOnlineFuture, ScenarioHandler scenarioHandler) {\r
         this.isOnlineFuture = isOnlineFuture;\r
@@ -62,6 +63,9 @@ public class SimpleClientHandler extends ChannelInboundHandlerAdapter {
         }\r
     }\r
 \r
+    /**\r
+     * @param scenarioHandler handler of scenario events\r
+     */\r
     public void setScenario(ScenarioHandler scenarioHandler) {\r
         this.scenarioHandler = scenarioHandler;\r
     }\r
index c495cbc5f3e5ecb885a2879747181479034017b5..8ca01e8e39db71bed2f391361e823ab26b3b3261 100644 (file)
@@ -25,6 +25,7 @@ public class SimpleClientInitializer extends ChannelInitializer<SocketChannel> {
 
     /**
      * @param isOnlineFuture future notifier of connected channel
+     * @param secured true if {@link SimpleClient} should use encrypted communication
      */
     public SimpleClientInitializer(SettableFuture<Boolean> isOnlineFuture, boolean secured) {
         this.isOnlineFuture = isOnlineFuture;
@@ -46,7 +47,10 @@ public class SimpleClientInitializer extends ChannelInitializer<SocketChannel> {
         isOnlineFuture = null;
 
     }
-    
+
+    /**
+     * @param scenarioHandler handler of scenario events
+     */
     public void setScenario(ScenarioHandler scenarioHandler) {
         this.scenarioHandler = scenarioHandler;
     }
index eb496ab3d369944a0a5ff738d04be6a3f9e3a0d5..490a094b14b52704785ba2fdcdde02b33c5156c5 100644 (file)
@@ -4,11 +4,20 @@ package org.opendaylight.openflowjava.protocol.impl.clients;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * Class representing sleep (wait) event
+ * 
+ * @author michal.polkorab
+ */
 public class SleepEvent implements ClientEvent {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(SleepEvent.class);
     private long sleepTime;
-    
+
+    /**
+     * 
+     * @param sleepTime time of {@link Thread#sleep(long)} in milliseconds
+     */
     public SleepEvent(long sleepTime) {
         this.sleepTime = sleepTime;
     }
index d9a38b025f27578ae568930b74dcc066a07b4b6a..1ad9b9441cfffdca618e7acc3425a247aee94049 100644 (file)
@@ -7,16 +7,21 @@ import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
-
+/**
+ * Class representing waiting on message
+ * @author michal.polkorab
+ */
 public class WaitForMessageEvent implements ClientEvent {
     
     private static final Logger LOGGER = LoggerFactory.getLogger(WaitForMessageEvent.class);
     private byte[] headerExpected;
     private byte[] headerReceived;
 
-    public WaitForMessageEvent(byte[] headerAwaited) {
-        this.headerExpected = headerAwaited;
+    /**
+     * @param headerExpected header (first 8 bytes) of expected message
+     */
+    public WaitForMessageEvent(byte[] headerExpected) {
+        this.headerExpected = headerExpected;
     }
 
     @Override
@@ -33,6 +38,9 @@ public class WaitForMessageEvent implements ClientEvent {
         return true;
     }
 
+    /**
+     * @param headerReceived header (first 8 bytes) of expected message
+     */
     public void setHeaderReceived(byte[] headerReceived) {
         this.headerReceived = headerReceived;
     }