|
31 | 31 | import java.util.concurrent.ThreadPoolExecutor; |
32 | 32 | import org.apache.hadoop.conf.Configuration; |
33 | 33 | import org.apache.hadoop.hbase.HBaseClassTestRule; |
| 34 | +import org.apache.hadoop.hbase.ipc.CallTimeoutException; |
| 35 | +import org.apache.hadoop.hbase.ipc.RemoteWithExtrasException; |
34 | 36 | import org.apache.hadoop.hbase.security.User; |
35 | 37 | import org.apache.hadoop.hbase.testclassification.ClientTests; |
36 | 38 | import org.apache.hadoop.hbase.testclassification.MetricsTests; |
@@ -150,51 +152,77 @@ public void testStaticMetrics() throws IOException { |
150 | 152 |
|
151 | 153 | for (int i = 0; i < loop; i++) { |
152 | 154 | METRICS.updateRpc(ClientService.getDescriptor().findMethodByName("Get"), |
153 | | - GetRequest.getDefaultInstance(), MetricsConnection.newCallStats(), false); |
| 155 | + GetRequest.getDefaultInstance(), MetricsConnection.newCallStats(), null); |
154 | 156 | METRICS.updateRpc(ClientService.getDescriptor().findMethodByName("Scan"), |
155 | | - ScanRequest.getDefaultInstance(), MetricsConnection.newCallStats(), false); |
| 157 | + ScanRequest.getDefaultInstance(), MetricsConnection.newCallStats(), |
| 158 | + new RemoteWithExtrasException("java.io.IOException", null, false, false)); |
156 | 159 | METRICS.updateRpc(ClientService.getDescriptor().findMethodByName("Multi"), |
157 | | - MultiRequest.getDefaultInstance(), MetricsConnection.newCallStats(), true); |
| 160 | + MultiRequest.getDefaultInstance(), MetricsConnection.newCallStats(), |
| 161 | + new CallTimeoutException("test with CallTimeoutException")); |
158 | 162 | METRICS.updateRpc(ClientService.getDescriptor().findMethodByName("Mutate"), |
159 | 163 | MutateRequest.newBuilder() |
160 | 164 | .setMutation(ProtobufUtil.toMutation(MutationType.APPEND, new Append(foo))) |
161 | 165 | .setRegion(region).build(), |
162 | | - MetricsConnection.newCallStats(), false); |
| 166 | + MetricsConnection.newCallStats(), null); |
163 | 167 | METRICS.updateRpc(ClientService.getDescriptor().findMethodByName("Mutate"), |
164 | 168 | MutateRequest.newBuilder() |
165 | 169 | .setMutation(ProtobufUtil.toMutation(MutationType.DELETE, new Delete(foo))) |
166 | 170 | .setRegion(region).build(), |
167 | | - MetricsConnection.newCallStats(), false); |
| 171 | + MetricsConnection.newCallStats(), null); |
168 | 172 | METRICS.updateRpc(ClientService.getDescriptor().findMethodByName("Mutate"), |
169 | 173 | MutateRequest.newBuilder() |
170 | 174 | .setMutation(ProtobufUtil.toMutation(MutationType.INCREMENT, new Increment(foo))) |
171 | 175 | .setRegion(region).build(), |
172 | | - MetricsConnection.newCallStats(), false); |
| 176 | + MetricsConnection.newCallStats(), null); |
173 | 177 | METRICS.updateRpc(ClientService.getDescriptor().findMethodByName("Mutate"), |
174 | 178 | MutateRequest.newBuilder() |
175 | 179 | .setMutation(ProtobufUtil.toMutation(MutationType.PUT, new Put(foo))).setRegion(region) |
176 | 180 | .build(), |
177 | | - MetricsConnection.newCallStats(), false); |
| 181 | + MetricsConnection.newCallStats(), null); |
178 | 182 | } |
| 183 | + |
179 | 184 | final String rpcCountPrefix = "rpcCount_" + ClientService.getDescriptor().getName() + "_"; |
180 | 185 | final String rpcFailureCountPrefix = |
181 | 186 | "rpcFailureCount_" + ClientService.getDescriptor().getName() + "_"; |
182 | 187 | String metricKey; |
183 | 188 | long metricVal; |
184 | 189 | Counter counter; |
185 | | - for (String method : new String[] { "Get", "Scan", "Mutate" }) { |
| 190 | + |
| 191 | + for (String method : new String[] { "Get", "Scan", "Multi", "Mutate" }) { |
186 | 192 | metricKey = rpcCountPrefix + method; |
187 | 193 | metricVal = METRICS.getRpcCounters().get(metricKey).getCount(); |
188 | 194 | assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal >= loop); |
| 195 | + |
189 | 196 | metricKey = rpcFailureCountPrefix + method; |
190 | 197 | counter = METRICS.getRpcCounters().get(metricKey); |
191 | 198 | metricVal = (counter != null) ? counter.getCount() : 0; |
192 | | - assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal == 0); |
| 199 | + if (method.equals("Get") || method.equals("Mutate")) { |
| 200 | + // no failure |
| 201 | + assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal == 0); |
| 202 | + } else { |
| 203 | + // has failure |
| 204 | + assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal == loop); |
| 205 | + } |
193 | 206 | } |
194 | | - metricKey = rpcFailureCountPrefix + "Multi"; |
| 207 | + |
| 208 | + // remote exception |
| 209 | + metricKey = "rpcRemoteExceptions_IOException"; |
| 210 | + counter = METRICS.getRpcCounters().get(metricKey); |
| 211 | + metricVal = (counter != null) ? counter.getCount() : 0; |
| 212 | + assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal == loop); |
| 213 | + |
| 214 | + // local exception |
| 215 | + metricKey = "rpcLocalExceptions_CallTimeoutException"; |
195 | 216 | counter = METRICS.getRpcCounters().get(metricKey); |
196 | 217 | metricVal = (counter != null) ? counter.getCount() : 0; |
197 | 218 | assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal == loop); |
| 219 | + |
| 220 | + // total exception |
| 221 | + metricKey = "rpcTotalExceptions"; |
| 222 | + counter = METRICS.getRpcCounters().get(metricKey); |
| 223 | + metricVal = (counter != null) ? counter.getCount() : 0; |
| 224 | + assertTrue("metric: " + metricKey + " val: " + metricVal, metricVal == loop * 2); |
| 225 | + |
198 | 226 | for (MetricsConnection.CallTracker t : new MetricsConnection.CallTracker[] { |
199 | 227 | METRICS.getGetTracker(), METRICS.getScanTracker(), METRICS.getMultiTracker(), |
200 | 228 | METRICS.getAppendTracker(), METRICS.getDeleteTracker(), METRICS.getIncrementTracker(), |
|
0 commit comments