Search in sources :

Example 21 with MultipartReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply in project openflowplugin by opendaylight.

the class StatisticsGatheringUtilsTest method testGatherStatistics_group.

@Test
public void testGatherStatistics_group() throws Exception {
    final MultipartType type = MultipartType.OFPMPGROUP;
    final long groupIdValue = 19L;
    final GroupStatsBuilder groupStatsBld = new GroupStatsBuilder().setBucketStats(Lists.newArrayList(createBucketStat(21L, 42L))).setByteCount(BigInteger.valueOf(84L)).setPacketCount(BigInteger.valueOf(63L)).setDurationSec(11L).setDurationNsec(12L).setRefCount(13L).setGroupId(new GroupId(groupIdValue));
    final MultipartReplyGroupBuilder mpReplyGroupBld = new MultipartReplyGroupBuilder();
    mpReplyGroupBld.setGroupStats(Lists.newArrayList(groupStatsBld.build()));
    final MultipartReplyGroupCaseBuilder mpReplyGroupCaseBld = new MultipartReplyGroupCaseBuilder();
    mpReplyGroupCaseBld.setMultipartReplyGroup(mpReplyGroupBld.build());
    final MultipartReply groupStatsUpdated = assembleMPReplyMessage(type, mpReplyGroupCaseBld.build());
    final List<MultipartReply> statsData = Collections.singletonList(groupStatsUpdated);
    fireAndCheck(type, statsData);
    final InstanceIdentifier<GroupStatistics> groupPath = dummyNodePath.augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId(groupIdValue))).augmentation(NodeGroupStatistics.class).child(GroupStatistics.class);
    verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(groupPath), Matchers.any(GroupStatistics.class));
}
Also used : MultipartReplyGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCaseBuilder) MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) MultipartReplyGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroupBuilder) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder) NodeGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) NodeGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics) GroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatistics) Test(org.junit.Test)

Example 22 with MultipartReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply in project openflowplugin by opendaylight.

the class StatisticsGatheringUtilsTest method testGatherStatistics_queue.

@Test
public void testGatherStatistics_queue() throws Exception {
    final MultipartType type = MultipartType.OFPMPQUEUE;
    final long queueIdValue = 4L;
    final QueueStatsBuilder queueStatsBld = new QueueStatsBuilder().setPortNo(11L).setTxBytes(BigInteger.valueOf(44L)).setTxErrors(BigInteger.valueOf(45L)).setTxPackets(BigInteger.valueOf(46L)).setDurationSec(47L).setDurationNsec(48L).setQueueId(queueIdValue);
    final MultipartReplyQueueBuilder mpReplyQueueBld = new MultipartReplyQueueBuilder();
    mpReplyQueueBld.setQueueStats(Lists.newArrayList(queueStatsBld.build()));
    final MultipartReplyQueueCaseBuilder mpReplyQueueCaseBld = new MultipartReplyQueueCaseBuilder();
    mpReplyQueueCaseBld.setMultipartReplyQueue(mpReplyQueueBld.build());
    final MultipartReply meterStatsUpdated = assembleMPReplyMessage(type, mpReplyQueueCaseBld.build());
    final List<MultipartReply> statsData = Collections.singletonList(meterStatsUpdated);
    fireAndCheck(type, statsData);
    final KeyedInstanceIdentifier<Queue, QueueKey> queuePath = dummyNodePath.child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("openflow:" + DUMMY_NODE_ID_VALUE + ":11"))).augmentation(FlowCapableNodeConnector.class).child(Queue.class, new QueueKey(new QueueId(queueIdValue)));
    verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(queuePath), Matchers.any(Queue.class));
}
Also used : MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId) MultipartReplyQueueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueueBuilder) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) MultipartReplyQueueCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCaseBuilder) QueueStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStatsBuilder) Queue(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey) QueueKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueKey) Test(org.junit.Test)

Example 23 with MultipartReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply in project openflowplugin by opendaylight.

the class MultipartReplyMessageDeserializer method deserialize.

@Override
public MultipartReply deserialize(ByteBuf message) {
    final long xid = message.readUnsignedInt();
    final int type = message.readUnsignedShort();
    final boolean reqMore = (message.readUnsignedShort() & 0x01) != 0;
    message.skipBytes(PADDING_IN_MULTIPART_REPLY_HEADER);
    final OFDeserializer<MultipartReplyBody> deserializer = Preconditions.checkNotNull(registry).getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, type, MultipartReplyBody.class));
    return new MultipartReplyBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(xid).setRequestMore(reqMore).setMultipartReplyBody(deserializer.deserialize(message)).build();
}
Also used : MultipartReplyBody(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody) MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) MultipartReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder)

Example 24 with MultipartReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply in project openflowplugin by opendaylight.

the class DeviceContextImplTest method testProcessReply2.

@Test
public void testProcessReply2() {
    final Xid dummyXid = new Xid(DUMMY_XID);
    final Error mockedError = mock(Error.class);
    deviceContext.processReply(dummyXid, Lists.newArrayList(mockedError));
    verify(messageSpy).spyMessage(any(Class.class), eq(MessageSpy.StatisticsGroup.FROM_SWITCH_PUBLISHED_FAILURE));
    final MultipartReply mockedMultipartReply = mock(MultipartReply.class);
    deviceContext.processReply(dummyXid, Lists.newArrayList(mockedMultipartReply));
    verify(messageSpy).spyMessage(any(Class.class), eq(MessageSpy.StatisticsGroup.FROM_SWITCH_PUBLISHED_SUCCESS));
}
Also used : Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) Error(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error) Test(org.junit.Test)

Example 25 with MultipartReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply in project openflowplugin by opendaylight.

the class DeviceContextImplTest method setUp.

