Пример #1
0
 private static boolean validStep(Output output) {
   if (!(output instanceof TracerouteOutput)) return false;
   TracerouteOutput to = (TracerouteOutput) output;
   if (to.getData().size() == 0) return false;
   TracerouteData data = to.getData().get(0);
   if (isPrivateIp(data.getFrom())) return false;
   return true;
 }
Пример #2
0
  protected static void loadMeasurement(int id) throws Exception {
    MeasurementGetResponse get = execute(service.measurements().get(String.valueOf(id)));

    Measurement measurement = get.getResult();
    if (measurement.getDescription().startsWith("MeasureRingNode")) {
      MeasurementResultResponse resultResp =
          execute(service.measurements().result(String.valueOf(id)));
      List<MeasurementResult> results = resultResp.getResult();
      for (MeasurementResult result : results) {

        List<TraceData> sections = new ArrayList<TraceData>();

        for (Output output : result.getOutputs()) {
          if (validStep(output)) {
            TracerouteOutput to = (TracerouteOutput) output;
            TracerouteData summary = summarize(to.getData());
            TraceData section = new TraceData();
            section.setToIp(summary.getFrom());

            TraceData validStart = validStart(sections, summary);

            if (validStart == null) {
              section.setFromIp(result.getFrom());
              section.setRtt(summary.getRoundTripTime());
            } else {
              section.setFromIp(validStart.getToIp());
              section.setRtt(summary.getRoundTripTime().subtract(validStart.getRttSource()));
            }
            section.setRttSource(summary.getRoundTripTime());
            section.setSourceIp(result.getFrom());
            sections.add(section);
          }
        }
        // Output section
        for (TraceData td : sections) {
          traceDataDao.save(td);
        }
      }
    }
  }