use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project openflowplugin by opendaylight.
the class Activator method createFlow.
private static Flow createFlow(String flowId, long groupId, int priority, short tableId) {
MatchBuilder matchBuilder = new MatchBuilder();
matchBuilder.setEthernetMatch(new EthernetMatchBuilder().setEthernetType(new EthernetTypeBuilder().setType(new EtherType(2048L)).build()).build());
FlowBuilder flowBuilder = new FlowBuilder();
flowBuilder.setMatch(matchBuilder.build());
flowBuilder.setInstructions(createGroupInstructions(groupId).build());
flowBuilder.setPriority(priority);
flowBuilder.setCookie(new FlowCookie(new BigInteger(flowId + "" + priority)));
FlowKey key = new FlowKey(new FlowId(flowId));
flowBuilder.setHardTimeout(0);
flowBuilder.setIdleTimeout(0);
flowBuilder.setStrict(false);
flowBuilder.setContainerName(null);
flowBuilder.setId(new FlowId(flowId));
flowBuilder.setTableId(tableId);
flowBuilder.setKey(key);
flowBuilder.setFlowName("FlowWithGroupInstruction");
return flowBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method _testAllFlows.
/*
* usage testAllFlows <dp>
* ex: _perfFlowTest 1
*/
@SuppressWarnings("checkstyle:IllegalCatch")
public void _testAllFlows(final CommandInterpreter ci) {
String dataPathID = ci.nextArgument();
final int numberOfFlows = 82;
if (dataPathID == null || dataPathID.trim().equals("")) {
dataPathID = "1";
}
ci.println("* Test All Flows *");
ci.println("* dataPathID:::" + dataPathID + "");
final String dataPath = "openflow:" + dataPathID;
final String tableId = "0";
final NodeBuilder tn = createTestNode(dataPath);
FlowBuilder tf;
for (int flow = 1; flow < numberOfFlows; flow++) {
final String flowID = "f" + flow;
try {
tf = createTestFlow(tn, flowID, tableId);
writeFlow(ci, tf, tn);
} catch (RuntimeException e) {
ci.println("--Test Failed--Issue found while adding flow" + flow);
break;
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method _perfFlowTest.
/*
* usage testSwitchFlows <numberOfSwitches> <numberOfFlows> <warmup iterations> <Number Of Threads>
* ex: _perfFlowTest 10 5 1 2
*/
public void _perfFlowTest(final CommandInterpreter ci) {
final String numberOfSwtichesStr = ci.nextArgument();
final String numberOfFlowsStr = ci.nextArgument();
final String warmupIterationsStr = ci.nextArgument();
final String threadCountStr = ci.nextArgument();
final String warmUpStr = ci.nextArgument();
int numberOfSwtiches = 0;
int numberOfFlows = 0;
int warmupIterations = 0;
boolean warmUpIterations = false;
int threadCount = 0;
if (numberOfSwtichesStr != null && !numberOfSwtichesStr.trim().equals("")) {
numberOfSwtiches = Integer.parseInt(numberOfSwtichesStr);
} else {
numberOfSwtiches = 2;
}
if (numberOfFlowsStr != null && !numberOfFlowsStr.trim().equals("")) {
numberOfFlows = Integer.parseInt(numberOfFlowsStr);
} else {
numberOfFlows = 2;
}
if (warmupIterationsStr != null && !warmupIterationsStr.trim().equals("")) {
warmupIterations = Integer.parseInt(warmupIterationsStr);
} else {
warmupIterations = 2;
}
if (threadCountStr != null && !threadCountStr.trim().equals("")) {
threadCount = Integer.parseInt(threadCountStr);
} else {
threadCount = 2;
}
if (warmUpStr != null && !warmUpStr.trim().equals("") && warmUpStr.trim().equals("true")) {
warmUpIterations = true;
} else {
warmUpIterations = false;
}
ci.println("* Test Configurations*");
ci.println("* numberOfSwtiches:::" + numberOfSwtiches + "");
ci.println("* numberOfFlows:::" + numberOfFlows + "");
ci.println("* warmupIterations:::" + warmupIterations + "");
ci.println("* Number of Threads :::" + threadCount + "");
ci.println("* Warmup Required? :::" + warmUpIterations + "");
String dataPath = "openflow:1";
NodeBuilder tn;
FlowBuilder tf;
final String tableId = "0";
if (warmUpIterations) {
ci.println("----Warmup Started-----");
for (int j = 1; j <= warmupIterations; j++) {
for (int i = 1; i <= numberOfSwtiches; i++) {
dataPath = "openflow:" + i;
tn = createTestNode(dataPath);
for (int flow = 1; flow < numberOfFlows; flow++) {
tf = createTestFlowPerfTest("f1", tableId, flow);
writeFlow(ci, tf, tn);
}
}
}
ci.println("----Warmup Done-----");
}
try {
final ExecutorService executor = Executors.newFixedThreadPool(threadCount);
int tableID = 0;
for (int t = 0; t < threadCount; t++) {
tableID = t + 1;
final Runnable tRunnable = new TestFlowThread(numberOfSwtiches, numberOfFlows, ci, t, tableID);
executor.execute(tRunnable);
}
executor.shutdown();
executor.awaitTermination(1, TimeUnit.SECONDS);
} catch (InterruptedException e) {
ci.println("Exception:" + e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createTestFlowPerfTest.
private FlowBuilder createTestFlowPerfTest(final String flowTypeArg, final String tableId, final int id) {
final FlowBuilder flow = new FlowBuilder();
String flowType = flowTypeArg;
int flowId = id;
if (flowType == null) {
flowType = "f1";
}
flow.setPriority(flowId);
switch(flowType) {
case "f1":
flowId += 1;
flow.setMatch(createMatch1().build());
flow.setInstructions(createDecNwTtlInstructions().build());
break;
default:
LOG.warn("flow type not understood: {}", flowType);
}
final FlowKey key = new FlowKey(new FlowId(Long.toString(flowId)));
if (null == flow.isBarrier()) {
flow.setBarrier(Boolean.FALSE);
}
final BigInteger value = BigInteger.valueOf(10);
flow.setCookie(new FlowCookie(value));
flow.setCookieMask(new FlowCookie(value));
flow.setHardTimeout(0);
flow.setIdleTimeout(0);
flow.setInstallHw(false);
flow.setStrict(false);
flow.setContainerName(null);
flow.setFlags(new FlowModFlags(false, false, false, false, true));
flow.setId(new FlowId("12"));
flow.setTableId(getTableId(tableId));
flow.setKey(key);
flow.setFlowName(ORIGINAL_FLOW_NAME + "X" + flowType);
return flow;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId in project openflowplugin by opendaylight.
the class TableFeaturesConvertor method setNextTableFeatureProperty.
private static void setNextTableFeatureProperty(final TableFeaturePropertiesBuilder builder, final TableFeaturesPropType type, final List<Short> tableIds) {
List<NextTableIds> nextTableIdsList = new ArrayList<>();
for (Short tableId : tableIds) {
NextTableIdsBuilder nextTableId = new NextTableIdsBuilder();
nextTableId.setTableId(tableId);
nextTableIdsList.add(nextTableId.build());
}
NextTableRelatedTableFeaturePropertyBuilder propBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
propBuilder.setNextTableIds(nextTableIdsList);
builder.setType(type);
builder.addAugmentation(NextTableRelatedTableFeatureProperty.class, propBuilder.build());
}
Aggregations