@Before
public void setUp() throws Exception {
    final CheckedFuture<Optional<Node>, ReadFailedException> noExistNodeFuture = Futures.immediateCheckedFuture(Optional.<Node>absent());
    Mockito.when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodeKeyIdent)).thenReturn(noExistNodeFuture);
    Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(readTx);
    Mockito.when(dataBroker.createTransactionChain(Mockito.any(TransactionChainManager.class))).thenReturn(txChainFactory);
    Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent);
    Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId);
    Mockito.when(deviceInfo.getDatapathId()).thenReturn(BigInteger.ONE);
    final SettableFuture<RpcResult<GetAsyncReply>> settableFuture = SettableFuture.create();
    final SettableFuture<RpcResult<MultipartReply>> settableFutureMultiReply = SettableFuture.create();
    Mockito.when(requestContext.getFuture()).thenReturn(settableFuture);
    Mockito.doAnswer(invocation -> {
        settableFuture.set((RpcResult<GetAsyncReply>) invocation.getArguments()[0]);
        return null;
    }).when(requestContext).setResult(any(RpcResult.class));
    Mockito.when(requestContextMultiReply.getFuture()).thenReturn(settableFutureMultiReply);
    Mockito.doAnswer(invocation -> {
        settableFutureMultiReply.set((RpcResult<MultipartReply>) invocation.getArguments()[0]);
        return null;
    }).when(requestContextMultiReply).setResult(any(RpcResult.class));
    Mockito.when(txChainFactory.newReadWriteTransaction()).thenReturn(writeTx);
    Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(readTx);
    Mockito.when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider);
    Mockito.when(connectionContext.getConnectionAdapter()).thenReturn(connectionAdapter);
    Mockito.when(connectionContext.getDeviceInfo()).thenReturn(deviceInfo);
    final FeaturesReply mockedFeaturesReply = mock(FeaturesReply.class);
    when(connectionContext.getFeatures()).thenReturn(mockedFeaturesReply);
    when(connectionContext.getFeatures().getCapabilities()).thenReturn(mock(Capabilities.class));
    Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
    Mockito.when(featuresOutput.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
    Mockito.when(featuresOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
    Mockito.when(contextChainHolder.getContextChain(deviceInfo)).thenReturn(contextChain);
    Mockito.when(contextChain.isMastered(ContextChainMastershipState.CHECK, false)).thenReturn(true);
    final PacketReceived packetReceived = new PacketReceivedBuilder().setMatch(new org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder().setInPort(new NodeConnectorId("openflow:1:LOCAL")).build()).build();
    Mockito.when(messageTranslatorPacketReceived.translate(any(Object.class), any(DeviceInfo.class), any(Object.class))).thenReturn(packetReceived);
    Mockito.when(messageTranslatorFlowCapableNodeConnector.translate(any(Object.class), any(DeviceInfo.class), any(Object.class))).thenReturn(mock(FlowCapableNodeConnector.class));
    Mockito.when(translatorLibrary.lookupTranslator(eq(new TranslatorKey(OFConstants.OFP_VERSION_1_3, PacketIn.class.getName())))).thenReturn(messageTranslatorPacketReceived);
    Mockito.when(translatorLibrary.lookupTranslator(eq(new TranslatorKey(OFConstants.OFP_VERSION_1_3, PortGrouping.class.getName())))).thenReturn(messageTranslatorFlowCapableNodeConnector);
    Mockito.when(translatorLibrary.lookupTranslator(eq(new TranslatorKey(OFConstants.OFP_VERSION_1_3, FlowRemoved.class.getName())))).thenReturn(messageTranslatorFlowRemoved);
    Mockito.when(abstractDeviceInitializer.initialize(any(), anyBoolean(), anyBoolean(), any(), any())).thenReturn(Futures.immediateFuture(null));
    final java.util.Optional<AbstractDeviceInitializer> deviceInitializer = java.util.Optional.of(this.abstractDeviceInitializer);
    Mockito.when(deviceInitializerProvider.lookup(OFConstants.OFP_VERSION_1_3)).thenReturn(deviceInitializer);
    Mockito.when(salRoleService.setRole(any())).thenReturn(Futures.immediateFuture(null));
    deviceContext = new DeviceContextImpl(connectionContext, dataBroker, messageSpy, translatorLibrary, convertorExecutor, false, timer, false, deviceInitializerProvider, true, false, contextChainHolder);
    ((DeviceContextImpl) deviceContext).lazyTransactionManagerInitialization();
    deviceContextSpy = Mockito.spy(deviceContext);
    xid = new Xid(atomicLong.incrementAndGet());
    xidMulti = new Xid(atomicLong.incrementAndGet());
    Mockito.doNothing().when(deviceContextSpy).writeToTransaction(any(), any(), any());
}
Also used : MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) PacketReceived(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived) TranslatorKey(org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) GetAsyncReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncReply) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) FlowRemoved(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) AbstractDeviceInitializer(org.opendaylight.openflowplugin.impl.device.initialization.AbstractDeviceInitializer) Optional(com.google.common.base.Optional) FeaturesReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) PortGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) PacketIn(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn) Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) Capabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities) TransactionChainManager(org.opendaylight.openflowplugin.common.txchain.TransactionChainManager) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Before(org.junit.Before)

Aggregations

MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)52 Test (org.junit.Test)29 ArrayList (java.util.ArrayList)25 List (java.util.List)25 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)13 MultipartType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType)11 Counter64 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64)10 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)10 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)7 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)6 DurationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)6 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply)6 MultipartReplyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder)6 ConvertorManager (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager)5 QueueId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId)5 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)5 TranslatorKey (org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey)4 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)4 MultipartReplyFlowCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase)4 MultipartReplyMeterCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase)4