Improved logging in ScenarioHandler
[openflowjava.git] / simple-client / src / main / java / org / opendaylight / openflowjava / protocol / impl / clients / ScenarioHandler.java
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);
     }