@Test public void testRun_wrongDataResponse() { when(data.getKey()).thenReturn("1,2"); task.run(); }
@Override public void run() { for (FlowCacheData flowCacheData : dataList) { Map<String, String> flowCacheDataMap = createFlowCacheDataMap(flowCacheData); if (flowCacheDataMap == null) { LOG.info("Stats are skipped for {}", flowCacheData); continue; } String srcIp = flowCacheDataMap.get(FlowCacheCons.Key.IP_SOURCE.get()); String dstIp = flowCacheDataMap.get(FlowCacheCons.Key.IP_DESTINATION.get()); EndpointL3 srcEpL3 = OFStatisticsManager.getEndpointL3ForIp(srcIp); EndpointL3 dstEpL3 = OFStatisticsManager.getEndpointL3ForIp(dstIp); if (srcEpL3 != null && dstEpL3 != null) { ContractId contractId = IidSflowNameUtil.resolveContractIdFromFlowCacheName(flowCache.getName()); MatchedRuleStatisticBuilder matchedRuleStatisticBuilder = new MatchedRuleStatisticBuilder() .setContract(contractId) .setSubject(IidSflowNameUtil.resolveSubjectNameFromFlowCacheName(flowCache.getName())) .setMatchedRule(IidSflowNameUtil.resolveRuleNameFromFlowCacheName(flowCache.getName())) .setClassifier(ImmutableList .of(IidSflowNameUtil.resolveClassifierNameFromFlowCacheName(flowCache.getName()))); if (FlowCacheCons.Value.BYTES.get().equals(IidSflowNameUtil.resolveFlowCacheValue(flowCache.getName()))) { matchedRuleStatisticBuilder.setByteCount(Math.round(flowCacheData.getValue())); } else if (FlowCacheCons.Value.FRAMES.get().equals(IidSflowNameUtil.resolveFlowCacheValue(flowCache.getName()))) { matchedRuleStatisticBuilder.setPacketCount(Math.round(flowCacheData.getValue())); } Set<Pair<ConsEpgKey, ProvEpgKey>> epgsForContract = OFStatisticsManager.getEpgsForContract(contractId); Set<EpgKey> epgsFromSrcEp = getEpgsFromEndpoint(srcEpL3); Set<EpgKey> epgsFromDstEp = getEpgsFromEndpoint(dstEpL3); Pair<? extends EpgKey, ? extends EpgKey> leftSrcEpgRightDstEpg = getMatchingEpgs(epgsForContract, epgsFromSrcEp, epgsFromDstEp, flowCache.getDirection()); if (leftSrcEpgRightDstEpg == null) { LOG.info("Stats are skipped for {}", flowCacheData); continue; } EpEpgToEpEpgStatistic epEpgToEpEpgStats = new EpEpgToEpEpgStatisticBuilder() .setSrcEpg(leftSrcEpgRightDstEpg.getLeft().getEpgId()) .setDstEpg(leftSrcEpgRightDstEpg.getRight().getEpgId()) .setMatchedRuleStatistic(ImmutableList.of(matchedRuleStatisticBuilder.build())) .build(); EpToEpStatistic e2e = new EpToEpStatisticBuilder().setSrcL2c(srcEpL3.getL2Context()) .setSrcMacAddress(srcEpL3.getMacAddress()) .setSrcTenant(srcEpL3.getTenant()) .setDstL2c(dstEpL3.getL2Context()) .setDstMacAddress(dstEpL3.getMacAddress()) .setDstTenant(dstEpL3.getTenant()) .setEpEpgToEpEpgStatistic(ImmutableList.of(epEpgToEpEpgStats)) .setTimestamp(timestamp) .build(); StatRecords statRecords = new StatRecordsBuilder().setEpToEpStatistic(ImmutableList.of(e2e)).build(); if (LOG.isTraceEnabled()) { LOG.trace("[sflow] writing StatRecords: {}", statRecords); } statisticsManager.writeStat(statRecords); } } }
ProcessDataTask implements Runnable { @Override public void run() { for (FlowCacheData flowCacheData : dataList) { Map<String, String> flowCacheDataMap = createFlowCacheDataMap(flowCacheData); if (flowCacheDataMap == null) { LOG.info("Stats are skipped for {}", flowCacheData); continue; } String srcIp = flowCacheDataMap.get(FlowCacheCons.Key.IP_SOURCE.get()); String dstIp = flowCacheDataMap.get(FlowCacheCons.Key.IP_DESTINATION.get()); EndpointL3 srcEpL3 = OFStatisticsManager.getEndpointL3ForIp(srcIp); EndpointL3 dstEpL3 = OFStatisticsManager.getEndpointL3ForIp(dstIp); if (srcEpL3 != null && dstEpL3 != null) { ContractId contractId = IidSflowNameUtil.resolveContractIdFromFlowCacheName(flowCache.getName()); MatchedRuleStatisticBuilder matchedRuleStatisticBuilder = new MatchedRuleStatisticBuilder() .setContract(contractId) .setSubject(IidSflowNameUtil.resolveSubjectNameFromFlowCacheName(flowCache.getName())) .setMatchedRule(IidSflowNameUtil.resolveRuleNameFromFlowCacheName(flowCache.getName())) .setClassifier(ImmutableList .of(IidSflowNameUtil.resolveClassifierNameFromFlowCacheName(flowCache.getName()))); if (FlowCacheCons.Value.BYTES.get().equals(IidSflowNameUtil.resolveFlowCacheValue(flowCache.getName()))) { matchedRuleStatisticBuilder.setByteCount(Math.round(flowCacheData.getValue())); } else if (FlowCacheCons.Value.FRAMES.get().equals(IidSflowNameUtil.resolveFlowCacheValue(flowCache.getName()))) { matchedRuleStatisticBuilder.setPacketCount(Math.round(flowCacheData.getValue())); } Set<Pair<ConsEpgKey, ProvEpgKey>> epgsForContract = OFStatisticsManager.getEpgsForContract(contractId); Set<EpgKey> epgsFromSrcEp = getEpgsFromEndpoint(srcEpL3); Set<EpgKey> epgsFromDstEp = getEpgsFromEndpoint(dstEpL3); Pair<? extends EpgKey, ? extends EpgKey> leftSrcEpgRightDstEpg = getMatchingEpgs(epgsForContract, epgsFromSrcEp, epgsFromDstEp, flowCache.getDirection()); if (leftSrcEpgRightDstEpg == null) { LOG.info("Stats are skipped for {}", flowCacheData); continue; } EpEpgToEpEpgStatistic epEpgToEpEpgStats = new EpEpgToEpEpgStatisticBuilder() .setSrcEpg(leftSrcEpgRightDstEpg.getLeft().getEpgId()) .setDstEpg(leftSrcEpgRightDstEpg.getRight().getEpgId()) .setMatchedRuleStatistic(ImmutableList.of(matchedRuleStatisticBuilder.build())) .build(); EpToEpStatistic e2e = new EpToEpStatisticBuilder().setSrcL2c(srcEpL3.getL2Context()) .setSrcMacAddress(srcEpL3.getMacAddress()) .setSrcTenant(srcEpL3.getTenant()) .setDstL2c(dstEpL3.getL2Context()) .setDstMacAddress(dstEpL3.getMacAddress()) .setDstTenant(dstEpL3.getTenant()) .setEpEpgToEpEpgStatistic(ImmutableList.of(epEpgToEpEpgStats)) .setTimestamp(timestamp) .build(); StatRecords statRecords = new StatRecordsBuilder().setEpToEpStatistic(ImmutableList.of(e2e)).build(); if (LOG.isTraceEnabled()) { LOG.trace("[sflow] writing StatRecords: {}", statRecords); } statisticsManager.writeStat(statRecords); } } } }
ProcessDataTask implements Runnable { @Override public void run() { for (FlowCacheData flowCacheData : dataList) { Map<String, String> flowCacheDataMap = createFlowCacheDataMap(flowCacheData); if (flowCacheDataMap == null) { LOG.info("Stats are skipped for {}", flowCacheData); continue; } String srcIp = flowCacheDataMap.get(FlowCacheCons.Key.IP_SOURCE.get()); String dstIp = flowCacheDataMap.get(FlowCacheCons.Key.IP_DESTINATION.get()); EndpointL3 srcEpL3 = OFStatisticsManager.getEndpointL3ForIp(srcIp); EndpointL3 dstEpL3 = OFStatisticsManager.getEndpointL3ForIp(dstIp); if (srcEpL3 != null && dstEpL3 != null) { ContractId contractId = IidSflowNameUtil.resolveContractIdFromFlowCacheName(flowCache.getName()); MatchedRuleStatisticBuilder matchedRuleStatisticBuilder = new MatchedRuleStatisticBuilder() .setContract(contractId) .setSubject(IidSflowNameUtil.resolveSubjectNameFromFlowCacheName(flowCache.getName())) .setMatchedRule(IidSflowNameUtil.resolveRuleNameFromFlowCacheName(flowCache.getName())) .setClassifier(ImmutableList .of(IidSflowNameUtil.resolveClassifierNameFromFlowCacheName(flowCache.getName()))); if (FlowCacheCons.Value.BYTES.get().equals(IidSflowNameUtil.resolveFlowCacheValue(flowCache.getName()))) { matchedRuleStatisticBuilder.setByteCount(Math.round(flowCacheData.getValue())); } else if (FlowCacheCons.Value.FRAMES.get().equals(IidSflowNameUtil.resolveFlowCacheValue(flowCache.getName()))) { matchedRuleStatisticBuilder.setPacketCount(Math.round(flowCacheData.getValue())); } Set<Pair<ConsEpgKey, ProvEpgKey>> epgsForContract = OFStatisticsManager.getEpgsForContract(contractId); Set<EpgKey> epgsFromSrcEp = getEpgsFromEndpoint(srcEpL3); Set<EpgKey> epgsFromDstEp = getEpgsFromEndpoint(dstEpL3); Pair<? extends EpgKey, ? extends EpgKey> leftSrcEpgRightDstEpg = getMatchingEpgs(epgsForContract, epgsFromSrcEp, epgsFromDstEp, flowCache.getDirection()); if (leftSrcEpgRightDstEpg == null) { LOG.info("Stats are skipped for {}", flowCacheData); continue; } EpEpgToEpEpgStatistic epEpgToEpEpgStats = new EpEpgToEpEpgStatisticBuilder() .setSrcEpg(leftSrcEpgRightDstEpg.getLeft().getEpgId()) .setDstEpg(leftSrcEpgRightDstEpg.getRight().getEpgId()) .setMatchedRuleStatistic(ImmutableList.of(matchedRuleStatisticBuilder.build())) .build(); EpToEpStatistic e2e = new EpToEpStatisticBuilder().setSrcL2c(srcEpL3.getL2Context()) .setSrcMacAddress(srcEpL3.getMacAddress()) .setSrcTenant(srcEpL3.getTenant()) .setDstL2c(dstEpL3.getL2Context()) .setDstMacAddress(dstEpL3.getMacAddress()) .setDstTenant(dstEpL3.getTenant()) .setEpEpgToEpEpgStatistic(ImmutableList.of(epEpgToEpEpgStats)) .setTimestamp(timestamp) .build(); StatRecords statRecords = new StatRecordsBuilder().setEpToEpStatistic(ImmutableList.of(e2e)).build(); if (LOG.isTraceEnabled()) { LOG.trace("[sflow] writing StatRecords: {}", statRecords); } statisticsManager.writeStat(statRecords); } } } ProcessDataTask(FlowCache flowCache, List<FlowCacheData> dataList, BigInteger timestamp,
            StatisticsManager statisticsManager); }
