/** * Opens respective mediator logs in case of a continuation call. * * @param messageId message uuid which corresponds to the continuation flow. * @param componentId component name */ public void openLogForContinuation(String messageId, String componentId) { if (continuationStateMap.containsKey(messageId)) { ContinuationStateHolder continuationStateHolder = continuationStateMap.get(messageId); int continuationIndex = continuationStateHolder.getCallbackPoint(); Integer componentIndex = null; while (continuationIndex > continuationStateHolder.getContinuationStackPosition()) { StatisticsLog statisticsLog = messageFlowLogs.get(continuationIndex); if (statisticsLog.getComponentId().equals(componentId)) { componentIndex = continuationIndex; } continuationIndex = statisticsLog.getParentLevel(); } if (componentIndex != null) { openLogs.addFirst(componentIndex); messageFlowLogs.get(componentIndex).setIsOpenedByContinuation(true); continuationStateHolder.setContinuationStackPosition(componentIndex); } else { if (log.isDebugEnabled()) { log.error("No log found to match the continuation component Id:" + componentId); } } } else { if (log.isDebugEnabled()) { log.debug("No continuation information found in statistic trace for this message Id."); } } }
/** * Closes opened statistics log specified by the componentLevel. * * @param componentLevel index of the closing statistic log in messageFlowLogs * @param endTime endTime of the closing statistics log */ private void closeStatisticLog(int componentLevel, Long endTime) { StatisticsLog currentLog = messageFlowLogs.get(componentLevel); if (log.isDebugEnabled()) { log.debug( "Closed statistic log of [ElementId" + currentLog.getComponentId() + "][MsgId" + currentLog.getParentMsgId()); } currentLog.setEndTime(endTime); updateParentLogs(currentLog.getParentLevel(), endTime); }
/** * 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() + "]"); } }