X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=simple-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fclients%2FScenarioHandler.java;h=075c65681930f2d20f76601783b5e51ceaadf0fb;hb=07de1ed897da9d7dc70c6d550f38c59339ed751e;hp=9e8a8025d299399f248c79d49b92979d48d2d90d;hpb=ff2f581fe0e7a7138dc765cfe713bc2d0791297e;p=openflowjava.git diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java index 9e8a8025..075c6568 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ScenarioHandler.java @@ -1,4 +1,11 @@ -/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */ +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.openflowjava.protocol.impl.clients; import io.netty.channel.ChannelHandlerContext; @@ -11,16 +18,22 @@ 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 scenario; private BlockingQueue ofMsg; private ChannelHandlerContext ctx; + private int eventNumber; + private boolean scenarioFinished = false; /** - * + * * @param scenario */ public ScenarioHandler(Stack scenario) { @@ -32,6 +45,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 +63,7 @@ public class ScenarioHandler extends Thread { } if (peek.eventExecuted()) { scenario.pop(); + eventNumber++; freezeCounter = 0; } else { freezeCounter++; @@ -63,29 +78,52 @@ public class ScenarioHandler extends Thread { LOGGER.error(e.getMessage(), e); } } - LOGGER.info("Scenario finished"); + LOGGER.debug("Scenario finished"); synchronized (this) { - notify(); + scenarioFinished = true; + this.notify(); } } + /** + * @return true if scenario is done / empty + */ public boolean isEmpty() { return scenario.isEmpty(); } + /** + * @return scenario + */ public Stack getScenario() { return scenario; } + /** + * @param scenario scenario filled with desired events + */ public void setScenario(Stack 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); } + + /** + * @return true is scenario is finished + */ + public boolean isScenarioFinished() { + return scenarioFinished; + } }