Search in sources :

Example 16 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project openflowplugin by opendaylight.

the class OpendaylightMeterStatisticsServiceImplTest method testGetMeterFeatures.

@Test
public void testGetMeterFeatures() throws Exception {
    GetMeterFeaturesInputBuilder input = new GetMeterFeaturesInputBuilder().setNode(createNodeRef("unitProt:123"));
    rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setMultipartReplyBody(new MultipartReplyMeterFeaturesCaseBuilder().setMultipartReplyMeterFeatures(new MultipartReplyMeterFeaturesBuilder().setBandTypes(new MeterBandTypeBitmap(true, false)).setCapabilities(new MeterFlags(true, false, false, false)).setMaxBands((short) 71).setMaxColor((short) 72).setMaxMeter(73L).build()).build()).build())).build();
    final Future<RpcResult<GetMeterFeaturesOutput>> resultFuture = meterStatisticsService.getMeterFeatures(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetMeterFeaturesOutput> rpcResult = resultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPMETERFEATURES, requestInput.getValue().getType());
}
Also used : MultipartReplyMeterFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCaseBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartReplyMeterFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeaturesBuilder) GetMeterFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutput) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MeterBandTypeBitmap(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap) GetMeterFeaturesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInputBuilder) Test(org.junit.Test)

Example 17 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project openflowplugin by opendaylight.

the class AbstractCompatibleStatServiceTest method setUp.

@Override
public void setUp() {
    rqContext = new AbstractRequestContext<Object>(42L) {

        @Override
        public void close() {
        // NOOP
        }
    };
    final Answer closeRequestFutureAnswer = invocation -> {
        rqContext.setResult(rpcResult);
        rqContext.close();
        return null;
    };
    Mockito.when(featuresOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
    Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
    Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
    Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
    Mockito.when(deviceInfo.getNodeId()).thenReturn(NODE_ID);
    Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
    Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(null);
    Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(Matchers.any(EventIdentifier.class));
    Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider).commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
    Mockito.when(translatorLibrary.lookupTranslator(Matchers.any(TranslatorKey.class))).thenReturn(translator);
    service = AggregateFlowsInTableService.createWithOook(rqContextStack, deviceContext, new AtomicLong(20L));
}
Also used : MultipartReplyAggregateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput) Matchers(org.mockito.Matchers) Mock(org.mockito.Mock) NotificationPublishService(org.opendaylight.controller.md.sal.binding.api.NotificationPublishService) DeviceState(org.opendaylight.openflowplugin.api.openflow.device.DeviceState) Captor(org.mockito.Captor) GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput) Answer(org.mockito.stubbing.Answer) ArgumentCaptor(org.mockito.ArgumentCaptor) GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) MultipartReplyAggregateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder) MessageTranslator(org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator) BigInteger(java.math.BigInteger) AggregateFlowsInTableService(org.opendaylight.openflowplugin.impl.statistics.services.AggregateFlowsInTableService) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) AbstractRequestContext(org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext) GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder) Test(org.junit.Test) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) FutureCallback(com.google.common.util.concurrent.FutureCallback) OFConstants(org.opendaylight.openflowplugin.api.OFConstants) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) AtomicLong(java.util.concurrent.atomic.AtomicLong) Mockito(org.mockito.Mockito) EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) TranslatorKey(org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey) AggregateFlowStatisticsUpdate(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate) TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) Assert(org.junit.Assert) Collections(java.util.Collections) AggregatedFlowStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics) AbstractStatsServiceTest(org.opendaylight.openflowplugin.impl.statistics.services.AbstractStatsServiceTest) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) AggregatedFlowStatisticsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder) Answer(org.mockito.stubbing.Answer) AtomicLong(java.util.concurrent.atomic.AtomicLong) EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier) TranslatorKey(org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey) FutureCallback(com.google.common.util.concurrent.FutureCallback)

Example 18 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project openflowplugin by opendaylight.

the class FlowForwarder method update.

