Search in sources :

Example 1 with MeterStatsEntry

use of org.openkilda.messaging.info.stats.MeterStatsEntry in project open-kilda by telstra.

the class OfMeterStatsMapperTest method testToPortStatsDataV13.

@Test
public void testToPortStatsDataV13() {
    OFFactoryVer13 factory = new OFFactoryVer13();
    OFMeterBandStats bandStats = factory.meterBandStats(U64.of(bandPacketCount), U64.of(bandByteCount));
    OFMeterStats meterStats = factory.buildMeterStats().setMeterId(meterId).setByteInCount(// we will put meter byte/packet count
    U64.of(meterByteCount)).setPacketInCount(// but we will expect to get band byte/packet count
    U64.of(meterPacketCount)).setBandStats(Collections.singletonList(bandStats)).build();
    OFMeterStatsReply reply = factory.buildMeterStatsReply().setEntries(Collections.singletonList(meterStats)).build();
    MeterStatsData data = OfMeterStatsMapper.INSTANCE.toMeterStatsData(Collections.singletonList(reply), switchId);
    assertEquals(switchId, data.getSwitchId());
    assertEquals(1, data.getStats().size());
    MeterStatsEntry statsEntry = data.getStats().get(0);
    // expected band byte/packet count instead of
    assertEquals(bandByteCount, statsEntry.getByteInCount());
    // meter byte/packet count
    assertEquals(bandPacketCount, statsEntry.getPacketsInCount());
}
Also used : OFMeterBandStats(org.projectfloodlight.openflow.protocol.OFMeterBandStats) MeterStatsData(org.openkilda.messaging.info.stats.MeterStatsData) OFMeterStats(org.projectfloodlight.openflow.protocol.OFMeterStats) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) OFMeterStatsReply(org.projectfloodlight.openflow.protocol.OFMeterStatsReply) MeterStatsEntry(org.openkilda.messaging.info.stats.MeterStatsEntry) Test(org.junit.Test)

Example 2 with MeterStatsEntry

use of org.openkilda.messaging.info.stats.MeterStatsEntry in project open-kilda by telstra.

the class StatsTopologyTest method meterSystemRulesStatsTest.

@Test
public void meterSystemRulesStatsTest() {
    long meterId = MeterId.createMeterIdForDefaultRule(VERIFICATION_BROADCAST_RULE_COOKIE).getValue();
    MeterStatsEntry meterStats = new MeterStatsEntry(meterId, 400L, 500L);
    sendStatsMessage(new MeterStatsData(SWITCH_ID_1, Collections.singletonList(meterStats)));
    List<Datapoint> datapoints = pollDatapoints(3);
    Map<String, Datapoint> datapointMap = createDatapointMap(datapoints);
    assertEquals(meterStats.getPacketsInCount(), datapointMap.get(METRIC_PREFIX + "switch.flow.system.meter.packets").getValue().longValue());
    assertEquals(meterStats.getByteInCount(), datapointMap.get(METRIC_PREFIX + "switch.flow.system.meter.bytes").getValue().longValue());
    assertEquals(meterStats.getByteInCount() * 8, datapointMap.get(METRIC_PREFIX + "switch.flow.system.meter.bits").getValue().longValue());
    datapoints.forEach(datapoint -> {
        assertEquals(3, datapoint.getTags().size());
        assertEquals(SWITCH_ID_1.toOtsdFormat(), datapoint.getTags().get("switchid"));
        assertEquals(String.valueOf(meterId), datapoint.getTags().get("meterid"));
        assertEquals(Cookie.toString(VERIFICATION_BROADCAST_RULE_COOKIE), datapoint.getTags().get("cookieHex"));
        assertEquals(timestamp, datapoint.getTime().longValue());
    });
}
Also used : MeterStatsData(org.openkilda.messaging.info.stats.MeterStatsData) Datapoint(org.openkilda.messaging.info.Datapoint) MeterStatsEntry(org.openkilda.messaging.info.stats.MeterStatsEntry) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 3 with MeterStatsEntry

use of org.openkilda.messaging.info.stats.MeterStatsEntry in project open-kilda by telstra.

the class StatsTopologyTest method meterFlowRulesStatsTest.

@Test
public void meterFlowRulesStatsTest() {
    Flow flow = createOneSwitchFlow(SWITCH_ID_1);
    FlowPath flowPath = flow.getForwardPath();
    sendUpdateFlowPathInfo(flowPath);
    MeterStatsEntry meterStats = new MeterStatsEntry(flowPath.getMeterId().getValue(), 500L, 700L);
    sendStatsMessage(new MeterStatsData(SWITCH_ID_1, Collections.singletonList(meterStats)));
    List<Datapoint> datapoints = pollDatapoints(3);
    Map<String, Datapoint> datapointMap = createDatapointMap(datapoints);
    assertEquals(meterStats.getPacketsInCount(), datapointMap.get(METRIC_PREFIX + "flow.meter.packets").getValue().longValue());
    assertEquals(meterStats.getByteInCount(), datapointMap.get(METRIC_PREFIX + "flow.meter.bytes").getValue().longValue());
    assertEquals(meterStats.getByteInCount() * 8, datapointMap.get(METRIC_PREFIX + "flow.meter.bits").getValue().longValue());
    datapoints.forEach(datapoint -> {
        assertEquals(6, datapoint.getTags().size());
        assertEquals(SWITCH_ID_1.toOtsdFormat(), datapoint.getTags().get("switchid"));
        assertEquals(String.valueOf(flowPath.getMeterId().getValue()), datapoint.getTags().get("meterid"));
        assertEquals("forward", datapoint.getTags().get("direction"));
        assertEquals("false", datapoint.getTags().get("is_y_flow_subflow"));
        assertEquals(flowId, datapoint.getTags().get("flowid"));
        assertEquals(String.valueOf(flowPath.getCookie().getValue()), datapoint.getTags().get("cookie"));
        assertEquals(timestamp, datapoint.getTime().longValue());
    });
}
Also used : MeterStatsData(org.openkilda.messaging.info.stats.MeterStatsData) Datapoint(org.openkilda.messaging.info.Datapoint) FlowPath(org.openkilda.model.FlowPath) MeterStatsEntry(org.openkilda.messaging.info.stats.MeterStatsEntry) Flow(org.openkilda.model.Flow) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 4 with MeterStatsEntry

