Search in sources :

Example 81 with FlowId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId in project openflowplugin by opendaylight.

the class FlowDirectStatisticsServiceTest method setUp.

@Override
public void setUp() throws Exception {
    service = new FlowDirectStatisticsService(requestContextStack, deviceContext, convertorManager, multipartWriterProvider);
    final DeviceFlowRegistry registry = mock(DeviceFlowRegistry.class);
    when(registry.retrieveDescriptor(any())).thenReturn(FlowDescriptorFactory.create(TABLE_NO, new FlowId("1")));
    when(deviceContext.getDeviceFlowRegistry()).thenReturn(registry);
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) DeviceFlowRegistry(org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry)

Example 82 with FlowId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId in project openflowplugin by opendaylight.

the class DeviceFlowRegistryImplTest method testStoreIfNecessary.

@Test
public void testStoreIfNecessary() throws Exception {
    FlowId newFlowId;
    // store existing key
    deviceFlowRegistry.store(key);
    newFlowId = deviceFlowRegistry.retrieveDescriptor(key).getFlowId();
    Assert.assertEquals(1, deviceFlowRegistry.getAllFlowDescriptors().size());
    Assert.assertEquals(descriptor, deviceFlowRegistry.retrieveDescriptor(key));
    Assert.assertEquals(descriptor.getFlowId(), newFlowId);
    // store new key
    final String alienPrefix = "#UF$TABLE*2-";
    final FlowRegistryKey key2 = FlowRegistryKeyFactory.create(OFConstants.OFP_VERSION_1_3, TestFlowHelper.createFlowAndStatisticsMapListBuilder(2).build());
    deviceFlowRegistry.store(key2);
    newFlowId = deviceFlowRegistry.retrieveDescriptor(key2).getFlowId();
    Assert.assertTrue(newFlowId.getValue().startsWith(alienPrefix));
    Assert.assertTrue(deviceFlowRegistry.retrieveDescriptor(key2).getFlowId().getValue().startsWith(alienPrefix));
    Assert.assertEquals(2, deviceFlowRegistry.getAllFlowDescriptors().size());
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowRegistryKey(org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey) Test(org.junit.Test)

Example 83 with FlowId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId in project openflowplugin by opendaylight.

the class StatisticsGatheringUtilsTest method testGatherStatistics_flow.

@Test
public void testGatherStatistics_flow() throws Exception {
    final short tableId = 0;
    final MultipartType type = MultipartType.OFPMPFLOW;
    final InstanceIdentifier<FlowCapableNode> nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
    final TableBuilder tableDataBld = new TableBuilder();
    tableDataBld.setId(tableId);
    final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
    flowNodeBuilder.setTable(Collections.singletonList(tableDataBld.build()));
    final Optional<FlowCapableNode> flowNodeOpt = Optional.of(flowNodeBuilder.build());
    final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> flowNodeFuture = Futures.immediateCheckedFuture(flowNodeOpt);
    when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodePath)).thenReturn(flowNodeFuture);
    when(flowDescriptor.getFlowId()).thenReturn(flowId);
    final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder matchBld = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder().setMatchEntry(Collections.<MatchEntry>emptyList());
    final FlowStatsBuilder flowStatsBld = new FlowStatsBuilder().setByteCount(BigInteger.valueOf(55L)).setPacketCount(BigInteger.valueOf(56L)).setDurationSec(57L).setDurationNsec(58L).setTableId((short) 0).setMatch(matchBld.build()).setFlags(new FlowModFlags(true, false, false, false, true));
    final MultipartReplyFlowBuilder mpReplyFlowBld = new MultipartReplyFlowBuilder();
    mpReplyFlowBld.setFlowStats(Lists.newArrayList(flowStatsBld.build()));
    final MultipartReplyFlowCaseBuilder mpReplyFlowCaseBld = new MultipartReplyFlowCaseBuilder();
    mpReplyFlowCaseBld.setMultipartReplyFlow(mpReplyFlowBld.build());
    final MultipartReply flowStatsUpdated = assembleMPReplyMessage(type, mpReplyFlowCaseBld.build());
    final List<MultipartReply> statsData = Collections.singletonList(flowStatsUpdated);
    fireAndCheck(type, statsData);
    final FlowBuilder flowBld = new FlowBuilder().setTableId((short) 0).setMatch(new MatchBuilder().build());
    final KeyedInstanceIdentifier<Table, TableKey> tablePath = dummyNodePath.augmentation(FlowCapableNode.class).child(Table.class, new TableKey((short) 0));
    final KeyedInstanceIdentifier<Flow, FlowKey> flowPath = tablePath.child(Flow.class, new FlowKey(flowId));
    verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>>any());
    final InOrder inOrder = Mockito.inOrder(deviceContext);
    inOrder.verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.any(), Matchers.any());
}
Also used : MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) MultipartReplyTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTableBuilder) TableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder) MultipartReplyFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder) FlowStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder) MultipartReplyFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) InOrder(org.mockito.InOrder) Optional(com.google.common.base.Optional) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags) MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) MultipartReplyFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Test(org.junit.Test)

