Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Split capacity/latency collecting logic into separate try/catch block #168

Merged
merged 1 commit into from
Aug 6, 2020
Merged
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
2 changes: 1 addition & 1 deletion licenses/performanceanalyzer-rca-1.3.jar.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ded78fab75fb3f5d04e80425dd46051c28025507
8878f121774e0e8a2906b884dc2fbc2cf2d337aa
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,31 @@ public void collectMetrics(long startTime) {
statsRecordMap.put(threadPoolName, new ThreadPoolStatsRecord(startTime, stats.getRejected()));
final long finalRejectionDelta = rejectionDelta;
ThreadPoolStatus threadPoolStatus = AccessController.doPrivileged((PrivilegedAction<ThreadPoolStatus>) () -> {
Integer capacity;
Double latency;
//This is for backward compatibility. core ES may or may not emit latency metric
// (depending on whether the patch has been applied or not)
// so we need to use reflection to check whether getCapacity() method exist in ThreadPoolStats.java.
try {
//This is for backward compatibility. core ES may or may not emit latency metric
// (depending on whether the patch has been applied or not)
// so we need to use reflection to check whether getLatency() method exist in ThreadPoolStats.java.
// call stats.getLatency()
Method getLantencyMethod = Stats.class.getMethod("getLatency");
double latency = (Double) getLantencyMethod.invoke(stats);
// call stats.getCapacity()
Method getCapacityMethod = Stats.class.getMethod("getCapacity");
int capacity = (Integer) getCapacityMethod.invoke(stats);
return new ThreadPoolStatus(stats.getName(),
stats.getQueue(), finalRejectionDelta,
stats.getThreads(), stats.getActive(),
latency, capacity);
} catch (Exception e) {
capacity = (Integer) getCapacityMethod.invoke(stats);
}
catch (Exception e) {
//core ES does not have the latency patch. send the threadpool metrics without adding latency.
return new ThreadPoolStatus(stats.getName(),
stats.getQueue(), finalRejectionDelta,
stats.getThreads(), stats.getActive());
capacity = null;
}
try {
// call stats.getLatency()
Method getLantencyMethod = Stats.class.getMethod("getLatency");
latency = (Double) getLantencyMethod.invoke(stats);
} catch (Exception e) {
latency = null;
}
return new ThreadPoolStatus(stats.getName(),
stats.getQueue(), finalRejectionDelta,
stats.getThreads(), stats.getActive(),
latency, capacity);
});
value.append(PerformanceAnalyzerMetrics.sMetricNewLineDelimitor)
.append(threadPoolStatus.serialize());
Expand Down Expand Up @@ -161,8 +166,8 @@ public ThreadPoolStatus(String type,
long rejected,
int threadsCount,
int threadsActive,
double queueLatency,
int queueCapacity) {
Double queueLatency,
Integer queueCapacity) {
this.type = type;
this.queueSize = queueSize;
this.rejected = rejected;
Expand Down