ProcessDataTask implements Runnable { @Override public void run() { for (FlowCacheData flowCacheData : dataList) { Map<String, String> flowCacheDataMap = createFlowCacheDataMap(flowCacheData); if (flowCacheDataMap == null) { LOG.info("Stats are skipped for {}", flowCacheData); continue; } String srcIp = flowCacheDataMap.get(FlowCacheCons.Key.IP_SOURCE.get()); String dstIp = flowCacheDataMap.get(FlowCacheCons.Key.IP_DESTINATION.get()); EndpointL3 srcEpL3 = OFStatisticsManager.getEndpointL3ForIp(srcIp); EndpointL3 dstEpL3 = OFStatisticsManager.getEndpointL3ForIp(dstIp); if (srcEpL3 != null && dstEpL3 != null) { ContractId contractId = IidSflowNameUtil.resolveContractIdFromFlowCacheName(flowCache.getName()); MatchedRuleStatisticBuilder matchedRuleStatisticBuilder = new MatchedRuleStatisticBuilder() .setContract(contractId) .setSubject(IidSflowNameUtil.resolveSubjectNameFromFlowCacheName(flowCache.getName())) .setMatchedRule(IidSflowNameUtil.resolveRuleNameFromFlowCacheName(flowCache.getName())) .setClassifier(ImmutableList .of(IidSflowNameUtil.resolveClassifierNameFromFlowCacheName(flowCache.getName()))); if (FlowCacheCons.Value.BYTES.get().equals(IidSflowNameUtil.resolveFlowCacheValue(flowCache.getName()))) { matchedRuleStatisticBuilder.setByteCount(Math.round(flowCacheData.getValue())); } else if (FlowCacheCons.Value.FRAMES.get().equals(IidSflowNameUtil.resolveFlowCacheValue(flowCache.getName()))) { matchedRuleStatisticBuilder.setPacketCount(Math.round(flowCacheData.getValue())); } Set<Pair<ConsEpgKey, ProvEpgKey>> epgsForContract = OFStatisticsManager.getEpgsForContract(contractId); Set<EpgKey> epgsFromSrcEp = getEpgsFromEndpoint(srcEpL3); Set<EpgKey> epgsFromDstEp = getEpgsFromEndpoint(dstEpL3); Pair<? extends EpgKey, ? extends EpgKey> leftSrcEpgRightDstEpg = getMatchingEpgs(epgsForContract, epgsFromSrcEp, epgsFromDstEp, flowCache.getDirection()); if (leftSrcEpgRightDstEpg == null) { LOG.info("Stats are skipped for {}", flowCacheData); continue; } EpEpgToEpEpgStatistic epEpgToEpEpgStats = new EpEpgToEpEpgStatisticBuilder() .setSrcEpg(leftSrcEpgRightDstEpg.getLeft().getEpgId()) .setDstEpg(leftSrcEpgRightDstEpg.getRight().getEpgId()) .setMatchedRuleStatistic(ImmutableList.of(matchedRuleStatisticBuilder.build())) .build(); EpToEpStatistic e2e = new EpToEpStatisticBuilder().setSrcL2c(srcEpL3.getL2Context()) .setSrcMacAddress(srcEpL3.getMacAddress()) .setSrcTenant(srcEpL3.getTenant()) .setDstL2c(dstEpL3.getL2Context()) .setDstMacAddress(dstEpL3.getMacAddress()) .setDstTenant(dstEpL3.getTenant()) .setEpEpgToEpEpgStatistic(ImmutableList.of(epEpgToEpEpgStats)) .setTimestamp(timestamp) .build(); StatRecords statRecords = new StatRecordsBuilder().setEpToEpStatistic(ImmutableList.of(e2e)).build(); if (LOG.isTraceEnabled()) { LOG.trace("[sflow] writing StatRecords: {}", statRecords); } statisticsManager.writeStat(statRecords); } } } ProcessDataTask(FlowCache flowCache, List<FlowCacheData> dataList, BigInteger timestamp,
            StatisticsManager statisticsManager); @Override void run(); }
