@Test public void testMetadata() { List<ColumnMetadata> columnMetadata = metadata(false).getColumnMetadata(); assertThat( columnMetadata.stream() .map(ColumnMetadata::getName) .collect(ImmutableList.toImmutableList()), contains(COL_FLOW, COL_TRACES, COL_TRACE_COUNT)); assertThat( columnMetadata.stream() .map(ColumnMetadata::getSchema) .collect(ImmutableList.toImmutableList()), contains(Schema.FLOW, Schema.set(Schema.TRACE), Schema.INTEGER)); List<ColumnMetadata> diffColumnMetadata = metadata(true).getColumnMetadata(); assertThat( diffColumnMetadata.stream() .map(ColumnMetadata::getName) .collect(ImmutableList.toImmutableList()), contains( COL_FLOW, TracerouteAnswerer.COL_BASE_TRACES, TracerouteAnswerer.COL_BASE_TRACE_COUNT, TracerouteAnswerer.COL_DELTA_TRACES, TracerouteAnswerer.COL_DELTA_TRACE_COUNT)); assertThat( diffColumnMetadata.stream() .map(ColumnMetadata::getSchema) .collect(ImmutableList.toImmutableList()), contains( Schema.FLOW, Schema.set(Schema.TRACE), Schema.INTEGER, Schema.set(Schema.TRACE), Schema.INTEGER)); }
public static TableMetadata metadata(boolean differential) { List<ColumnMetadata> columnMetadata; if (differential) { columnMetadata = ImmutableList.of( new ColumnMetadata(COL_FLOW, Schema.FLOW, "The flow", true, false), new ColumnMetadata( TableDiff.baseColumnName(COL_TRACES), Schema.set(Schema.TRACE), "The traces in the BASE snapshot", false, true), new ColumnMetadata( TableDiff.baseColumnName(COL_TRACE_COUNT), Schema.INTEGER, "The total number traces in the BASE snapshot", false, true), new ColumnMetadata( TableDiff.deltaColumnName(COL_TRACES), Schema.set(Schema.TRACE), "The traces in the DELTA snapshot", false, true), new ColumnMetadata( TableDiff.deltaColumnName(COL_TRACE_COUNT), Schema.INTEGER, "The total number traces in the DELTA snapshot", false, true)); } else { columnMetadata = ImmutableList.of( new ColumnMetadata(COL_FLOW, Schema.FLOW, "The flow", true, false), new ColumnMetadata( COL_TRACES, Schema.set(Schema.TRACE), "The traces for this flow", false, true), new ColumnMetadata( COL_TRACE_COUNT, Schema.INTEGER, "The total number traces for this flow", false, true)); } return new TableMetadata(columnMetadata, String.format("Paths for flow ${%s}", COL_FLOW)); }
TracerouteAnswerer extends Answerer { public static TableMetadata metadata(boolean differential) { List<ColumnMetadata> columnMetadata; if (differential) { columnMetadata = ImmutableList.of( new ColumnMetadata(COL_FLOW, Schema.FLOW, "The flow", true, false), new ColumnMetadata( TableDiff.baseColumnName(COL_TRACES), Schema.set(Schema.TRACE), "The traces in the BASE snapshot", false, true), new ColumnMetadata( TableDiff.baseColumnName(COL_TRACE_COUNT), Schema.INTEGER, "The total number traces in the BASE snapshot", false, true), new ColumnMetadata( TableDiff.deltaColumnName(COL_TRACES), Schema.set(Schema.TRACE), "The traces in the DELTA snapshot", false, true), new ColumnMetadata( TableDiff.deltaColumnName(COL_TRACE_COUNT), Schema.INTEGER, "The total number traces in the DELTA snapshot", false, true)); } else { columnMetadata = ImmutableList.of( new ColumnMetadata(COL_FLOW, Schema.FLOW, "The flow", true, false), new ColumnMetadata( COL_TRACES, Schema.set(Schema.TRACE), "The traces for this flow", false, true), new ColumnMetadata( COL_TRACE_COUNT, Schema.INTEGER, "The total number traces for this flow", false, true)); } return new TableMetadata(columnMetadata, String.format("Paths for flow ${%s}", COL_FLOW)); } }
TracerouteAnswerer extends Answerer { public static TableMetadata metadata(boolean differential) { List<ColumnMetadata> columnMetadata; if (differential) { columnMetadata = ImmutableList.of( new ColumnMetadata(COL_FLOW, Schema.FLOW, "The flow", true, false), new ColumnMetadata( TableDiff.baseColumnName(COL_TRACES), Schema.set(Schema.TRACE), "The traces in the BASE snapshot", false, true), new ColumnMetadata( TableDiff.baseColumnName(COL_TRACE_COUNT), Schema.INTEGER, "The total number traces in the BASE snapshot", false, true), new ColumnMetadata( TableDiff.deltaColumnName(COL_TRACES), Schema.set(Schema.TRACE), "The traces in the DELTA snapshot", false, true), new ColumnMetadata( TableDiff.deltaColumnName(COL_TRACE_COUNT), Schema.INTEGER, "The total number traces in the DELTA snapshot", false, true)); } else { columnMetadata = ImmutableList.of( new ColumnMetadata(COL_FLOW, Schema.FLOW, "The flow", true, false), new ColumnMetadata( COL_TRACES, Schema.set(Schema.TRACE), "The traces for this flow", false, true), new ColumnMetadata( COL_TRACE_COUNT, Schema.INTEGER, "The total number traces for this flow", false, true)); } return new TableMetadata(columnMetadata, String.format("Paths for flow ${%s}", COL_FLOW)); } TracerouteAnswerer(Question question, IBatfish batfish); }
TracerouteAnswerer extends Answerer { public static TableMetadata metadata(boolean differential) { List<ColumnMetadata> columnMetadata; if (differential) { columnMetadata = ImmutableList.of( new ColumnMetadata(COL_FLOW, Schema.FLOW, "The flow", true, false), new ColumnMetadata( TableDiff.baseColumnName(COL_TRACES), Schema.set(Schema.TRACE), "The traces in the BASE snapshot", false, true), new ColumnMetadata( TableDiff.baseColumnName(COL_TRACE_COUNT), Schema.INTEGER, "The total number traces in the BASE snapshot", false, true), new ColumnMetadata( TableDiff.deltaColumnName(COL_TRACES), Schema.set(Schema.TRACE), "The traces in the DELTA snapshot", false, true), new ColumnMetadata( TableDiff.deltaColumnName(COL_TRACE_COUNT), Schema.INTEGER, "The total number traces in the DELTA snapshot", false, true)); } else { columnMetadata = ImmutableList.of( new ColumnMetadata(COL_FLOW, Schema.FLOW, "The flow", true, false), new ColumnMetadata( COL_TRACES, Schema.set(Schema.TRACE), "The traces for this flow", false, true), new ColumnMetadata( COL_TRACE_COUNT, Schema.INTEGER, "The total number traces for this flow", false, true)); } return new TableMetadata(columnMetadata, String.format("Paths for flow ${%s}", COL_FLOW)); } 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 TableMetadata metadata(boolean differential) { List<ColumnMetadata> columnMetadata; if (differential) { columnMetadata = ImmutableList.of( new ColumnMetadata(COL_FLOW, Schema.FLOW, "The flow", true, false), new ColumnMetadata( TableDiff.baseColumnName(COL_TRACES), Schema.set(Schema.TRACE), "The traces in the BASE snapshot", false, true), new ColumnMetadata( TableDiff.baseColumnName(COL_TRACE_COUNT), Schema.INTEGER, "The total number traces in the BASE snapshot", false, true), new ColumnMetadata( TableDiff.deltaColumnName(COL_TRACES), Schema.set(Schema.TRACE), "The traces in the DELTA snapshot", false, true), new ColumnMetadata( TableDiff.deltaColumnName(COL_TRACE_COUNT), Schema.INTEGER, "The total number traces in the DELTA snapshot", false, true)); } else { columnMetadata = ImmutableList.of( new ColumnMetadata(COL_FLOW, Schema.FLOW, "The flow", true, false), new ColumnMetadata( COL_TRACES, Schema.set(Schema.TRACE), "The traces for this flow", false, true), new ColumnMetadata( COL_TRACE_COUNT, Schema.INTEGER, "The total number traces for this flow", false, true)); } return new TableMetadata(columnMetadata, String.format("Paths for flow ${%s}", COL_FLOW)); } 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; }