Search in sources :

Example 1 with TransactionId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId in project openflowplugin by opendaylight.

the class FlowForwarderTest method removeTest.

@Test
public void removeTest() throws Exception {
    Mockito.when(salFlowService.removeFlow(removeFlowInputCpt.capture())).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().setTransactionId(new TransactionId(BigInteger.ONE)).build()).buildFuture());
    final Flow removeFlow = new FlowBuilder(flow).build();
    final Future<RpcResult<RemoveFlowOutput>> removeResult = flowForwarder.remove(flowPath, removeFlow, flowCapableNodePath);
    Mockito.verify(salFlowService).removeFlow(Matchers.<RemoveFlowInput>any());
    final RemoveFlowInput flowInput = removeFlowInputCpt.getValue();
    Assert.assertEquals(2, flowInput.getTableId().shortValue());
    Assert.assertEquals(emptyMatch, flowInput.getMatch());
    Assert.assertEquals(null, flowInput.getInstructions());
    Assert.assertEquals(true, flowInput.isStrict());
    final RpcResult<RemoveFlowOutput> removeFlowOutputRpcResult = removeResult.get(2, TimeUnit.SECONDS);
    Assert.assertTrue(removeFlowOutputRpcResult.isSuccessful());
    final RemoveFlowOutput resultValue = removeFlowOutputRpcResult.getResult();
    Assert.assertEquals(1, resultValue.getTransactionId().getValue().intValue());
}
Also used : FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) RemoveFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput) RemoveFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder) RemoveFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TransactionId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) UpdatedFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow) OriginalFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow) Test(org.junit.Test)

Example 2 with TransactionId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId in project openflowplugin by opendaylight.

the class GroupForwarderTest method setUp.

@Before
public void setUp() throws Exception {
    groupForwarder = new GroupForwarder(salGroupService);
    txId = new TransactionId(BigInteger.ONE);
}
Also used : TransactionId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId) Before(org.junit.Before)

Example 3 with TransactionId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId in project openflowplugin by opendaylight.

the class TableForwarderTest method setUp.

@Before
public void setUp() throws Exception {
    tableForwarder = new TableForwarder(salTableService);
    txId = new TransactionId(BigInteger.ONE);
}
Also used : TransactionId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId) Before(org.junit.Before)

Example 4 with TransactionId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId in project openflowplugin by opendaylight.

the class QueueStatisticsToNotificationTransformer method transformToNotification.

/**
 * Transform statistics to notification.
 *
 * @param mpReplyList   raw multipart response from device
 * @param deviceInfo    device state
 * @param ofVersion     device version
 * @param emulatedTxId  emulated transaction Id
 * @return notification containing flow stats
 */
public static QueueStatisticsUpdate transformToNotification(final List<MultipartReply> mpReplyList, final DeviceInfo deviceInfo, final OpenflowVersion ofVersion, final TransactionId emulatedTxId) {
    QueueStatisticsUpdateBuilder notification = new QueueStatisticsUpdateBuilder();
    notification.setId(deviceInfo.getNodeId());
    notification.setMoreReplies(Boolean.FALSE);
    notification.setTransactionId(emulatedTxId);
    notification.setQueueIdAndStatisticsMap(new ArrayList<>());
    for (MultipartReply mpReply : mpReplyList) {
        MultipartReplyQueueCase caseBody = (MultipartReplyQueueCase) mpReply.getMultipartReplyBody();
        MultipartReplyQueue replyBody = caseBody.getMultipartReplyQueue();
        for (QueueStats queueStats : replyBody.getQueueStats()) {
            QueueIdAndStatisticsMapBuilder statsBuilder = new QueueIdAndStatisticsMapBuilder();
            statsBuilder.setNodeConnectorId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(deviceInfo.getDatapathId(), queueStats.getPortNo(), ofVersion));
            statsBuilder.setTransmissionErrors(new Counter64(queueStats.getTxErrors()));
            statsBuilder.setTransmittedBytes(new Counter64(queueStats.getTxBytes()));
            statsBuilder.setTransmittedPackets(new Counter64(queueStats.getTxPackets()));
            DurationBuilder durationBuilder = new DurationBuilder();
            durationBuilder.setSecond(new Counter32(queueStats.getDurationSec()));
            durationBuilder.setNanosecond(new Counter32(queueStats.getDurationNsec()));
            statsBuilder.setDuration(durationBuilder.build());
            statsBuilder.setQueueId(new QueueId(queueStats.getQueueId()));
            notification.getQueueIdAndStatisticsMap().add(statsBuilder.build());
        }
    }
    return notification.build();
}
Also used : Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) QueueIdAndStatisticsMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder) MultipartReplyQueueCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId) QueueStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats) MultipartReplyQueue(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue) QueueStatisticsUpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdateBuilder) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)

Example 5 with TransactionId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId in project openflowplugin by opendaylight.

the class AllMeterConfigStatsService method transformToNotification.

@Override
public MeterConfigStatsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
    MeterConfigStatsUpdatedBuilder message = new MeterConfigStatsUpdatedBuilder();
    message.setId(getDeviceInfo().getNodeId());
    message.setMoreReplies(Boolean.FALSE);
    message.setTransactionId(emulatedTxId);
    message.setMeterConfigStats(new ArrayList<>());
    for (MultipartReply mpReply : result) {
        MultipartReplyMeterConfigCase caseBody = (MultipartReplyMeterConfigCase) mpReply.getMultipartReplyBody();
        MultipartReplyMeterConfig replyBody = caseBody.getMultipartReplyMeterConfig();
        final Optional<List<MeterConfigStats>> meterConfigStatsList = convertorExecutor.convert(replyBody.getMeterConfig(), data);
        meterConfigStatsList.ifPresent(meterConfigStats -> message.getMeterConfigStats().addAll(meterConfigStats));
    }
    return message.build();
}
Also used : MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) MeterConfigStatsUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdatedBuilder) ArrayList(java.util.ArrayList) List(java.util.List) MultipartReplyMeterConfigCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase) MultipartReplyMeterConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig)

Aggregations

MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)11 TransactionId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId)9 ArrayList (java.util.ArrayList)7 List (java.util.List)7 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)5 Before (org.junit.Before)3 Test (org.junit.Test)3 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)3 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)3 Counter64 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64)2 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)2 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)2 OriginalFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow)2 UpdatedFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Collection (java.util.Collection)1 Nonnull (javax.annotation.Nonnull)1 TranslatorKey (org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey)1 ServiceException (org.opendaylight.openflowplugin.impl.services.util.ServiceException)1 FlowStatsResponseConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.FlowStatsResponseConvertorData)1