Search in sources :

Example 1 with RemoveFlowPathInfo

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

the class NotifyFlowStatsOnRemovedPathsAction method perform.

@Override
protected void perform(S from, S to, E event, C context, T stateMachine) {
    Stream.of(stateMachine.getOldPrimaryForwardPath(), stateMachine.getOldPrimaryReversePath(), stateMachine.getOldProtectedForwardPath(), stateMachine.getOldProtectedReversePath()).map(flowPathRepository::findById).filter(Optional::isPresent).map(Optional::get).forEach(flowPath -> {
        Flow flow = flowPath.getFlow();
        RemoveFlowPathInfo pathInfo = new RemoveFlowPathInfo(flow.getFlowId(), flow.getYFlowId(), flowPath.getCookie(), flowPath.getMeterId(), FlowPathMapper.INSTANCE.mapToPathNodes(flowPath));
        carrier.sendNotifyFlowStats(pathInfo);
    });
}
Also used : Optional(java.util.Optional) RemoveFlowPathInfo(org.openkilda.messaging.info.stats.RemoveFlowPathInfo) Flow(org.openkilda.model.Flow)

Example 2 with RemoveFlowPathInfo

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

the class NotifyFlowStatsAction method perform.

@Override
protected void perform(State from, State to, Event event, FlowDeleteContext context, FlowDeleteFsm stateMachine) {
    String flowId = stateMachine.getFlowId();
    flowPathRepository.findByFlowId(flowId).forEach(flowPath -> {
        Flow flow = flowPath.getFlow();
        RemoveFlowPathInfo pathInfo = new RemoveFlowPathInfo(flow.getFlowId(), flow.getYFlowId(), flowPath.getCookie(), flowPath.getMeterId(), FlowPathMapper.INSTANCE.mapToPathNodes(flowPath));
        carrier.sendNotifyFlowStats(pathInfo);
    });
}
Also used : RemoveFlowPathInfo(org.openkilda.messaging.info.stats.RemoveFlowPathInfo) Flow(org.openkilda.model.Flow)

Example 3 with RemoveFlowPathInfo

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

the class StatsTopologyTest method sendRemoveFlowPathInfo.

private void sendRemoveFlowPathInfo(FlowPath flowPath) {
    RemoveFlowPathInfo pathInfo = new RemoveFlowPathInfo(flowPath.getFlowId(), null, flowPath.getCookie(), flowPath.getMeterId(), FlowPathMapper.INSTANCE.mapToPathNodes(flowPath));
    InfoMessage infoMessage = new InfoMessage(pathInfo, timestamp, UUID.randomUUID().toString(), null, null);
    sendMessage(infoMessage, statsTopologyConfig.getFlowStatsNotifyTopic());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) RemoveFlowPathInfo(org.openkilda.messaging.info.stats.RemoveFlowPathInfo)

Example 4 with RemoveFlowPathInfo

use of org.openkilda.messaging.info.stats.RemoveFlowPathInfo 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 5 with RemoveFlowPathInfo

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

the class KildaEntryCacheServiceTest method shouldHandleRemovingMeterFromCache.

@Test
public void shouldHandleRemovingMeterFromCache() {
    Flow flow = buildFlow();
    MeterStatsData statsOrigin = getMeterStatsDataSrcSwitch();
    service.completeAndForwardMeterStats(statsOrigin);
    verify(carrier, atLeastOnce()).emitMeterStats(meterCacheCaptor.capture());
    List<MeterStatsAndDescriptor> statsEntries = meterCacheCaptor.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.completeAndForwardMeterStats(statsOrigin);
    verify(carrier, atLeastOnce()).emitMeterStats(meterCacheCaptor.capture());
    statsEntries = meterCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, statsOrigin.getStats().size(), 1);
    assertMeterCache(statsEntries, forwardPath.getMeterId().getValue(), 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.completeAndForwardMeterStats(statsOrigin);
    verify(carrier, atLeastOnce()).emitMeterStats(meterCacheCaptor.capture());
    statsEntries = meterCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, statsOrigin.getStats().size(), 0);
}
Also used : MeterStatsData(org.openkilda.messaging.info.stats.MeterStatsData) MeterStatsAndDescriptor(org.openkilda.wfm.topology.stats.model.MeterStatsAndDescriptor) CommonFlowDescriptor(org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor) 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)

Aggregations

RemoveFlowPathInfo (org.openkilda.messaging.info.stats.RemoveFlowPathInfo)5 Flow (org.openkilda.model.Flow)4 Test (org.junit.Test)2 UpdateFlowPathInfo (org.openkilda.messaging.info.stats.UpdateFlowPathInfo)2 FlowPath (org.openkilda.model.FlowPath)2 YFlow (org.openkilda.model.YFlow)2 CommonFlowDescriptor (org.openkilda.wfm.topology.stats.model.CommonFlowDescriptor)2 Optional (java.util.Optional)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 FlowStatsData (org.openkilda.messaging.info.stats.FlowStatsData)1 MeterStatsData (org.openkilda.messaging.info.stats.MeterStatsData)1 FlowStatsAndDescriptor (org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor)1 MeterStatsAndDescriptor (org.openkilda.wfm.topology.stats.model.MeterStatsAndDescriptor)1