HADOOP-13159. Fix potential NPE in Metrics2 source for DecayRpcScheduler. Contributed by Xiaoyu Yao.
(cherry picked from commit9478484845
) (cherry picked from commit744d5edc87
)
This commit is contained in:
parent
264c06a438
commit
937bc924cb
|
@ -206,11 +206,6 @@ public class DecayRpcScheduler implements RpcScheduler,
|
||||||
this.backOffResponseTimeThresholds =
|
this.backOffResponseTimeThresholds =
|
||||||
parseBackOffResponseTimeThreshold(ns, conf, numLevels);
|
parseBackOffResponseTimeThreshold(ns, conf, numLevels);
|
||||||
|
|
||||||
// Setup delay timer
|
|
||||||
Timer timer = new Timer();
|
|
||||||
DecayTask task = new DecayTask(this, timer);
|
|
||||||
timer.scheduleAtFixedRate(task, decayPeriodMillis, decayPeriodMillis);
|
|
||||||
|
|
||||||
// Setup response time metrics
|
// Setup response time metrics
|
||||||
responseTimeTotalInCurrWindow = new AtomicLongArray(numLevels);
|
responseTimeTotalInCurrWindow = new AtomicLongArray(numLevels);
|
||||||
responseTimeCountInCurrWindow = new AtomicLongArray(numLevels);
|
responseTimeCountInCurrWindow = new AtomicLongArray(numLevels);
|
||||||
|
@ -223,6 +218,11 @@ public class DecayRpcScheduler implements RpcScheduler,
|
||||||
Preconditions.checkArgument(topUsersCount > 0,
|
Preconditions.checkArgument(topUsersCount > 0,
|
||||||
"the number of top users for scheduler metrics must be at least 1");
|
"the number of top users for scheduler metrics must be at least 1");
|
||||||
|
|
||||||
|
// Setup delay timer
|
||||||
|
Timer timer = new Timer();
|
||||||
|
DecayTask task = new DecayTask(this, timer);
|
||||||
|
timer.scheduleAtFixedRate(task, decayPeriodMillis, decayPeriodMillis);
|
||||||
|
|
||||||
MetricsProxy prox = MetricsProxy.getInstance(ns, numLevels);
|
MetricsProxy prox = MetricsProxy.getInstance(ns, numLevels);
|
||||||
prox.setDelegate(this);
|
prox.setDelegate(this);
|
||||||
prox.registerMetrics2Source(ns);
|
prox.registerMetrics2Source(ns);
|
||||||
|
@ -821,9 +821,10 @@ public class DecayRpcScheduler implements RpcScheduler,
|
||||||
final int topCallerCount = 10;
|
final int topCallerCount = 10;
|
||||||
TopN topNCallers = getTopCallers(topCallerCount);
|
TopN topNCallers = getTopCallers(topCallerCount);
|
||||||
Map<Object, Integer> decisions = scheduleCacheRef.get();
|
Map<Object, Integer> decisions = scheduleCacheRef.get();
|
||||||
for (int i=0; i < topNCallers.size(); i++) {
|
final int actualCallerCount = topNCallers.size();
|
||||||
|
for (int i = 0; i < actualCallerCount; i++) {
|
||||||
NameValuePair entry = topNCallers.poll();
|
NameValuePair entry = topNCallers.poll();
|
||||||
String topCaller = "Top." + (topCallerCount - i) + "." +
|
String topCaller = "Top." + (actualCallerCount - i) + "." +
|
||||||
"Caller(" + entry.getName() + ")";
|
"Caller(" + entry.getName() + ")";
|
||||||
String topCallerVolume = topCaller + ".Volume";
|
String topCallerVolume = topCaller + ".Volume";
|
||||||
String topCallerPriority = topCaller + ".Priority";
|
String topCallerPriority = topCaller + ".Priority";
|
||||||
|
|
Loading…
Reference in New Issue