Search in sources :

Example 1 with FlowStatsAndDescriptor

use of org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor in project open-kilda by telstra.

the class FlowMetricGenBolt method handleInput.

@Override
protected void handleInput(Tuple input) throws Exception {
    SwitchFlowStats stats = pullValue(input, STATS_FIELD, SwitchFlowStats.class);
    log.debug("dataCache in FlowMetricGenBolt {}", stats);
    long timestamp = pullContext(input).getCreateTime();
    SwitchId switchId = stats.getSwitchId();
    for (FlowStatsAndDescriptor entry : stats.getStatsEntries()) {
        handleStatsEntry(entry.getData(), timestamp, switchId, entry.getDescriptor());
    }
}
Also used : FlowStatsAndDescriptor(org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor) SwitchId(org.openkilda.model.SwitchId) SwitchFlowStats(org.openkilda.wfm.topology.stats.model.SwitchFlowStats)

Example 2 with FlowStatsAndDescriptor

use of org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor in project open-kilda by telstra.

the class KildaEntryCacheServiceTest method shouldHandleRemovingFlowFromCache.

@Test
public void shouldHandleRemovingFlowFromCache() {
    Flow flow = buildFlow();
    FlowStatsData statsOrigin = getFlowStatsDataSrcSwitch();
    service.completeAndForwardFlowStats(statsOrigin);
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    List<FlowStatsAndDescriptor> statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, statsOrigin.getStats().size(), 0);
    FlowPath forwardPath = flow.getForwardPath();
    UpdateFlowPathInfo pathInfo = new UpdateFlowPathInfo(flow.getFlowId(), flow.getYFlowId(), forwardPath.getCookie(), forwardPath.getMeterId(), FlowPathMapper.INSTANCE.mapToPathNodes(forwardPath));
    service.addOrUpdateCache(pathInfo);
    service.completeAndForwardFlowStats(statsOrigin);
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, statsOrigin.getStats().size(), 1);
    assertCookieCache(statsEntries, forwardPath.getCookie(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), forwardPath.getCookie(), forwardPath.getMeterId()));
    RemoveFlowPathInfo pathInfo2 = new RemoveFlowPathInfo(flow.getFlowId(), flow.getYFlowId(), forwardPath.getCookie(), forwardPath.getMeterId(), FlowPathMapper.INSTANCE.mapToPathNodes(forwardPath));
    service.removeCached(pathInfo2);
    service.completeAndForwardFlowStats(statsOrigin);
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, statsOrigin.getStats().size(), 0);
}
Also used : FlowStatsAndDescriptor(org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor) CommonFlowDescriptor(org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor) FlowStatsData(org.openkilda.messaging.info.stats.FlowStatsData) UpdateFlowPathInfo(org.openkilda.messaging.info.stats.UpdateFlowPathInfo) FlowPath(org.openkilda.model.FlowPath) RemoveFlowPathInfo(org.openkilda.messaging.info.stats.RemoveFlowPathInfo) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) Test(org.junit.Test)

Example 3 with FlowStatsAndDescriptor

use of org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor in project open-kilda by telstra.

the class KildaEntryCacheServiceTest method assertCookieCache.

private void assertCookieCache(List<FlowStatsAndDescriptor> statsEntries, FlowSegmentCookie cookie, KildaEntryDescriptor expectedDescriptor) {
    long needle = cookie.getValue();
    for (FlowStatsAndDescriptor entry : statsEntries) {
        if (needle == entry.getData().getCookie()) {
            KildaEntryDescriptor descriptor = entry.getDescriptor();
            Assert.assertEquals(expectedDescriptor, descriptor);
            return;
        }
    }
    Assert.fail("Cache miss");
}
Also used : FlowStatsAndDescriptor(org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor) KildaEntryDescriptor(org.openkilda.wfm.topology.stats.model.KildaEntryDescriptor)

Example 4 with FlowStatsAndDescriptor

use of org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor in project open-kilda by telstra.

the class KildaEntryCacheServiceTest method shouldRefreshYFlowSubFlowCookieCache.

