Esempio n. 1
0
  private TracedCallAO mapTracedCall(CurrentlyTracedCall useCase, TimeUnit unit) {
    TraceStep root = useCase.getRootStep();
    TracedCallAO ret = new TracedCallAO();
    ret.setName(useCase.getName());
    ret.setCreated(useCase.getCreated());
    ret.setDate(NumberUtils.makeISO8601TimestampString(useCase.getCreated()));

    JourneyCallIntermediateContainer container = new JourneyCallIntermediateContainer();
    fillUseCasePathElementBeanList(container, root, 0, unit);
    ret.setElements(container.getElements());

    // check for duplicates
    List<TracedCallDuplicateStepsAO> dupSteps = new ArrayList<TracedCallDuplicateStepsAO>();
    Map<String, JourneyCallIntermediateContainer.ReversedCallHelper> stepsReversed =
        container.getReversedSteps();
    for (Map.Entry<String, JourneyCallIntermediateContainer.ReversedCallHelper> entry :
        stepsReversed.entrySet()) {
      if (entry.getValue() != null && entry.getValue().getPositions().size() > 1) {
        // duplicate found
        TracedCallDuplicateStepsAO dupStep = new TracedCallDuplicateStepsAO();
        dupStep.setCall(entry.getKey());
        dupStep.setPositions(entry.getValue().getPositions());
        dupStep.setTimespent(entry.getValue().getTimespent());
        dupStep.setDuration(entry.getValue().getDuration());
        dupSteps.add(dupStep);
      }
    }

    ret.setDuplicateSteps(dupSteps);

    return ret;
  }
Esempio n. 2
0
  @Override
  public List<JourneyListItemAO> getJourneys() throws APIException {
    List<Journey> journeys = journeyManager.getJourneys();
    List<JourneyListItemAO> beans = new ArrayList<JourneyListItemAO>(journeys.size());

    for (Journey j : journeys) {
      JourneyListItemAO bean = new JourneyListItemAO();

      bean.setName(j.getName());
      bean.setActive(j.isActive());
      bean.setCreated(NumberUtils.makeISO8601TimestampString(j.getCreatedTimestamp()));
      bean.setLastActivity(NumberUtils.makeISO8601TimestampString(j.getLastActivityTimestamp()));
      bean.setNumberOfCalls(j.getTracedCalls().size());
      beans.add(bean);
    }

    return beans;
  }
Esempio n. 3
0
 /**
  * Convert {@link net.anotheria.moskito.core.threshold.alerts.ThresholdAlert} to plain text.
  *
  * @param thresholdAlert {@link net.anotheria.moskito.core.threshold.alerts.ThresholdAlert}.
  * @return threshold alert plain text.
  */
 public static String toPlainText(ThresholdAlert thresholdAlert) {
   String text = "Threshold alert:\n";
   text += "Timestamp: " + thresholdAlert.getTimestamp() + "\n";
   text +=
       "ISO Timestamp: "
           + NumberUtils.makeISO8601TimestampString(thresholdAlert.getTimestamp())
           + "\n";
   text += "Threshold: " + thresholdAlert.getThreshold().getName() + "\n";
   text += "OldStatus: " + thresholdAlert.getOldStatus() + "\n";
   text += "NewStatus: " + thresholdAlert.getNewStatus() + "\n";
   text += "OldValue: " + thresholdAlert.getOldValue() + "\n";
   text += "NewValue: " + thresholdAlert.getNewValue() + "\n";
   return text;
 }
Esempio n. 4
0
  @Override
  public JourneyAO getJourney(String name) throws APIException {
    JourneyAO ret = new JourneyAO();
    Journey journey;
    try {
      journey = journeyManager.getJourney(name);
    } catch (NoSuchJourneyException e) {
      throw new APIException("Journey not found.");
    }

    ret.setName(journey.getName());
    ret.setActive(journey.isActive());
    ret.setCreatedTimestamp(journey.getCreatedTimestamp());
    ret.setLastActivityTimestamp(journey.getLastActivityTimestamp());

    List<CurrentlyTracedCall> recorded = journey.getTracedCalls();
    List<JourneySingleTracedCallAO> calls =
        new ArrayList<JourneySingleTracedCallAO>(recorded.size());
    for (int i = 0; i < recorded.size(); i++) {
      CurrentlyTracedCall tracedCall = recorded.get(i);
      if (tracedCall == null) {
        // this is a WTF, how could a null get added here in first place.
        log.warn("Unexpected null as tracedCall at position " + i);
        continue;
      }
      JourneySingleTracedCallAO b = new JourneySingleTracedCallAO();
      b.setName(tracedCall.getName());
      b.setDate(NumberUtils.makeISO8601TimestampString(tracedCall.getCreated()));
      b.setContainedSteps(tracedCall.getNumberOfSteps());
      b.setDuration(tracedCall.getRootStep().getDuration());
      calls.add(b);
    }

    ret.setCalls(calls);

    return ret;
  }