@Test public void testFlowTracesToRowsMaxTraces() { Flow flow = Flow.builder().setIngressNode("node").setDstIp(Ip.parse("1.1.1.1")).build(); SortedMap<Flow, List<Trace>> flowTraces = ImmutableSortedMap.of( flow, ImmutableList.of( new Trace(FlowDisposition.DENIED_OUT, ImmutableList.of()), new Trace(FlowDisposition.DENIED_IN, ImmutableList.of()))); Multiset<Row> rows = flowTracesToRows(flowTraces, 1); assertThat( rows.iterator().next(), allOf( hasColumn( COL_FLOW, allOf(hasDstIp(Ip.parse("1.1.1.1")), hasIngressNode("node")), Schema.FLOW), hasColumn(COL_TRACES, hasSize(1), Schema.set(Schema.TRACE)), hasColumn(TracerouteAnswerer.COL_TRACE_COUNT, equalTo(2), Schema.INTEGER))); }
public static Multiset<Row> flowTracesToRows( SortedMap<Flow, List<Trace>> flowTraces, int maxTraces) { Multiset<Row> rows = LinkedHashMultiset.create(); for (Map.Entry<Flow, List<Trace>> flowTrace : flowTraces.entrySet()) { List<Trace> traces = flowTrace.getValue(); List<Trace> prunedTraces = TracePruner.prune(traces, maxTraces); rows.add( Row.of( COL_FLOW, flowTrace.getKey(), COL_TRACES, prunedTraces, COL_TRACE_COUNT, traces.size())); } return rows; }
TracerouteAnswerer extends Answerer { public static Multiset<Row> flowTracesToRows( SortedMap<Flow, List<Trace>> flowTraces, int maxTraces) { Multiset<Row> rows = LinkedHashMultiset.create(); for (Map.Entry<Flow, List<Trace>> flowTrace : flowTraces.entrySet()) { List<Trace> traces = flowTrace.getValue(); List<Trace> prunedTraces = TracePruner.prune(traces, maxTraces); rows.add( Row.of( COL_FLOW, flowTrace.getKey(), COL_TRACES, prunedTraces, COL_TRACE_COUNT, traces.size())); } return rows; } }
TracerouteAnswerer extends Answerer { public static Multiset<Row> flowTracesToRows( SortedMap<Flow, List<Trace>> flowTraces, int maxTraces) { Multiset<Row> rows = LinkedHashMultiset.create(); for (Map.Entry<Flow, List<Trace>> flowTrace : flowTraces.entrySet()) { List<Trace> traces = flowTrace.getValue(); List<Trace> prunedTraces = TracePruner.prune(traces, maxTraces); rows.add( Row.of( COL_FLOW, flowTrace.getKey(), COL_TRACES, prunedTraces, COL_TRACE_COUNT, traces.size())); } return rows; } TracerouteAnswerer(Question question, IBatfish batfish); }
TracerouteAnswerer extends Answerer { public static Multiset<Row> flowTracesToRows( SortedMap<Flow, List<Trace>> flowTraces, int maxTraces) { Multiset<Row> rows = LinkedHashMultiset.create(); for (Map.Entry<Flow, List<Trace>> flowTrace : flowTraces.entrySet()) { List<Trace> traces = flowTrace.getValue(); List<Trace> prunedTraces = TracePruner.prune(traces, maxTraces); rows.add( Row.of( COL_FLOW, flowTrace.getKey(), COL_TRACES, prunedTraces, COL_TRACE_COUNT, traces.size())); } return rows; } TracerouteAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); @Override AnswerElement answerDiff(NetworkSnapshot snapshot, NetworkSnapshot reference); static TableMetadata metadata(boolean differential); static Multiset<Row> flowTracesToRows(
      SortedMap<Flow, List<Trace>> flowTraces, int maxTraces); static Multiset<Row> diffFlowTracesToRows(
      Map<Flow, List<Trace>> baseFlowTraces,
      Map<Flow, List<Trace>> deltaFlowTraces,
      int maxTraces); }
TracerouteAnswerer extends Answerer { public static Multiset<Row> flowTracesToRows( SortedMap<Flow, List<Trace>> flowTraces, int maxTraces) { Multiset<Row> rows = LinkedHashMultiset.create(); for (Map.Entry<Flow, List<Trace>> flowTrace : flowTraces.entrySet()) { List<Trace> traces = flowTrace.getValue(); List<Trace> prunedTraces = TracePruner.prune(traces, maxTraces); rows.add( Row.of( COL_FLOW, flowTrace.getKey(), COL_TRACES, prunedTraces, COL_TRACE_COUNT, traces.size())); } return rows; } TracerouteAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); @Override AnswerElement answerDiff(NetworkSnapshot snapshot, NetworkSnapshot reference); static TableMetadata metadata(boolean differential); static Multiset<Row> flowTracesToRows(
      SortedMap<Flow, List<Trace>> flowTraces, int maxTraces); static Multiset<Row> diffFlowTracesToRows(
      Map<Flow, List<Trace>> baseFlowTraces,
      Map<Flow, List<Trace>> deltaFlowTraces,
      int maxTraces); static final String COL_FLOW; static final String COL_TRACES; static final String COL_TRACE_COUNT; static final String COL_BASE_TRACES; static final String COL_DELTA_TRACES; static final String COL_BASE_TRACE_COUNT; static final String COL_DELTA_TRACE_COUNT; }