Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7231: JMC createReport for JMC8 Automated Analysis fails to evaluate several rules #302

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -83,27 +83,29 @@ public class GcLockerRule implements IRule {

private IResult getResult(
IItemCollection items, IPreferenceValueProvider valueProvider, IResultValueProvider resultProvider) {
GarbageCollectionsInfo aggregate = resultProvider.getResultValue(GarbageCollectionInfoRule.GC_INFO);
if (aggregate != null) {
int gcLockers = aggregate.getGcLockers();
if (gcLockers > 0) {
int gcCount = aggregate.getGcCount();
IQuantity limit = valueProvider.getPreferenceValue(GC_LOCKER_RATIO_LIMIT);
double ratio = gcLockers / gcCount;
double score = RulesToolkit.mapExp74(ratio, limit.doubleValue());
return ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.get(score))
.setSummary(Messages.getString(Messages.GcLockerRuleFactory_TEXT_INFO))
.setExplanation(Messages.getString(Messages.GcLockerRuleFactory_TEXT_INFO_LONG))
.addResult(TypedResult.SCORE, UnitLookup.NUMBER_UNITY.quantity(score))
.addResult(GC_LOCKER_RATIO, UnitLookup.PERCENT_UNITY.quantity(ratio)).build();
} else {
return ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.OK)
.setSummary(Messages.getString(Messages.GcLockerRuleFactory_TEXT_OK)).build();
if (resultProvider != null) {
GarbageCollectionsInfo aggregate = resultProvider.getResultValue(GarbageCollectionInfoRule.GC_INFO);
if (aggregate != null) {
int gcLockers = aggregate.getGcLockers();
if (gcLockers > 0) {
int gcCount = aggregate.getGcCount();
IQuantity limit = valueProvider.getPreferenceValue(GC_LOCKER_RATIO_LIMIT);
double ratio = gcLockers / gcCount;
double score = RulesToolkit.mapExp74(ratio, limit.doubleValue());
return ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.get(score))
.setSummary(Messages.getString(Messages.GcLockerRuleFactory_TEXT_INFO))
.setExplanation(Messages.getString(Messages.GcLockerRuleFactory_TEXT_INFO_LONG))
.addResult(TypedResult.SCORE, UnitLookup.NUMBER_UNITY.quantity(score))
.addResult(GC_LOCKER_RATIO, UnitLookup.PERCENT_UNITY.quantity(ratio)).build();
} else {
return ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.OK)
.setSummary(Messages.getString(Messages.GcLockerRuleFactory_TEXT_OK)).build();
}
}
} else {
return ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.NA)
.setSummary(Messages.getString(Messages.GcLockerRule_TEXT_NA)).build();
}
return ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.NA)
.setSummary(Messages.getString(Messages.GcLockerRule_TEXT_NA)).build();

}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -75,20 +75,28 @@ public RunnableFuture<IResult> createEvaluation(
FutureTask<IResult> evaluationTask = new FutureTask<>(new Callable<IResult>() {
@Override
public IResult call() throws Exception {
GarbageCollectionsInfo aggregate = resultProvider.getResultValue(GarbageCollectionInfoRule.GC_INFO);
if (aggregate.foundNonRequestedSerialOldGc()) {
CollectorType oldCollectorType = CollectorType.getOldCollectorType(items);
if (oldCollectorType == CollectorType.CMS) {
return ResultBuilder.createFor(GcStallRule.this, valueProvider).setSeverity(Severity.WARNING)
.setSummary(Messages.getString(Messages.SerialOldRuleFactory_TEXT_WARN_CMS))
.setExplanation(Messages.getString(Messages.SerialOldRuleFactory_TEXT_WARN_CMS_LONG))
.build();
} else if (oldCollectorType == CollectorType.G1_OLD) {
return ResultBuilder.createFor(GcStallRule.this, valueProvider).setSeverity(Severity.WARNING)
.setSummary(Messages.getString(Messages.SerialOldRuleFactory_TEXT_WARN_G1))
.setExplanation(Messages.getString(Messages.SerialOldRuleFactory_TEXT_WARN_G1_LONG))
.build();
if (resultProvider != null) {
GarbageCollectionsInfo aggregate = resultProvider.getResultValue(GarbageCollectionInfoRule.GC_INFO);
if (aggregate.foundNonRequestedSerialOldGc()) {
CollectorType oldCollectorType = CollectorType.getOldCollectorType(items);
if (oldCollectorType == CollectorType.CMS) {
return ResultBuilder.createFor(GcStallRule.this, valueProvider)
.setSeverity(Severity.WARNING)
.setSummary(Messages.getString(Messages.SerialOldRuleFactory_TEXT_WARN_CMS))
.setExplanation(
Messages.getString(Messages.SerialOldRuleFactory_TEXT_WARN_CMS_LONG))
.build();
} else if (oldCollectorType == CollectorType.G1_OLD) {
return ResultBuilder.createFor(GcStallRule.this, valueProvider)
.setSeverity(Severity.WARNING)
.setSummary(Messages.getString(Messages.SerialOldRuleFactory_TEXT_WARN_G1))
.setExplanation(Messages.getString(Messages.SerialOldRuleFactory_TEXT_WARN_G1_LONG))
.build();
}
}
} else {
return ResultBuilder.createFor(GcStallRule.this, valueProvider).setSeverity(Severity.NA)
.setSummary(Messages.getString(Messages.GcLockerRule_TEXT_NA)).build();
}
IQuantity c = items.getAggregate(Aggregators.count(null, null, JdkFilters.CONCURRENT_MODE_FAILURE));
if (c != null && c.clampedLongValueIn(NUMBER_UNITY) > 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -98,23 +98,29 @@ public IResult call() throws Exception {
private IResult getHeapInspectionResult(
IItemCollection items, IPreferenceValueProvider vp, IResultValueProvider rp) {
IQuantity limit = vp.getPreferenceValue(HEAP_INSPECTION_LIMIT);
GarbageCollectionsInfo aggregate = rp.getResultValue(GarbageCollectionInfoRule.GC_INFO);
if (aggregate.getObjectCountGCs() > 0) {
double score = RulesToolkit.mapExp74(aggregate.getObjectCountGCs(), limit.longValue());
String longMessage = Messages.getString(Messages.HeapInspectionGcRuleFactory_TEXT_INFO_LONG);
if (RulesToolkit.isEventsEnabled(items, JdkTypeIDs.OBJECT_COUNT)) {
longMessage += "\n" + Messages.getString(Messages.HeapInspectionGcRuleFactory_TEXT_INFO_LONG_JFR); //$NON-NLS-1$
if (rp != null) {
GarbageCollectionsInfo aggregate = rp.getResultValue(GarbageCollectionInfoRule.GC_INFO);
if (aggregate.getObjectCountGCs() > 0) {
double score = RulesToolkit.mapExp74(aggregate.getObjectCountGCs(), limit.longValue());
String longMessage = Messages.getString(Messages.HeapInspectionGcRuleFactory_TEXT_INFO_LONG);
if (RulesToolkit.isEventsEnabled(items, JdkTypeIDs.OBJECT_COUNT)) {
longMessage += "\n" + Messages.getString(Messages.HeapInspectionGcRuleFactory_TEXT_INFO_LONG_JFR); //$NON-NLS-1$
}
return ResultBuilder.createFor(this, vp).setSeverity(Severity.get(score))
.setSummary(Messages.getString(Messages.HeapInspectionGcRuleFactory_TEXT_INFO))
.setExplanation(longMessage)
.addResult(TypedResult.SCORE, UnitLookup.NUMBER_UNITY.quantity(score))
.addResult(OBJECT_COUNT_GCS, UnitLookup.NUMBER_UNITY.quantity(aggregate.getObjectCountGCs()))
.build();
} else {
return ResultBuilder.createFor(this, vp).setSeverity(Severity.OK)
.setSummary(Messages.getString(Messages.HeapInspectionGcRuleFactory_TEXT_OK))
.setExplanation(Messages.getString(Messages.HeapInspectionGcRuleFactory_TEXT_OK_LONG)).build();
}
return ResultBuilder.createFor(this, vp).setSeverity(Severity.get(score))
.setSummary(Messages.getString(Messages.HeapInspectionGcRuleFactory_TEXT_INFO))
.setExplanation(longMessage).addResult(TypedResult.SCORE, UnitLookup.NUMBER_UNITY.quantity(score))
.addResult(OBJECT_COUNT_GCS, UnitLookup.NUMBER_UNITY.quantity(aggregate.getObjectCountGCs()))
.build();
} else {
return ResultBuilder.createFor(this, vp).setSeverity(Severity.OK)
.setSummary(Messages.getString(Messages.HeapInspectionGcRuleFactory_TEXT_OK))
.setExplanation(Messages.getString(Messages.HeapInspectionGcRuleFactory_TEXT_OK_LONG)).build();
}

return ResultBuilder.createFor(this, vp).setSeverity(Severity.NA)
.setSummary(Messages.getString(Messages.GcLockerRule_TEXT_NA)).build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -195,7 +195,8 @@ protected IResult getResult(IItemCollection items, IPreferenceValueProvider vp,
IQuantity heapUsedRatio = null;
if (maxHeapSize != null) {
IQuantity avgHeapUsed = items.getAggregate(JdkAggregators.AVG_HEAP_USED_AFTER_GC);
heapUsedRatio = UnitLookup.PERCENT_UNITY.quantity(avgHeapUsed.ratioTo(maxHeapSize));
if (avgHeapUsed != null)
heapUsedRatio = UnitLookup.PERCENT_UNITY.quantity(avgHeapUsed.ratioTo(maxHeapSize));
heapInfo = Messages.getString(Messages.StringDeduplicationRule_RESULT_HEAP_USAGE);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -96,20 +96,24 @@ public IResult call() throws Exception {

private IResult getSystemGcResult(
IItemCollection items, IPreferenceValueProvider valueProvider, IResultValueProvider resultProvider) {
GarbageCollectionsInfo aggregate = resultProvider.getResultValue(GarbageCollectionInfoRule.GC_INFO);
IQuantity limit = valueProvider.getPreferenceValue(SYSTEM_GC_RATIO_LIMIT);
if (aggregate.getSystemGcCount() > 0) {
double systemGcRatio = aggregate.getSystemGcCount() / aggregate.getGcCount();
double score = RulesToolkit.mapExp100(systemGcRatio, limit.doubleValue());
return ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.get(score))
.setSummary(Messages.getString(Messages.SystemGcRuleFactory_TEXT_INFO))
.setExplanation(Messages.getString(Messages.SystemGcRuleFactory_TEXT_INFO_LONG))
.addResult(TypedResult.SCORE, UnitLookup.NUMBER_UNITY.quantity(score))
.addResult(SYSTEM_GC_RATIO, UnitLookup.PERCENT_UNITY.quantity(systemGcRatio)).build();
} else {
return ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.OK)
.setSummary(Messages.getString(Messages.SystemGcRuleFactory_TEXT_OK)).build();
if (resultProvider != null) {
GarbageCollectionsInfo aggregate = resultProvider.getResultValue(GarbageCollectionInfoRule.GC_INFO);
IQuantity limit = valueProvider.getPreferenceValue(SYSTEM_GC_RATIO_LIMIT);
if (aggregate.getSystemGcCount() > 0) {
double systemGcRatio = aggregate.getSystemGcCount() / aggregate.getGcCount();
double score = RulesToolkit.mapExp100(systemGcRatio, limit.doubleValue());
return ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.get(score))
.setSummary(Messages.getString(Messages.SystemGcRuleFactory_TEXT_INFO))
.setExplanation(Messages.getString(Messages.SystemGcRuleFactory_TEXT_INFO_LONG))
.addResult(TypedResult.SCORE, UnitLookup.NUMBER_UNITY.quantity(score))
.addResult(SYSTEM_GC_RATIO, UnitLookup.PERCENT_UNITY.quantity(systemGcRatio)).build();
} else {
return ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.OK)
.setSummary(Messages.getString(Messages.SystemGcRuleFactory_TEXT_OK)).build();
}
}
return ResultBuilder.createFor(this, valueProvider).setSeverity(Severity.NA)
.setSummary(Messages.getString(Messages.GcLockerRule_TEXT_NA)).build();
}

@Override
Expand Down