Search in sources :

Example 96 with RpcResult

use of org.opendaylight.yangtools.yang.common.RpcResult in project openflowplugin by opendaylight.

the class OpendaylightMeterStatisticsServiceImplTest method testGetAllMeterStatistics.

@Test
public void testGetAllMeterStatistics() throws Exception {
    GetAllMeterStatisticsInputBuilder input = new GetAllMeterStatisticsInputBuilder().setNode(createNodeRef("unitProt:123"));
    rpcResult = buildMeterStatisticsReply();
    final Future<RpcResult<GetAllMeterStatisticsOutput>> resultFuture = meterStatisticsService.getAllMeterStatistics(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetAllMeterStatisticsOutput> rpcResult = resultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPMETER, requestInput.getValue().getType());
}
Also used : GetAllMeterStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInputBuilder) GetAllMeterStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Test(org.junit.Test)

Example 97 with RpcResult

use of org.opendaylight.yangtools.yang.common.RpcResult 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 98 with RpcResult

use of org.opendaylight.yangtools.yang.common.RpcResult in project openflowplugin by opendaylight.

the class OpendaylightQueueStatisticsServiceImplTest method testGetAllQueuesStatisticsFromAllPorts.

@Test
public void testGetAllQueuesStatisticsFromAllPorts() throws Exception {
    Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider).commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
    GetAllQueuesStatisticsFromAllPortsInputBuilder input = new GetAllQueuesStatisticsFromAllPortsInputBuilder().setNode(createNodeRef("unitProt:123"));
    rpcResult = buildQueueStatsReply();
    final Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> resultFuture = queueStatisticsService.getAllQueuesStatisticsFromAllPorts(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetAllQueuesStatisticsFromAllPortsOutput> rpcResult = resultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPQUEUE, requestInput.getValue().getType());
}
Also used : GetAllQueuesStatisticsFromAllPortsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInputBuilder) GetAllQueuesStatisticsFromAllPortsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) FutureCallback(com.google.common.util.concurrent.FutureCallback) Test(org.junit.Test)

Example 99 with RpcResult

use of org.opendaylight.yangtools.yang.common.RpcResult 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 100 with RpcResult

use of org.opendaylight.yangtools.yang.common.RpcResult in project openflowplugin by opendaylight.

the class GroupForwarder method update.

@Override
public void update(final InstanceIdentifier<Group> identifier, final Group original, final Group update, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
    final Group originalGroup = original;
    final Group updatedGroup = update;
    final UpdateGroupInputBuilder builder = new UpdateGroupInputBuilder();
    builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
    builder.setGroupRef(new GroupRef(identifier));
    builder.setTransactionUri(new Uri(provider.getNewTransactionId()));
    builder.setUpdatedGroup(new UpdatedGroupBuilder(updatedGroup).build());
    builder.setOriginalGroup(new OriginalGroupBuilder(originalGroup).build());
    final Future<RpcResult<UpdateGroupOutput>> resultFuture = this.provider.getSalGroupService().updateGroup(builder.build());
    JdkFutures.addErrorLogging(resultFuture, LOG, "updateGroup");
}
Also used : StaleGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) OriginalGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroupBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdateGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder) GroupRef(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupRef) UpdatedGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)

Aggregations

RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)360 Test (org.junit.Test)120 ExecutionException (java.util.concurrent.ExecutionException)118 ArrayList (java.util.ArrayList)61 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)37 InOrder (org.mockito.InOrder)30 List (java.util.List)29 BigInteger (java.math.BigInteger)26 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)25 FutureCallback (com.google.common.util.concurrent.FutureCallback)24 AllocateIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput)24 AllocateIdOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)24 RpcError (org.opendaylight.yangtools.yang.common.RpcError)24 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)23 AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)23 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)22 Future (java.util.concurrent.Future)21 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)21 Logger (org.slf4j.Logger)21 LoggerFactory (org.slf4j.LoggerFactory)21