Exemplo n.º 1
0
 private void createNewCloneLog(StatisticDataUnit statisticDataUnit, int parentIndex) {
   StatisticsLog parentLog = messageFlowLogs.get(parentIndex);
   StatisticsLog statisticsLog =
       new StatisticsLog(statisticDataUnit, parentLog.getMsgId(), parentIndex);
   messageFlowLogs.add(statisticsLog);
   parentLog.setChildren(messageFlowLogs.size() - 1);
   openLogs.addFirst(messageFlowLogs.size() - 1);
   if (log.isDebugEnabled()) {
     log.debug(
         "Created statistic log for [ElementId|"
             + statisticDataUnit.getComponentId()
             + "]|[MsgId|"
             + statisticDataUnit.getCloneId()
             + "]");
   }
 }
Exemplo n.º 2
0
  /**
   * Create a new statistics log for the reported statistic event for given parameters.
   *
   * @param statisticDataUnit statistic data unit with raw data
   * @param parentIndex parentIndex of the statistic log
   */
  private void createNewLog(StatisticDataUnit statisticDataUnit, int parentIndex) {
    StatisticsLog parentLog = messageFlowLogs.get(parentIndex);

    StatisticsLog statisticsLog =
        new StatisticsLog(statisticDataUnit, parentLog.getMsgId(), parentIndex);

    Integer immediateParentFromMessageLogs =
        getImmediateParentFromMessageLogs(statisticsLog.getMsgId());

    if (immediateParentFromMessageLogs == null) {
      immediateParentFromMessageLogs = parentIndex;
    }

    StatisticsLog possibleParent = messageFlowLogs.get(immediateParentFromMessageLogs);
    Integer lastAggregateIndex = getImmediateAggregateIndex();
    StatisticsLog lastAggregateLog = null;
    if (lastAggregateIndex != null) {
      lastAggregateLog = messageFlowLogs.get(getImmediateAggregateIndex());
    }

    if (possibleParent.getImmediateChild() == null) {
      if (possibleParent.getChildren().size() == 0) {
        possibleParent.setImmediateChild(messageFlowLogs.size());
      } else {
        if (lastAggregateLog != null && lastAggregateLog.getImmediateChild() == null) {
          lastAggregateLog.setImmediateChild(messageFlowLogs.size());
          lastAggregateLog.setMsgId(statisticsLog.getMsgId());
        } else {
          log.error(
              "Trying to set branching tree for non clone ComponentId:"
                  + statisticDataUnit.getComponentId());
          possibleParent.setChildren(messageFlowLogs.size());
        }
      }
    } else {
      if (lastAggregateLog != null && lastAggregateLog.getImmediateChild() == null) {
        lastAggregateLog.setImmediateChild(messageFlowLogs.size());
        lastAggregateLog.setMsgId(statisticsLog.getMsgId());
      } else {
        if (possibleParent.getChildren().size() == 0) {
          possibleParent.setChildren(possibleParent.getImmediateChild());
          possibleParent.setImmediateChild(null);
          possibleParent.setChildren(messageFlowLogs.size());
          log.error(
              "Setting immediate child of the component:"
                  + possibleParent.getComponentId()
                  + " as branching child");
        } else {
          log.error("Unexpected unrecoverable error happened during statistics collection");
        }
      }
    }

    messageFlowLogs.add(statisticsLog);
    openLogs.addFirst(messageFlowLogs.size() - 1);
    if (log.isDebugEnabled()) {
      log.debug(
          "Created statistic log for [ElementId|"
              + statisticDataUnit.getComponentId()
              + "]|[MsgId|"
              + statisticDataUnit.getCloneId()
              + "]");
    }
  }