Search in sources :

Example 21 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.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();
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) EthernetTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder) BigInteger(java.math.BigInteger) EtherType(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)

Example 22 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.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;
        }
    }
}
Also used : FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)

Example 23 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.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());
    }
}
Also used : FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) ExecutorService(java.util.concurrent.ExecutorService) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)

Example 24 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.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;
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags) BigInteger(java.math.BigInteger)

Example 25 with TableId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.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());
}
Also used : NextTableIdsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder) NextTableIds(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds) ArrayList(java.util.ArrayList) NextTableRelatedTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder)

Aggregations

BigInteger (java.math.BigInteger)38 Test (org.junit.Test)32 ArrayList (java.util.ArrayList)26 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)17 ByteBuf (io.netty.buffer.ByteBuf)16 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)16 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)15 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)15 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId)14 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId)14 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)13 FlowCookie (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie)12 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)12 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)9 FlowModFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags)7 Optional (com.google.common.base.Optional)6 ExecutionException (java.util.concurrent.ExecutionException)5 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)5 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)5 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)5