ProcessDataTask implements Runnable { @Override public void run() { for (FlowCacheData flowCacheData : dataList) { Map<String, String> flowCacheDataMap = createFlowCacheDataMap(flowCacheData); if (flowCacheDataMap == null) { LOG.info("Stats are skipped for {}", flowCacheData); continue; } String srcIp = flowCacheDataMap.get(FlowCacheCons.Key.IP_SOURCE.get()); String dstIp = flowCacheDataMap.get(FlowCacheCons.Key.IP_DESTINATION.get()); EndpointL3 srcEpL3 = OFStatisticsManager.getEndpointL3ForIp(srcIp); EndpointL3 dstEpL3 = OFStatisticsManager.getEndpointL3ForIp(dstIp); if (srcEpL3 != null && dstEpL3 != null) { ContractId contractId = IidSflowNameUtil.resolveContractIdFromFlowCacheName(flowCache.getName()); MatchedRuleStatisticBuilder matchedRuleStatisticBuilder = new MatchedRuleStatisticBuilder() .setContract(contractId) .setSubject(IidSflowNameUtil.resolveSubjectNameFromFlowCacheName(flowCache.getName())) .setMatchedRule(IidSflowNameUtil.resolveRuleNameFromFlowCacheName(flowCache.getName())) .setClassifier(ImmutableList .of(IidSflowNameUtil.resolveClassifierNameFromFlowCacheName(flowCache.getName()))); if (FlowCacheCons.Value.BYTES.get().equals(IidSflowNameUtil.resolveFlowCacheValue(flowCache.getName()))) { matchedRuleStatisticBuilder.setByteCount(Math.round(flowCacheData.getValue())); } else if (FlowCacheCons.Value.FRAMES.get().equals(IidSflowNameUtil.resolveFlowCacheValue(flowCache.getName()))) { matchedRuleStatisticBuilder.setPacketCount(Math.round(flowCacheData.getValue())); } Set<Pair<ConsEpgKey, ProvEpgKey>> epgsForContract = OFStatisticsManager.getEpgsForContract(contractId); Set<EpgKey> epgsFromSrcEp = getEpgsFromEndpoint(srcEpL3); Set<EpgKey> epgsFromDstEp = getEpgsFromEndpoint(dstEpL3); Pair<? extends EpgKey, ? extends EpgKey> leftSrcEpgRightDstEpg = getMatchingEpgs(epgsForContract, epgsFromSrcEp, epgsFromDstEp, flowCache.getDirection()); if (leftSrcEpgRightDstEpg == null) { LOG.info("Stats are skipped for {}", flowCacheData); continue; } EpEpgToEpEpgStatistic epEpgToEpEpgStats = new EpEpgToEpEpgStatisticBuilder() .setSrcEpg(leftSrcEpgRightDstEpg.getLeft().getEpgId()) .setDstEpg(leftSrcEpgRightDstEpg.getRight().getEpgId()) .setMatchedRuleStatistic(ImmutableList.of(matchedRuleStatisticBuilder.build())) .build(); EpToEpStatistic e2e = new EpToEpStatisticBuilder().setSrcL2c(srcEpL3.getL2Context()) .setSrcMacAddress(srcEpL3.getMacAddress()) .setSrcTenant(srcEpL3.getTenant()) .setDstL2c(dstEpL3.getL2Context()) .setDstMacAddress(dstEpL3.getMacAddress()) .setDstTenant(dstEpL3.getTenant()) .setEpEpgToEpEpgStatistic(ImmutableList.of(epEpgToEpEpgStats)) .setTimestamp(timestamp) .build(); StatRecords statRecords = new StatRecordsBuilder().setEpToEpStatistic(ImmutableList.of(e2e)).build(); if (LOG.isTraceEnabled()) { LOG.trace("[sflow] writing StatRecords: {}", statRecords); } statisticsManager.writeStat(statRecords); } } } ProcessDataTask(FlowCache flowCache, List<FlowCacheData> dataList, BigInteger timestamp,
            StatisticsManager statisticsManager); @Override void run();  }