Search in sources :

Example 11 with Drop

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop in project openflowplugin by opendaylight.

the class MultipartReplyMeterConfigDeserializerTest method deserializeDrop.

@Test
public void deserializeDrop() throws Exception {
    ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    writeCommonAtributes(buffer);
    buffer.writeShort(OFPMBTDROP);
    buffer.writeShort(SUB_ITEM);
    buffer.writeInt(DROP_RATE);
    buffer.writeInt(DROP_BURST_SIZE);
    buffer.writeZero(PADDING_IN_METER_BAND_DROP_HEADER);
    final MultipartReplyMeterConfig reply = (MultipartReplyMeterConfig) deserializeMultipart(buffer);
    assertEquals(METER_ID, reply.getMeterConfigStats().get(0).getMeterId().getValue().intValue());
    assertEquals(FLAGS, reply.getMeterConfigStats().get(0).getFlags());
    final Drop drop = (Drop) reply.getMeterConfigStats().get(0).getMeterBandHeaders().getMeterBandHeader().get(0).getBandType();
    assertEquals(DROP_RATE, drop.getDropRate().intValue());
    assertEquals(DROP_BURST_SIZE, drop.getDropBurstSize().intValue());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyMeterConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterConfig) Drop(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop) Test(org.junit.Test)

Example 12 with Drop

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop in project bgpcep by opendaylight.

the class Stateful07TopologySessionListenerTest method testDuplicatedSession.

/**
 * When a session is somehow duplicated in controller, the controller should drop existing session.
 */
@Test
public void testDuplicatedSession() throws ReadFailedException {
    this.listener.onSessionUp(this.session);
    // create node
    this.topologyRpcs.addLsp(createAddLspInput());
    final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
    final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
    final long srpId = req.getSrp().getOperationId().getValue();
    final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true, this.testAddress, this.testAddress, this.testAddress, Optional.absent());
    final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setSync(true).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.of(MsgBuilderUtil.createSrp(srpId)), MsgBuilderUtil.createPath(req.getEro().getSubobject()));
    this.listener.onMessage(this.session, pcRpt);
    readDataOperational(getDataBroker(), TOPO_IID, topology -> {
        assertEquals(1, topology.getNode().size());
        return topology;
    });
    // now we do session up again
    this.listener.onSessionUp(this.session);
    assertTrue(this.session.isClosed());
    // node should be removed after termination
    checkNotPresentOperational(getDataBroker(), this.pathComputationClientIId);
    assertFalse(this.receivedMsgs.isEmpty());
    // the last message should be a Close message
    assertTrue(this.receivedMsgs.get(this.receivedMsgs.size() - 1) instanceof Close);
}
Also used : Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs) MsgBuilderUtil.createLspTlvs(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) Close(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Close) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests) Pcinitiate(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Pcinitiate) Test(org.junit.Test)

Example 13 with Drop

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop in project netvirt by opendaylight.

the class ElanInterfaceManager method setupFilterEqualsTable.

public void setupFilterEqualsTable(ElanInstance elanInfo, InterfaceInfo interfaceInfo, WriteTransaction writeFlowGroupTx) {
    int ifTag = interfaceInfo.getInterfaceTag();
    Flow flow = MDSALUtil.buildFlowNew(NwConstants.ELAN_FILTER_EQUALS_TABLE, getFlowRef(NwConstants.ELAN_FILTER_EQUALS_TABLE, ifTag, "group"), 9, elanInfo.getElanInstanceName(), 0, 0, ElanConstants.COOKIE_ELAN_FILTER_EQUALS.add(BigInteger.valueOf(ifTag)), ElanUtils.getTunnelIdMatchForFilterEqualsLPortTag(ifTag), elanUtils.getInstructionsInPortForOutGroup(interfaceInfo.getInterfaceName()));
    mdsalManager.addFlowToTx(interfaceInfo.getDpId(), flow, writeFlowGroupTx);
    Flow flowEntry = MDSALUtil.buildFlowNew(NwConstants.ELAN_FILTER_EQUALS_TABLE, getFlowRef(NwConstants.ELAN_FILTER_EQUALS_TABLE, ifTag, "drop"), 10, elanInfo.getElanInstanceName(), 0, 0, ElanConstants.COOKIE_ELAN_FILTER_EQUALS.add(BigInteger.valueOf(ifTag)), getMatchesForFilterEqualsLPortTag(ifTag), MDSALUtil.buildInstructionsDrop());
    mdsalManager.addFlowToTx(interfaceInfo.getDpId(), flowEntry, writeFlowGroupTx);
}
Also used : Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 14 with Drop

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop in project netvirt by opendaylight.