@Override
public void update(final InstanceIdentifier<Flow> identifier, final Flow original, final Flow update, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
    final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class);
    if (tableIdValidationPrecondition(tableKey, update)) {
        final UpdateFlowInputBuilder builder = new UpdateFlowInputBuilder();
        builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
        builder.setFlowRef(new FlowRef(identifier));
        builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
        // This method is called only when a given flow object in datastore
        // has been updated. So FRM always needs to set strict flag into
        // update-flow input so that only a flow entry associated with
        // a given flow object is updated.
        builder.setUpdatedFlow(new UpdatedFlowBuilder(update).setStrict(Boolean.TRUE).build());
        builder.setOriginalFlow(new OriginalFlowBuilder(original).setStrict(Boolean.TRUE).build());
        final Future<RpcResult<UpdateFlowOutput>> resultFuture = provider.getSalFlowService().updateFlow(builder.build());
        JdkFutures.addErrorLogging(resultFuture, LOG, "updateFlow");
    }
}
Also used : UpdateFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) FlowRef(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) OriginalFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder) UpdatedFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder)

Example 19 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project openflowplugin by opendaylight.

the class FlowForwarder method removeWithResult.

// TODO: Pull this into ForwardingRulesCommiter and override it here
@Override
public Future<RpcResult<RemoveFlowOutput>> removeWithResult(final InstanceIdentifier<Flow> identifier, final Flow removeDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
    Future<RpcResult<RemoveFlowOutput>> resultFuture = SettableFuture.create();
    final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class);
    if (tableIdValidationPrecondition(tableKey, removeDataObj)) {
        final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(removeDataObj);
        builder.setFlowRef(new FlowRef(identifier));
        builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
        builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey)));
        // This method is called only when a given flow object has been
        // removed from datastore. So FRM always needs to set strict flag
        // into remove-flow input so that only a flow entry associated with
        // a given flow object is removed.
        builder.setTransactionUri(new Uri(provider.getNewTransactionId())).setStrict(Boolean.TRUE);
        resultFuture = provider.getSalFlowService().removeFlow(builder.build());
    }
    return resultFuture;
}
Also used : NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) FlowTableRef(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef) FlowRef(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RemoveFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)

Example 20 with Object

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project openflowplugin by opendaylight.

the class OpendaylightFlowStatisticsServiceDelegateImplTest method testGetAggregateFlowStatisticsFromFlowTableForAllFlows.

@Test
public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws Exception {
    GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder().setNode(createNodeRef("unitProt:123")).setTableId(new TableId((short) 1));
    Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceInfo), Matchers.any())).thenReturn(new AggregatedFlowStatisticsBuilder().setByteCount(new Counter64(BigInteger.valueOf(50L))).setPacketCount(new Counter64(BigInteger.valueOf(51L))).setFlowCount(new Counter32(52L)).build());
    rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setType(MultipartType.OFPMPAGGREGATE).setVersion(OFConstants.OFP_VERSION_1_3).setFlags(new MultipartRequestFlags(false)).setMultipartReplyBody(new MultipartReplyAggregateCaseBuilder().setMultipartReplyAggregate(new MultipartReplyAggregateBuilder().setByteCount(BigInteger.valueOf(50L)).setPacketCount(BigInteger.valueOf(51L)).setFlowCount(52L).build()).build()).build())).build();
    final Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> resultFuture = flowStatisticsServiceDelegate.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> rpcResultCompatible = resultFuture.get();
    Assert.assertTrue(rpcResultCompatible.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType());
    Mockito.verify(notificationPublishService, Mockito.timeout(NOTIFICATION_WAIT_TIMEOUT_MS)).offerNotification(Matchers.any(Notification.class));
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) AggregatedFlowStatisticsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder) Notification(org.opendaylight.yangtools.yang.binding.Notification) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) MultipartReplyAggregateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput) MultipartReplyAggregateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder) AbstractSingleStatsServiceTest(org.opendaylight.openflowplugin.impl.statistics.services.AbstractSingleStatsServiceTest) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)94 ByteBuf (io.netty.buffer.ByteBuf)82 Test (org.junit.Test)62 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)34 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)33 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)33 ExecutionException (java.util.concurrent.ExecutionException)30 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)29 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)25 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)25 List (java.util.List)21 HashMap (java.util.HashMap)19 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)18 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)17 Nullable (org.eclipse.jdt.annotation.Nullable)16 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)16 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)15 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)15 FutureCallback (com.google.common.util.concurrent.FutureCallback)14 BigInteger (java.math.BigInteger)14