@Test
public void shouldRefreshYFlowSubFlowCookieCache() {
    Switch srcSwitch = Switch.builder().switchId(SRC_SWITCH_ID).build();
    Switch destSwitch = Switch.builder().switchId(DST_SWITCH_ID).build();
    Switch transitSwitch = Switch.builder().switchId(TRANSIT_SWITCH_ID).build();
    Flow flow = new TestFlowBuilder().yFlowId("dummy-y-flow-id").srcSwitch(srcSwitch).addTransitionEndpoint(srcSwitch, 2).addTransitionEndpoint(transitSwitch, 1).addTransitionEndpoint(transitSwitch, 2).addTransitionEndpoint(destSwitch, 1).unmaskedCookie(FLOW_UNMASKED_COOKIE).forwardMeterId(FORWARD_METER_ID).reverseMeterId(REVERSE_METER_ID).destSwitch(destSwitch).build();
    when(flowRepository.findAll()).thenReturn(Collections.singletonList(flow));
    when(yFlowRepository.findAll()).thenReturn(Collections.emptyList());
    service.refreshCache();
    final FlowSegmentCookie forwardPathCookie = flow.getForwardPath().getCookie();
    final FlowSegmentCookie reversePathCookie = flow.getReversePath().getCookie();
    // source switch
    service.completeAndForwardFlowStats(new FlowStatsData(flow.getSrcSwitchId(), asList(new FlowStatsEntry(0, forwardPathCookie.getValue(), 0, 0, 0, 0), new FlowStatsEntry(0, reversePathCookie.getValue(), 0, 0, 0, 0))));
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    List<FlowStatsAndDescriptor> statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, 2, 2);
    assertCookieCache(statsEntries, forwardPathCookie, new YFlowSubDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getYFlowId(), flow.getFlowId(), forwardPathCookie, flow.getForwardPath().getMeterId()));
    assertCookieCache(statsEntries, reversePathCookie, new YFlowSubDescriptor(flow.getSrcSwitchId(), EGRESS, flow.getYFlowId(), flow.getFlowId(), reversePathCookie, null));
    // transit
    service.completeAndForwardFlowStats(new FlowStatsData(transitSwitch.getSwitchId(), asList(new FlowStatsEntry(0, forwardPathCookie.getValue(), 0, 0, 0, 0), new FlowStatsEntry(0, reversePathCookie.getValue(), 0, 0, 0, 0))));
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, 2, 2);
    assertCookieCache(statsEntries, forwardPathCookie, new YFlowSubDescriptor(transitSwitch.getSwitchId(), TRANSIT, flow.getYFlowId(), flow.getFlowId(), forwardPathCookie, null));
    assertCookieCache(statsEntries, reversePathCookie, new YFlowSubDescriptor(transitSwitch.getSwitchId(), TRANSIT, flow.getYFlowId(), flow.getFlowId(), reversePathCookie, null));
    // egress
    service.completeAndForwardFlowStats(new FlowStatsData(flow.getDestSwitchId(), asList(new FlowStatsEntry(0, forwardPathCookie.getValue(), 0, 0, 0, 0), new FlowStatsEntry(0, reversePathCookie.getValue(), 0, 0, 0, 0))));
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, 2, 2);
    assertCookieCache(statsEntries, forwardPathCookie, new YFlowSubDescriptor(flow.getDestSwitchId(), EGRESS, flow.getYFlowId(), flow.getFlowId(), forwardPathCookie, null));
    assertCookieCache(statsEntries, reversePathCookie, new YFlowSubDescriptor(flow.getDestSwitchId(), INGRESS, flow.getYFlowId(), flow.getFlowId(), reversePathCookie, flow.getReversePath().getMeterId()));
}
Also used : FlowStatsAndDescriptor(org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Switch(org.openkilda.model.Switch) FlowStatsEntry(org.openkilda.messaging.info.stats.FlowStatsEntry) FlowStatsData(org.openkilda.messaging.info.stats.FlowStatsData) YFlowSubDescriptor(org.openkilda.wfm.topology.stats.model.YFlowSubDescriptor) TestFlowBuilder(org.openkilda.wfm.share.flow.TestFlowBuilder) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) Test(org.junit.Test)

Example 5 with FlowStatsAndDescriptor

use of org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor in project open-kilda by telstra.

the class KildaEntryCacheServiceTest method shouldRefreshCommonFlowsCookieCache.