the class AclLiveStatisticsRpcServiceTest method getStatsTwoPortEgressOnly.

/**
 * Test stats for two ports and egress direction only. <br>
 * port1 is valid <br>
 * port2 is invalid <br>
 * Expectation: Error expected for port2. Drop stats should be available for
 * egress direction only.
 *
 * @throws Exception the exception
 */
@Test
public void getStatsTwoPortEgressOnly() throws Exception {
    List<String> lstInterfaces = Arrays.asList(PORT_1, PORT_2);
    Direction direction = Direction.Egress;
    GetAclPortStatisticsInput input = new GetAclPortStatisticsInputBuilder().setDirection(direction).setInterfaceNames(lstInterfaces).build();
    Future<RpcResult<GetAclPortStatisticsOutput>> rpcResultFuture = aclStatsService.getAclPortStatistics(input);
    RpcResult<GetAclPortStatisticsOutput> output = rpcResultFuture.get();
    LOG.info("getStatsTwoPortEgressOnly output = {}", output);
    assertStatsOutput(output, direction);
}
Also used : GetAclPortStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetAclPortStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsInput) Direction(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.Direction) GetAclPortStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsInputBuilder) Test(org.junit.Test)

Example 15 with Drop

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop in project netvirt by opendaylight.

the class AclLiveStatisticsHelper method getAclDropStats.

/**
 * Gets the acl drop stats.
 *
 * @param direction the direction
 * @param aclStatsBuilder the acl stats builder
 * @param flowStatsOutput the flow stats output
 */