Example 84 with FlowId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId in project openflowplugin by opendaylight.

the class FlowDirectStatisticsServiceTest method setUp.

@Override
public void setUp() throws Exception {
    service = new FlowDirectStatisticsService(requestContextStack, deviceContext, convertorManager, multipartWriterProvider);
    final DeviceFlowRegistry registry = mock(DeviceFlowRegistry.class);
    when(registry.retrieveDescriptor(any())).thenReturn(FlowDescriptorFactory.create(TABLE_NO, new FlowId("1")));
    when(deviceContext.getDeviceFlowRegistry()).thenReturn(registry);
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) DeviceFlowRegistry(org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry)

Example 85 with FlowId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId in project openflowplugin by opendaylight.

the class FlatBatchUtilTest method testMergeJobsResultsFutures.

@Test
public void testMergeJobsResultsFutures() throws Exception {
    final BatchFailure batchFailure = new BatchFailureBuilder().setBatchOrder(9).setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder().setFlowId(new FlowId("11")).build()).build();
    final ProcessFlatBatchOutput output = new ProcessFlatBatchOutputBuilder().setBatchFailure(Lists.newArrayList(batchFailure)).build();
    final RpcResult<ProcessFlatBatchOutput> rpcResultFailed = RpcResultBuilder.<ProcessFlatBatchOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ut-rpcError").withResult(output).build();
    final RpcResult<ProcessFlatBatchOutput> rpcResultSuccess = RpcResultBuilder.<ProcessFlatBatchOutput>success().withResult(new ProcessFlatBatchOutputBuilder().setBatchFailure(new ArrayList<>())).build();
    final RpcResult<ProcessFlatBatchOutput> rpcResult1 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultFailed, rpcResultSuccess));
    Assert.assertEquals(1, rpcResult1.getErrors().size());
    Assert.assertFalse(rpcResult1.isSuccessful());
    final RpcResult<ProcessFlatBatchOutput> rpcResult2 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultFailed, rpcResultFailed));
    Assert.assertEquals(2, rpcResult2.getErrors().size());
    Assert.assertFalse(rpcResult2.isSuccessful());
    final RpcResult<ProcessFlatBatchOutput> rpcResult3 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultSuccess, rpcResultSuccess));
    Assert.assertEquals(0, rpcResult3.getErrors().size());
    Assert.assertTrue(rpcResult3.isSuccessful());
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) BatchFailure(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure) ProcessFlatBatchOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder) BatchFailureBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailureBuilder) FlatBatchFailureFlowIdCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.batch.failure.batch.item.id.choice.FlatBatchFailureFlowIdCaseBuilder) ProcessFlatBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput) Test(org.junit.Test)

Aggregations

FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)79 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)53 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)46 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)43 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)25 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)24 ArrayList (java.util.ArrayList)22 BigInteger (java.math.BigInteger)21 Test (org.junit.Test)21 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)21 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)19 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)15 FlowCookie (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie)13 FlowModFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags)10 List (java.util.List)9 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)9 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)8 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)8 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)8