@Test
public void shouldRefreshCommonFlowsCookieCache() {
    Flow flow = buildFlow();
    when(flowRepository.findAll()).thenReturn(Collections.singletonList(flow));
    when(yFlowRepository.findAll()).thenReturn(Collections.emptyList());
    service.refreshCache();
    final FlowPath forwardPath = flow.getForwardPath();
    FlowStatsData statsOriginSrc = getFlowStatsDataSrcSwitch();
    service.completeAndForwardFlowStats(statsOriginSrc);
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    List<FlowStatsAndDescriptor> statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, statsOriginSrc.getStats().size(), 3);
    assertCookieCache(statsEntries, forwardPath.getCookie(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), forwardPath.getCookie(), flow.getForwardPath().getMeterId()));
    assertCookieCache(statsEntries, REVERSE_PATH_COOKIE, new CommonFlowDescriptor(flow.getSrcSwitchId(), EGRESS, flow.getFlowId(), REVERSE_PATH_COOKIE, null));
    assertCookieCache(statsEntries, PROTECTED_REVERSE_PATH_COOKIE, new CommonFlowDescriptor(flow.getSrcSwitchId(), EGRESS, flow.getFlowId(), PROTECTED_REVERSE_PATH_COOKIE, null));
    FlowStatsData statsOriginDst = getFlowStatsDataDstSwitch();
    service.completeAndForwardFlowStats(statsOriginDst);
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, statsOriginDst.getStats().size(), 3);
    assertCookieCache(statsEntries, forwardPath.getCookie(), new CommonFlowDescriptor(flow.getDestSwitchId(), EGRESS, flow.getFlowId(), forwardPath.getCookie(), null));
    assertCookieCache(statsEntries, REVERSE_PATH_COOKIE, new CommonFlowDescriptor(flow.getDestSwitchId(), INGRESS, flow.getFlowId(), REVERSE_PATH_COOKIE, flow.getReversePath().getMeterId()));
    assertCookieCache(statsEntries, PROTECTED_FORWARD_PATH_COOKIE, new CommonFlowDescriptor(flow.getDestSwitchId(), EGRESS, flow.getFlowId(), PROTECTED_FORWARD_PATH_COOKIE, null));
    FlowStatsData statsOriginTransit = getFlowStatsDataTransitSwitch();
    service.completeAndForwardFlowStats(statsOriginTransit);
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, statsOriginTransit.getStats().size(), 4);
    assertCookieCache(statsEntries, forwardPath.getCookie(), new CommonFlowDescriptor(TRANSIT_SWITCH_ID, TRANSIT, flow.getFlowId(), forwardPath.getCookie(), null));
    assertCookieCache(statsEntries, REVERSE_PATH_COOKIE, new CommonFlowDescriptor(TRANSIT_SWITCH_ID, TRANSIT, flow.getFlowId(), REVERSE_PATH_COOKIE, null));
    assertCookieCache(statsEntries, PROTECTED_FORWARD_PATH_COOKIE, new CommonFlowDescriptor(TRANSIT_SWITCH_ID, TRANSIT, flow.getFlowId(), PROTECTED_FORWARD_PATH_COOKIE, null));
    assertCookieCache(statsEntries, PROTECTED_REVERSE_PATH_COOKIE, new CommonFlowDescriptor(TRANSIT_SWITCH_ID, TRANSIT, flow.getFlowId(), PROTECTED_REVERSE_PATH_COOKIE, null));
    // flow endpoint satellites
    service.completeAndForwardFlowStats(new FlowStatsData(flow.getSrcSwitchId(), asList(new FlowStatsEntry(0, forwardPath.getCookie().toBuilder().type(CookieType.SERVER_42_FLOW_RTT_INGRESS).build().getValue(), 0, 0, 0, 0), new FlowStatsEntry(0, forwardPath.getCookie().toBuilder().mirror(true).build().getValue(), 0, 0, 0, 0), new FlowStatsEntry(0, forwardPath.getCookie().toBuilder().looped(true).build().getValue(), 0, 0, 0, 0))));
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, 3, 3);
    assertCookieCache(statsEntries, forwardPath.getCookie().toBuilder().type(CookieType.SERVER_42_FLOW_RTT_INGRESS).build(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), forwardPath.getCookie(), forwardPath.getMeterId()));
    assertCookieCache(statsEntries, forwardPath.getCookie().toBuilder().mirror(true).build(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), forwardPath.getCookie(), forwardPath.getMeterId()));
    assertCookieCache(statsEntries, forwardPath.getCookie().toBuilder().looped(true).build(), new CommonFlowDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getFlowId(), forwardPath.getCookie(), forwardPath.getMeterId()));
}
Also used : FlowStatsAndDescriptor(org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor) CommonFlowDescriptor(org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor) FlowStatsEntry(org.openkilda.messaging.info.stats.FlowStatsEntry) FlowStatsData(org.openkilda.messaging.info.stats.FlowStatsData) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) Test(org.junit.Test)

Aggregations

FlowStatsAndDescriptor (org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor)6 Test (org.junit.Test)4 FlowStatsData (org.openkilda.messaging.info.stats.FlowStatsData)4 Flow (org.openkilda.model.Flow)4 YFlow (org.openkilda.model.YFlow)4 FlowPath (org.openkilda.model.FlowPath)3 CommonFlowDescriptor (org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor)3 FlowStatsEntry (org.openkilda.messaging.info.stats.FlowStatsEntry)2 UpdateFlowPathInfo (org.openkilda.messaging.info.stats.UpdateFlowPathInfo)2 RemoveFlowPathInfo (org.openkilda.messaging.info.stats.RemoveFlowPathInfo)1 Switch (org.openkilda.model.Switch)1 SwitchId (org.openkilda.model.SwitchId)1 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)1 TestFlowBuilder (org.openkilda.wfm.share.flow.TestFlowBuilder)1 KildaEntryDescriptor (org.openkilda.wfm.topology.stats.model.KildaEntryDescriptor)1 SwitchFlowStats (org.openkilda.wfm.topology.stats.model.SwitchFlowStats)1 YFlowSubDescriptor (org.openkilda.wfm.topology.stats.model.YFlowSubDescriptor)1