Search in sources :

Example 21 with NodeBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder 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 22 with NodeBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder in project openflowplugin by opendaylight.

the class OpenflowpluginTestCommandProvider method _modifyMDFlow.

public void _modifyMDFlow(final CommandInterpreter ci) {
    final NodeBuilder tn = createTestNode(ci.nextArgument());
    final FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
    tf.setFlowName(UPDATED_FLOW_NAME);
    writeFlow(ci, tf, tn);
    tf.setFlowName(ORIGINAL_FLOW_NAME);
    writeFlow(ci, tf, tn);
}
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 NodeBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder in project openflowplugin by opendaylight.

the class OpenflowPluginBulkGroupTransactionProvider method createTestFlow.

private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
    FlowBuilder flow = new FlowBuilder();
    long id = 123;
    String flowType = flowTypeArg;
    if (flowType == null) {
        flowType = "f1";
    }
    switch(flowType) {
        case "f1":
            id += 1;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createDecNwTtlInstructions().build());
            break;
        case "f2":
            id += 2;
            flow.setMatch(createMatch2().build());
            flow.setInstructions(createDropInstructions().build());
            break;
        case "f3":
            id += 3;
            flow.setMatch(createMatch3().build());
            flow.setInstructions(createDropInstructions().build());
            break;
        case "f4":
            id += 4;
            flow.setMatch(createEthernetMatch().build());
            flow.setInstructions(createDropInstructions().build());
            break;
        case "f82":
            id += 1;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createDropInstructions().build());
            break;
        case "f5":
            id += 5;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction().build());
            break;
        case "f6":
            id += 6;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createGotoTableInstructions().build());
            break;
        case "f7":
            id += 7;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createMeterInstructions().build());
            break;
        case "f8":
            id += 8;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction7().build());
            break;
        case "f9":
            id += 9;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction2().build());
            break;
        case "f10":
            id += 10;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction3().build());
            break;
        case "f14":
            id += 14;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction7().build());
            break;
        case "f29":
            id += 29;
            flow.setMatch(createMatch1().build());
            flow.setInstructions(createAppyActionInstruction21().build());
            break;
        default:
            LOG.warn("flow type not understood: {}", flowType);
    }
    final FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
    if (null == flow.isBarrier()) {
        flow.setBarrier(Boolean.FALSE);
    }
    // flow.setBufferId(12L);
    BigInteger value = BigInteger.valueOf(10);
    BigInteger outputPort = BigInteger.valueOf(4294967295L);
    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.setOutGroup(4294967295L);
    // set outport to OFPP_NONE (65535) to disable remove restriction for
    // flow
    flow.setOutPort(outputPort);
    flow.setKey(key);
    flow.setPriority(2);
    flow.setFlowName(originalFlowName + "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 24 with NodeBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder in project openflowplugin by opendaylight.

the class OpenflowPluginBulkGroupTransactionProvider method createUserNode.

private void createUserNode(String nodeRef) {
    NodeBuilder builder = new NodeBuilder();
    builder.setId(new NodeId(nodeRef));
    builder.setKey(new NodeKey(builder.getId()));
    testNode12 = builder.build();
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 25 with NodeBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder in project openflowplugin by opendaylight.

the class OpenflowPluginBulkGroupTransactionProvider method createTestNode.

private NodeBuilder createTestNode(String nodeId) {
    if (nodeId == null) {
        nodeId = OpenflowpluginTestActivator.NODE_ID;
    }
    NodeBuilder builder = new NodeBuilder();
    builder.setId(new NodeId(nodeId));
    builder.setKey(new NodeKey(builder.getId()));
    return builder;
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Aggregations

NodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)35 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)30 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)21 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)21 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)18 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)17 Test (org.junit.Test)11 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)11 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)11 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)11 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)11 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)11 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)10 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)8 ArrayList (java.util.ArrayList)7 Optional (com.google.common.base.Optional)6 BigInteger (java.math.BigInteger)6 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)6 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)6 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)5