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;
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()) {
- stack.addFirst(clientEvent.getValue());
+ for (ClientEvent clientEvent : scenarioService.getEventsFromScenario(
+ scenarioService.unMarshallData(scenarioName))) {
+ stack.addFirst(clientEvent);
}
return stack;
}
package org.opendaylight.openflowjava.protocol.impl.clients;
import java.io.IOException;
-import java.util.SortedMap;
+import java.util.List;
import javax.xml.bind.JAXBException;
import org.xml.sax.SAXException;
*/
Scenario unMarshallData(String scenarioName) throws SAXException, JAXBException;
- SortedMap<Integer, ClientEvent> getEventsFromScenario(Scenario scenario) throws IOException;
+ List<ClientEvent> getEventsFromScenario(Scenario scenario) throws IOException;
}
import com.google.common.base.Preconditions;
import java.io.File;
import java.io.IOException;
-import java.util.SortedMap;
-import java.util.TreeMap;
+import java.util.ArrayList;
+import java.util.List;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
}
@Override
- public SortedMap<Integer, ClientEvent> getEventsFromScenario(Scenario scenario) throws IOException {
+ public List<ClientEvent> getEventsFromScenario(Scenario scenario) throws IOException {
Preconditions.checkNotNull(scenario, "Scenario name not found. Check XML file, scenario name or directories.");
- SortedMap<Integer, ClientEvent> events = new TreeMap<>();
- Integer counter = 0;
- for (Step step : scenario.getStep()) {
+ List<Step> steps = scenario.getStep();
+ List<ClientEvent> events = new ArrayList<>(steps.size());
+ for (Step step : steps) {
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));
+ events.add(new SleepEvent(1000));
break;
case SEND_EVENT:
- events.put(counter++, new SendEvent(ByteBufUtils.serializeList(step.getBytes())));
+ events.add(new SendEvent(ByteBufUtils.serializeList(step.getBytes())));
break;
case WAIT_FOR_MESSAGE_EVENT:
- events.put(counter++, new WaitForMessageEvent(ByteBufUtils.serializeList(step.getBytes())));
+ events.add(new WaitForMessageEvent(ByteBufUtils.serializeList(step.getBytes())));
break;
default:
break;