use of org.openkilda.messaging.info.stats.MeterStatsEntry in project open-kilda by telstra.

the class KildaEntryCacheService method completeAndForwardMeterStats.

/**
 * Process the provided {@link MeterStatsData} by completing it with cached data and forwarding it.
 *
 * @param data the data to process.
 */
public void completeAndForwardMeterStats(MeterStatsData data) {
    SwitchMeterStats stats = new SwitchMeterStats(data.getSwitchId());
    for (MeterStatsEntry entry : data.getStats()) {
        MeterCacheKey key = new MeterCacheKey(data.getSwitchId(), entry.getMeterId());
        stats.add(entry, switchAndMeterToFlow.get(key));
    }
    carrier.emitMeterStats(stats);
}
Also used : MeterCacheKey(org.openkilda.wfm.topology.stats.model.MeterCacheKey) SwitchMeterStats(org.openkilda.wfm.topology.stats.model.SwitchMeterStats) MeterStatsEntry(org.openkilda.messaging.info.stats.MeterStatsEntry)

Example 5 with MeterStatsEntry

use of org.openkilda.messaging.info.stats.MeterStatsEntry in project open-kilda by telstra.

the class StatsTopologyTest method lldpMeterStatsTest.

@Test
public void lldpMeterStatsTest() {
    long lldpMeterId = MeterId.MIN_FLOW_METER_ID;
    MeterStatsEntry meterStats = new MeterStatsEntry(lldpMeterId, 400L, 500L);
    sendStatsMessage(new MeterStatsData(SWITCH_ID_1, Collections.singletonList(meterStats)));
    List<Datapoint> datapoints = pollDatapoints(3);
    Map<String, Datapoint> datapointMap = createDatapointMap(datapoints);
    assertEquals(meterStats.getPacketsInCount(), datapointMap.get(METRIC_PREFIX + "flow.meter.packets").getValue().longValue());
    assertEquals(meterStats.getByteInCount(), datapointMap.get(METRIC_PREFIX + "flow.meter.bytes").getValue().longValue());
    assertEquals(meterStats.getByteInCount() * 8, datapointMap.get(METRIC_PREFIX + "flow.meter.bits").getValue().longValue());
    datapoints.forEach(datapoint -> {
        assertEquals(5, datapoint.getTags().size());
        assertEquals(SWITCH_ID_1.toOtsdFormat(), datapoint.getTags().get("switchid"));
        assertEquals(String.valueOf(lldpMeterId), datapoint.getTags().get("meterid"));
        assertEquals("unknown", datapoint.getTags().get("direction"));
        assertEquals("unknown", datapoint.getTags().get("cookie"));
        assertEquals("unknown", datapoint.getTags().get("flowid"));
        assertEquals(timestamp, datapoint.getTime().longValue());
    });
}
Also used : MeterStatsData(org.openkilda.messaging.info.stats.MeterStatsData) Datapoint(org.openkilda.messaging.info.Datapoint) MeterStatsEntry(org.openkilda.messaging.info.stats.MeterStatsEntry) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Aggregations

MeterStatsEntry (org.openkilda.messaging.info.stats.MeterStatsEntry)6 Test (org.junit.Test)5 MeterStatsData (org.openkilda.messaging.info.stats.MeterStatsData)5 Datapoint (org.openkilda.messaging.info.Datapoint)3 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)3 Flow (org.openkilda.model.Flow)2 FlowEndpoint (org.openkilda.model.FlowEndpoint)1 FlowPath (org.openkilda.model.FlowPath)1 MeterId (org.openkilda.model.MeterId)1 Switch (org.openkilda.model.Switch)1 YFlow (org.openkilda.model.YFlow)1 TestFlowBuilder (org.openkilda.wfm.share.flow.TestFlowBuilder)1 TestYFlowBuilder (org.openkilda.wfm.share.yflow.TestYFlowBuilder)1 TestYSubFlowBuilder (org.openkilda.wfm.share.yflow.TestYSubFlowBuilder)1 MeterCacheKey (org.openkilda.wfm.topology.stats.model.MeterCacheKey)1 MeterStatsAndDescriptor (org.openkilda.wfm.topology.stats.model.MeterStatsAndDescriptor)1 SwitchMeterStats (org.openkilda.wfm.topology.stats.model.SwitchMeterStats)1 YFlowDescriptor (org.openkilda.wfm.topology.stats.model.YFlowDescriptor)1 OFMeterBandStats (org.projectfloodlight.openflow.protocol.OFMeterBandStats)1 OFMeterStats (org.projectfloodlight.openflow.protocol.OFMeterStats)1