/** * {@inheritDoc} */ @Override public int hashCode() { final int prime = 31; int result = 1; result = (prime * result) + ((this.diagnosisTimerData == null) ? 0 : this.diagnosisTimerData.hashCode()); result = (prime * result) + (int) (this.invocationId ^ (this.invocationId >>> 32)); result = (prime * result) + (int) (this.methodIdent ^ (this.methodIdent >>> 32)); return result; }
/** * {@inheritDoc} */ @Override public int hashCode() { final int prime = 31; int result = 1; result = (prime * result) + (int) (this.methodIdent ^ (this.methodIdent >>> 32)); result = (prime * result) + ((this.aggregatedDiagnosisTimerData == null) ? 0 : this.aggregatedDiagnosisTimerData.hashCode()); return result; }
@BeforeMethod public void init() { when(problemOccurrence.getApplicationNameIdent()).thenReturn(APP_ID); when(problemOccurrence.getBusinessTransactionNameIdent()).thenReturn(BUSINESS_TX_ID); when(problemOccurrence.getProblemContext()).thenReturn(invocationIdentifier); when(problemOccurrence.getRequestRoot()).thenReturn(invocationIdentifier); when(problemOccurrence.getGlobalContext()).thenReturn(invocationIdentifier); when(problemOccurrence.getCauseType()).thenReturn(causeType); when(problemOccurrence.getSourceType()).thenReturn(sourceType); when(problemOccurrence.getRootCause()).thenReturn(rootCause); when(invocationIdentifier.getDiagnosisTimerData()).thenReturn(diagnosisTimerData); when(rootCause.getAggregatedDiagnosisTimerData()).thenReturn(aggregatedDiagnosisTimerData); when(diagnosisTimerData.getDuration()).thenReturn(DURATION); when(diagnosisTimerData.getExclusiveDuration()).thenReturn(EXCLUSIVE_DURATION); when(aggregatedDiagnosisTimerData.getExclusiveDuration()).thenReturn(EXCLUSIVE_DURATION); when(applicationData.getName()).thenReturn(APPLICATION_NAME); when(businessTransactionData.getName()).thenReturn(BUSINESS_TX); when(methodIdent.getMethodName()).thenReturn(METHOD); when(methodIdent.getFQN()).thenReturn(FQN); }
/** * Add fields to builder. * * @param data * ProblemOccurrence instance * @param builder * Builder that can be used to create influx points. */ protected void addFields(ProblemOccurrence data, Builder builder) { builder.addField(Series.ProblemOccurrenceInformation.FIELD_INVOCATION_ROOT_DURATION, data.getRequestRoot().getDiagnosisTimerData().getDuration()); builder.addField(Series.ProblemOccurrenceInformation.FIELD_GLOBAL_CONTEXT_METHOD_EXCLUSIVE_TIME, data.getGlobalContext().getDiagnosisTimerData().getExclusiveDuration()); builder.addField(Series.ProblemOccurrenceInformation.FIELD_ROOTCAUSE_METHOD_EXCLUSIVE_TIME, data.getRootCause().getAggregatedDiagnosisTimerData().getExclusiveDuration()); builder.addField(Series.ProblemOccurrenceInformation.FIELD_ROOTCAUSE_METHOD_EXCLUSIVE_COUNT, data.getRootCause().getAggregatedDiagnosisTimerData().getExclusiveCount()); }
BusinessTransactionData businessTx = cachedDataService.getBusinessTransactionForId(data.getApplicationNameIdent(), data.getBusinessTransactionNameIdent()); if (null != businessTx) { businessTxName = businessTx.getName(); ApplicationData applicationData = cachedDataService.getApplicationForId(data.getApplicationNameIdent()); if (applicationData != null) { applicationName = applicationData.getName(); MethodIdent problemContextMethodIdent = cachedDataService.getMethodIdentForId(data.getProblemContext().getMethodIdent()); if (problemContextMethodIdent != null) { problemContextName = problemContextMethodIdent.getFQN() + "." + problemContextMethodIdent.getMethodName(); MethodIdent rootCauseMethodIdent = cachedDataService.getMethodIdentForId(data.getRootCause().getMethodIdent()); if (rootCauseMethodIdent != null) { rootCauseName = rootCauseMethodIdent.getFQN() + "." + rootCauseMethodIdent.getMethodName(); builder.tag(Series.ProblemOccurrenceInformation.TAG_PROBLEM_CONTEXT_METHOD_NAME, problemContextName); builder.tag(Series.ProblemOccurrenceInformation.TAG_ROOTCAUSE_METHOD_NAME, rootCauseName); builder.tag(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_CAUSE_TYPE, data.getCauseType().toString()); builder.tag(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_SOURCE_TYPE, data.getSourceType().toString());
RootCause rootCause = new RootCause(rootCauseInvocations.get().getMethodIdent(), rootCauseInvocations.get().getAggregatedDiagnosisTimerData()); ProblemOccurrence problem = new ProblemOccurrence(inputInvocationSequence, globalContext.get(), problemContext.get().getCommonContext(), rootCause, causeStructure.get().getCauseType(), causeStructure.get().getSourceType()); problems.add(problem); RootCause rootCause = new RootCause(globalContext.get().getMethodIdent(), new AggregatedDiagnosisTimerData(InvocationSequenceDataHelper.getTimerDataOrSQLData(globalContext.get()))); ProblemOccurrence problem = new ProblemOccurrence(inputInvocationSequence, globalContext.get(), rootCause); problems.add(problem);
/** * {@inheritDoc} */ @Override public int hashCode() { final int prime = 31; int result = 1; result = (prime * result) + this.applicationNameIdent; result = (prime * result) + this.businessTransactionNameIdent; result = (prime * result) + ((this.causeType == null) ? 0 : this.causeType.hashCode()); result = (prime * result) + ((this.globalContext == null) ? 0 : this.globalContext.hashCode()); result = (prime * result) + ((this.problemContext == null) ? 0 : this.problemContext.hashCode()); result = (prime * result) + ((this.requestRoot == null) ? 0 : this.requestRoot.hashCode()); result = (prime * result) + ((this.rootCause == null) ? 0 : this.rootCause.hashCode()); result = (prime * result) + ((this.sourceType == null) ? 0 : this.sourceType.hashCode()); return result; }
/** * {@inheritDoc} */ @Override public int hashCode() { final int prime = 31; int result = 1; result = (prime * result) + ((this.aggregatedDiagnosisTimerData == null) ? 0 : this.aggregatedDiagnosisTimerData.hashCode()); result = (prime * result) + ((this.aggregationKey == null) ? 0 : this.aggregationKey.hashCode()); result = (prime * result) + (int) (this.methodIdent ^ (this.methodIdent >>> 32)); result = (prime * result) + ((this.rawInvocationsSequenceElements == null) ? 0 : this.rawInvocationsSequenceElements.hashCode()); result = (prime * result) + ((this.sourceType == null) ? 0 : this.sourceType.hashCode()); return result; }
/** * Sorts list with aggregated {@link InvocationSequenceData} with the help of the summed * up exclusive times. */ @Override public int compare(AggregatedDiagnosisData o1, AggregatedDiagnosisData o2) { return Double.compare(o2.getAggregatedDiagnosisTimerData().getExclusiveDuration(), o1.getAggregatedDiagnosisTimerData().getExclusiveDuration()); } });
@Test public void noApplicationData() throws Exception { when(cachedDataService.getApplicationForId(problemOccurrence.getApplicationNameIdent())).thenReturn(null); when(cachedDataService.getPlatformIdentForId(APP_ID)).thenReturn(null); when(cachedDataService.getBusinessTransactionForId(APP_ID, BUSINESS_TX_ID)).thenReturn(businessTransactionData); when(cachedDataService.getMethodIdentForId(invocationIdentifier.getMethodIdent())).thenReturn(methodIdent); Builder pointBuilder = builder.getBuilder(problemOccurrence); assertThat(getMeasurement(pointBuilder), is(Series.ProblemOccurrenceInformation.NAME)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_APPLICATION_NAME, String.valueOf(ApplicationDefinition.UNKNOWN_APP))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_BUSINESS_TRANSACTION_NAME, String.valueOf(BUSINESS_TX))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_PROBLEM_CONTEXT_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_ROOTCAUSE_METHOD_NAME, FQN + "." + METHOD)); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_CAUSE_TYPE, String.valueOf(causeType))); assertThat(getTags(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.TAG_CAUSESTRUCTURE_SOURCE_TYPE, String.valueOf(sourceType))); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_INVOCATION_ROOT_DURATION, DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_GLOBAL_CONTEXT_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); assertThat(getFields(pointBuilder), hasEntry(Series.ProblemOccurrenceInformation.FIELD_ROOTCAUSE_METHOD_EXCLUSIVE_TIME, EXCLUSIVE_DURATION)); }
return false; } else if (!this.globalContext.equals(other.globalContext)) { return false; return false; } else if (!this.problemContext.equals(other.problemContext)) { return false; return false; } else if (!this.requestRoot.equals(other.requestRoot)) { return false; return false; } else if (!this.rootCause.equals(other.rootCause)) { return false;
/** * {@inheritDoc} */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } RootCause other = (RootCause) obj; if (this.methodIdent != other.methodIdent) { return false; } if (this.aggregatedDiagnosisTimerData == null) { if (other.aggregatedDiagnosisTimerData != null) { return false; } } else if (!this.aggregatedDiagnosisTimerData.equals(other.aggregatedDiagnosisTimerData)) { return false; } return true; }
/** * Rule execution. * * @return DIAGNOSIS_TAG_CAUSE_STRUCTURE */ @Action(resultTag = RuleConstants.DIAGNOSIS_TAG_CAUSE_STRUCTURE) public CauseStructure action() { // In case there is just one Root Cause method. if (rootCause.size() == 1) { return new CauseStructure(CauseType.SINGLE, rootCause.getSourceType()); } // The Root Causes are called either recursive if (calculateMaxRecursionDepth() > 1) { return new CauseStructure(CauseType.RECURSIVE, rootCause.getSourceType()); // or iterative. } else { return new CauseStructure(CauseType.ITERATIVE, rootCause.getSourceType()); } }
@Test(expectedExceptions = IllegalArgumentException.class) public void expectedExceptionsIfTheCauseHasNoElements() { long methodIdentEqual = new Long(108); when(rootCause.getMethodIdent()).thenReturn(methodIdentEqual); when(rootCause.size()).thenReturn(0); CauseStructure causeStructure = causeStructureRule.action(); assert (causeStructure.getCauseType() == CauseType.SINGLE); }
/** * {@inheritDoc} */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } InvocationIdentifier other = (InvocationIdentifier) obj; if (this.diagnosisTimerData == null) { if (other.diagnosisTimerData != null) { return false; } } else if (!this.diagnosisTimerData.equals(other.diagnosisTimerData)) { return false; } if (this.invocationId != other.invocationId) { return false; } if (this.methodIdent != other.methodIdent) { return false; } return true; }
/** * Constructor that creates new ProblemOccurrence based on InvocationSequenceData. * * @param requestRoot * root InvocationSequenceData * @param globalContext * identified globalContext * @param rootCause * identified rootCauses */ public ProblemOccurrence(final InvocationSequenceData requestRoot, final InvocationSequenceData globalContext, final RootCause rootCause) { if (requestRoot == null) { throw new IllegalArgumentException("requestRoot cannot be null"); } if (globalContext == null) { throw new IllegalArgumentException("globalContext cannot be null"); } if (rootCause == null) { throw new IllegalArgumentException("rootCause cannot be null"); } this.businessTransactionNameIdent = requestRoot.getBusinessTransactionId(); this.applicationNameIdent = requestRoot.getApplicationId(); this.requestRoot = new InvocationIdentifier(requestRoot); this.globalContext = new InvocationIdentifier(globalContext); this.problemContext = new InvocationIdentifier(globalContext); this.rootCause = rootCause; this.causeType = CauseType.SINGLE; this.sourceType = SourceType.TIMERDATA; }
/** * Gets the most significant cluster in the list. * * @param causeClusters * List of clusters to get the most significant. * @return Returns the most significant cluster in the list. */ private CauseCluster getSignificantCluster(List<CauseCluster> causeClusters) { // Checks if there is already a cluster with higher duration ratio // from overallExclusiveDuration. CauseCluster significantCluster = getHighDurationCluster(causeClusters, timeWastingOperation.getAggregatedDiagnosisTimerData().getExclusiveDuration()); // Iterates as long as there is no significantCluster. while ((null == significantCluster) && !stopClustering) { calculateDistancesToNextCluster(causeClusters); causeClusters = mergeClusters(causeClusters); significantCluster = getHighDurationCluster(causeClusters, timeWastingOperation.getAggregatedDiagnosisTimerData().getExclusiveDuration()); } // This rule does not return the Problem Context directly, but the significant cluster. // The Problem Context is the deepest node in the invocation tree that subsumes all // InvocationSequenceData the significant cluster holds and can be accessed via // cluster.getCommonContext(). return significantCluster; }
/** * {@inheritDoc} */ @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); long temp; temp = Double.doubleToLongBits(this.exclusiveCount); result = (prime * result) + (int) (temp ^ (temp >>> 32)); return result; }
/** * {@inheritDoc} */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!super.equals(obj)) { return false; } if (getClass() != obj.getClass()) { return false; } AggregatedDiagnosisTimerData other = (AggregatedDiagnosisTimerData) obj; if (Double.doubleToLongBits(this.exclusiveCount) != Double.doubleToLongBits(other.exclusiveCount)) { return false; } return true; }