HBASE-27845 Distinguish the mutate types of rpc error in MetricsConnection.
This commit is contained in:
parent
ef0ce71c7e
commit
b04e455bdc
|
@ -652,25 +652,26 @@ public final class MetricsConnection implements StatisticTrackable {
|
|||
concurrentCallsPerServerHist.update(callsPerServer);
|
||||
}
|
||||
// Update the counter that tracks RPCs by type.
|
||||
String methodName = method.getService().getName() + "_" + method.getName();
|
||||
StringBuilder methodName = new StringBuilder();
|
||||
methodName.append(method.getService().getName()).append("_").append(method.getName());
|
||||
// Distinguish mutate types.
|
||||
if ("Mutate".equals(method.getName())) {
|
||||
final MutationType type = ((MutateRequest) param).getMutation().getMutateType();
|
||||
switch (type) {
|
||||
case APPEND:
|
||||
methodName += "(Append)";
|
||||
methodName.append("(Append)");
|
||||
break;
|
||||
case DELETE:
|
||||
methodName += "(Delete)";
|
||||
methodName.append("(Delete)");
|
||||
break;
|
||||
case INCREMENT:
|
||||
methodName += "(Increment)";
|
||||
methodName.append("(Increment)");
|
||||
break;
|
||||
case PUT:
|
||||
methodName += "(Put)";
|
||||
methodName.append("(Put)");
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unrecognized mutation type " + type);
|
||||
methodName.append("(Unknown)");
|
||||
}
|
||||
}
|
||||
getMetric(CNT_BASE + methodName, rpcCounters, counterFactory).inc();
|
||||
|
@ -749,7 +750,7 @@ public final class MetricsConnection implements StatisticTrackable {
|
|||
}
|
||||
}
|
||||
// Fallback to dynamic registry lookup for DDL methods.
|
||||
updateRpcGeneric(methodName, stats);
|
||||
updateRpcGeneric(methodName.toString(), stats);
|
||||
}
|
||||
|
||||
public void incrCacheDroppingExceptions(Object exception) {
|
||||
|
|
|
@ -99,7 +99,7 @@ public class TestMetricsConnection {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMetricsWithMutiConnections() throws IOException {
|
||||
public void testMetricsWithMultiConnections() throws IOException {
|
||||
Configuration conf = new Configuration();
|
||||
conf.setBoolean(MetricsConnection.CLIENT_SIDE_METRICS_ENABLED_KEY, true);
|
||||
conf.set(MetricsConnection.METRICS_SCOPE_KEY, "unit-test");
|
||||
|
@ -192,17 +192,17 @@ public class TestMetricsConnection {
|
|||
for (String method : new String[] { "Get", "Scan", "Multi" }) {
|
||||
metricKey = rpcCountPrefix + method;
|
||||
metricVal = METRICS.getRpcCounters().get(metricKey).getCount();
|
||||
assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal == loop);
|
||||
assertEquals("metric: " + metricKey + " val: " + metricVal, metricVal, loop);
|
||||
|
||||
metricKey = rpcFailureCountPrefix + method;
|
||||
counter = METRICS.getRpcCounters().get(metricKey);
|
||||
metricVal = (counter != null) ? counter.getCount() : 0;
|
||||
if (method.equals("Get")) {
|
||||
// no failure
|
||||
assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal == 0);
|
||||
assertEquals("metric: " + metricKey + " val: " + metricVal, 0, metricVal);
|
||||
} else {
|
||||
// has failure
|
||||
assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal == loop);
|
||||
assertEquals("metric: " + metricKey + " val: " + metricVal, metricVal, loop);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,17 +210,17 @@ public class TestMetricsConnection {
|
|||
for (String mutationType : new String[] { "Append", "Delete", "Increment", "Put" }) {
|
||||
metricKey = rpcCountPrefix + method + "(" + mutationType + ")";
|
||||
metricVal = METRICS.getRpcCounters().get(metricKey).getCount();
|
||||
assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal == loop);
|
||||
assertEquals("metric: " + metricKey + " val: " + metricVal, metricVal, loop);
|
||||
|
||||
metricKey = rpcFailureCountPrefix + method + "(" + mutationType + ")";
|
||||
counter = METRICS.getRpcCounters().get(metricKey);
|
||||
metricVal = (counter != null) ? counter.getCount() : 0;
|
||||
if (mutationType.equals("Put")) {
|
||||
// no failure
|
||||
assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal == loop);
|
||||
} else {
|
||||
// has failure
|
||||
assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal == 0);
|
||||
assertEquals("metric: " + metricKey + " val: " + metricVal, metricVal, loop);
|
||||
} else {
|
||||
// no failure
|
||||
assertEquals("metric: " + metricKey + " val: " + metricVal, 0, metricVal);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,19 +228,19 @@ public class TestMetricsConnection {
|
|||
metricKey = "rpcRemoteExceptions_IOException";
|
||||
counter = METRICS.getRpcCounters().get(metricKey);
|
||||
metricVal = (counter != null) ? counter.getCount() : 0;
|
||||
assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal == loop);
|
||||
assertEquals("metric: " + metricKey + " val: " + metricVal, metricVal, loop);
|
||||
|
||||
// local exception
|
||||
metricKey = "rpcLocalExceptions_CallTimeoutException";
|
||||
counter = METRICS.getRpcCounters().get(metricKey);
|
||||
metricVal = (counter != null) ? counter.getCount() : 0;
|
||||
assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal == loop * 2);
|
||||
assertEquals("metric: " + metricKey + " val: " + metricVal, metricVal, loop * 2);
|
||||
|
||||
// total exception
|
||||
metricKey = "rpcTotalExceptions";
|
||||
counter = METRICS.getRpcCounters().get(metricKey);
|
||||
metricVal = (counter != null) ? counter.getCount() : 0;
|
||||
assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal == loop * 3);
|
||||
assertEquals("metric: " + metricKey + " val: " + metricVal, metricVal, loop * 3);
|
||||
|
||||
for (MetricsConnection.CallTracker t : new MetricsConnection.CallTracker[] {
|
||||
METRICS.getGetTracker(), METRICS.getScanTracker(), METRICS.getMultiTracker(),
|
||||
|
|
Loading…
Reference in New Issue