private static void getAclDropStats(Direction direction, AclPortStatsBuilder aclStatsBuilder, GetFlowStatisticsOutput flowStatsOutput) {
    List<FlowAndStatisticsMapList> flowAndStatisticsMapList = flowStatsOutput.getFlowAndStatisticsMapList();
    if (flowAndStatisticsMapList == null || flowAndStatisticsMapList.isEmpty()) {
        String errMsg = "Unable to retrieve drop counts as interface is not configured for statistics collection.";
        aclStatsBuilder.setError(new ErrorBuilder().setErrorMessage(errMsg).build());
        return;
    }
    BytesBuilder portEgressBytesBuilder = new BytesBuilder();
    BytesBuilder portIngressBytesBuilder = new BytesBuilder();
    PacketsBuilder portEgressPacketsBuilder = new PacketsBuilder();
    PacketsBuilder portIngressPacketsBuilder = new PacketsBuilder();
    for (FlowAndStatisticsMapList flowStats : flowAndStatisticsMapList) {
        BigInteger portEgressBytesBuilderDropCount = BigInteger.valueOf(0);
        BigInteger portEgressPacketsBuilderDropCount = BigInteger.valueOf(0);
        BigInteger portIngressBytesBuilderDropCount = BigInteger.valueOf(0);
        BigInteger portIngressPacketsBuilderDropCount = BigInteger.valueOf(0);
        switch(flowStats.getTableId()) {
            case NwConstants.INGRESS_ACL_FILTER_CUM_DISPATCHER_TABLE:
                if (flowStats.getPriority().equals(AclConstants.CT_STATE_TRACKED_INVALID_PRIORITY)) {
                    portEgressBytesBuilder.setInvalidDropCount(flowStats.getByteCount().getValue());
                    portEgressPacketsBuilder.setInvalidDropCount(flowStats.getPacketCount().getValue());
                } else if (flowStats.getPriority().equals(AclConstants.ACL_PORT_SPECIFIC_DROP_PRIORITY)) {
                    if (portEgressBytesBuilder.getDropCount() != null) {
                        portEgressBytesBuilderDropCount = portEgressBytesBuilder.getDropCount().add(flowStats.getByteCount().getValue());
                        portEgressPacketsBuilderDropCount = portEgressPacketsBuilder.getDropCount().add(flowStats.getPacketCount().getValue());
                    } else {
                        portEgressBytesBuilderDropCount = flowStats.getByteCount().getValue();
                        portEgressPacketsBuilderDropCount = flowStats.getPacketCount().getValue();
                    }
                } else if (flowStats.getPriority().equals(AclConstants.ACE_LAST_REMOTE_ACL_PRIORITY)) {
                    if (portEgressBytesBuilder.getDropCount() != null) {
                        portEgressBytesBuilderDropCount = portEgressBytesBuilder.getDropCount().add(flowStats.getByteCount().getValue());
                        portEgressPacketsBuilderDropCount = portEgressPacketsBuilder.getDropCount().add(flowStats.getPacketCount().getValue());
                    } else {
                        portEgressBytesBuilderDropCount = flowStats.getByteCount().getValue();
                        portEgressPacketsBuilderDropCount = flowStats.getPacketCount().getValue();
                    }
                }
                // TODO: Update stats for other drops
                break;
            case NwConstants.EGRESS_ACL_FILTER_CUM_DISPATCHER_TABLE:
                if (flowStats.getPriority().equals(AclConstants.CT_STATE_TRACKED_INVALID_PRIORITY)) {
                    portIngressBytesBuilder.setInvalidDropCount(flowStats.getByteCount().getValue());
                    portIngressPacketsBuilder.setInvalidDropCount(flowStats.getPacketCount().getValue());
                } else if (flowStats.getPriority().equals(AclConstants.ACL_PORT_SPECIFIC_DROP_PRIORITY)) {
                    if (portIngressBytesBuilder.getDropCount() != null) {
                        portIngressBytesBuilderDropCount = portIngressBytesBuilder.getDropCount().add(flowStats.getByteCount().getValue());
                        portIngressPacketsBuilderDropCount = portIngressPacketsBuilder.getDropCount().add(flowStats.getPacketCount().getValue());
                    } else {
                        portIngressBytesBuilderDropCount = flowStats.getByteCount().getValue();
                        portIngressPacketsBuilderDropCount = flowStats.getPacketCount().getValue();
                    }
                } else if (flowStats.getPriority().equals(AclConstants.ACE_LAST_REMOTE_ACL_PRIORITY)) {
                    if (portIngressBytesBuilder.getDropCount() != null) {
                        portIngressBytesBuilderDropCount = portIngressBytesBuilder.getDropCount().add(flowStats.getByteCount().getValue());
                        portIngressPacketsBuilderDropCount = portIngressPacketsBuilder.getDropCount().add(flowStats.getPacketCount().getValue());
                    } else {
                        portIngressBytesBuilderDropCount = flowStats.getByteCount().getValue();
                        portIngressPacketsBuilderDropCount = flowStats.getPacketCount().getValue();
                    }
                }
                // TODO: Update stats for other drops
                break;
            default:
                LOG.warn("Invalid table ID filtered for Acl flow stats: {}", flowStats);
                break;
        }
        portEgressBytesBuilder.setDropCount(portEgressBytesBuilderDropCount);
        portEgressPacketsBuilder.setDropCount(portEgressPacketsBuilderDropCount);
        portIngressBytesBuilder.setDropCount(portIngressBytesBuilderDropCount);
        portIngressPacketsBuilder.setDropCount(portIngressPacketsBuilderDropCount);
    }
    List<AclDropStats> lstAclDropStats = new ArrayList<>();
    if (direction == Direction.Egress || direction == Direction.Both) {
        AclDropStats aclEgressDropStats = new AclDropStatsBuilder().setDirection(Direction.Egress).setBytes(portEgressBytesBuilder.build()).setPackets(portEgressPacketsBuilder.build()).build();
        lstAclDropStats.add(aclEgressDropStats);
    }
    if (direction == Direction.Ingress || direction == Direction.Both) {
        AclDropStats aclIngressDropStats = new AclDropStatsBuilder().setDirection(Direction.Ingress).setBytes(portIngressBytesBuilder.build()).setPackets(portIngressPacketsBuilder.build()).build();
        lstAclDropStats.add(aclIngressDropStats);
    }
    aclStatsBuilder.setAclDropStats(lstAclDropStats);
}
Also used : AclDropStats(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.acl.port.stats.AclDropStats) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) PacketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.acl.port.stats.acl.drop.stats.PacketsBuilder) AclDropStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.acl.port.stats.AclDropStatsBuilder) ErrorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.acl.port.stats.ErrorBuilder) BytesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.acl.port.stats.acl.drop.stats.BytesBuilder)

Aggregations

ArrayList (java.util.ArrayList)18 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)10 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)10 InstructionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)9 ApplyActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder)9 ApplyActionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder)9 InstructionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder)9 Test (org.junit.Test)8 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)8 ControllerActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder)7 DropAction (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction)7 DropActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder)7 GroupActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder)7 PushMplsActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder)7 PushPbbActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder)7 SetVlanIdActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder)7 InstructionKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey)6 PopMplsActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder)5 PopPbbActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder)5 PopVlanActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder)5