|
52 | 52 | import org.apache.hadoop.hbase.util.Bytes;
|
53 | 53 | import org.apache.hadoop.hbase.util.EnvironmentEdge;
|
54 | 54 | import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
| 55 | +import org.apache.hadoop.hbase.util.ReflectionUtils; |
55 | 56 | import org.apache.hadoop.hbase.util.Threads;
|
56 | 57 | import org.junit.Before;
|
57 | 58 | import org.junit.ClassRule;
|
@@ -274,6 +275,41 @@ public void testPluggableRpcQueue() throws Exception {
|
274 | 275 | }
|
275 | 276 | }
|
276 | 277 |
|
| 278 | + @Test |
| 279 | + public void testPluggableRpcQueueWireUpWithFastPathExecutor() throws Exception { |
| 280 | + String queueType = RpcExecutor.CALL_QUEUE_TYPE_PLUGGABLE_CONF_VALUE; |
| 281 | + Configuration schedConf = HBaseConfiguration.create(); |
| 282 | + schedConf.set(RpcExecutor.CALL_QUEUE_TYPE_CONF_KEY, queueType); |
| 283 | + schedConf.set(RpcExecutor.PLUGGABLE_CALL_QUEUE_CLASS_NAME, "org.apache.hadoop.hbase.ipc.TestPluggableQueueImpl"); |
| 284 | + schedConf.setBoolean(RpcExecutor.PLUGGABLE_CALL_QUEUE_WITH_FAST_PATH_ENABLED, true); |
| 285 | + |
| 286 | + PriorityFunction priority = mock(PriorityFunction.class); |
| 287 | + when(priority.getPriority(any(), any(), any())).thenReturn(HConstants.NORMAL_QOS); |
| 288 | + SimpleRpcScheduler scheduler = new SimpleRpcScheduler(schedConf, 0, 0, 0, priority, |
| 289 | + HConstants.QOS_THRESHOLD); |
| 290 | + |
| 291 | + Field f = scheduler.getClass().getDeclaredField("callExecutor"); |
| 292 | + f.setAccessible(true); |
| 293 | + assertTrue(f.get(scheduler) instanceof FastPathBalancedQueueRpcExecutor); |
| 294 | + } |
| 295 | + |
| 296 | + @Test |
| 297 | + public void testPluggableRpcQueueWireUpWithoutFastPathExecutor() throws Exception { |
| 298 | + String queueType = RpcExecutor.CALL_QUEUE_TYPE_PLUGGABLE_CONF_VALUE; |
| 299 | + Configuration schedConf = HBaseConfiguration.create(); |
| 300 | + schedConf.set(RpcExecutor.CALL_QUEUE_TYPE_CONF_KEY, queueType); |
| 301 | + schedConf.set(RpcExecutor.PLUGGABLE_CALL_QUEUE_CLASS_NAME, "org.apache.hadoop.hbase.ipc.TestPluggableQueueImpl"); |
| 302 | + |
| 303 | + PriorityFunction priority = mock(PriorityFunction.class); |
| 304 | + when(priority.getPriority(any(), any(), any())).thenReturn(HConstants.NORMAL_QOS); |
| 305 | + SimpleRpcScheduler scheduler = new SimpleRpcScheduler(schedConf, 0, 0, 0, priority, |
| 306 | + HConstants.QOS_THRESHOLD); |
| 307 | + |
| 308 | + Field f = scheduler.getClass().getDeclaredField("callExecutor"); |
| 309 | + f.setAccessible(true); |
| 310 | + assertTrue(f.get(scheduler) instanceof BalancedQueueRpcExecutor); |
| 311 | + } |
| 312 | + |
277 | 313 | @Test
|
278 | 314 | public void testPluggableRpcQueueCanListenToConfigurationChanges() throws Exception {
|
279 | 315 |
|
@@ -316,9 +352,7 @@ private void testRpcScheduler(final String queueType) throws Exception {
|
316 | 352 | testRpcScheduler(queueType, null);
|
317 | 353 | }
|
318 | 354 |
|
319 |
| - private void testRpcScheduler(final String queueType, final String pluggableQueueClass) |
320 |
| - throws Exception { |
321 |
| - |
| 355 | + private void testRpcScheduler(final String queueType, final String pluggableQueueClass) throws Exception { |
322 | 356 | Configuration schedConf = HBaseConfiguration.create();
|
323 | 357 | schedConf.set(RpcExecutor.CALL_QUEUE_TYPE_CONF_KEY, queueType);
|
324 | 358 |
|
@@ -388,7 +422,8 @@ private void testRpcScheduler(final String queueType, final String pluggableQueu
|
388 | 422 | // -> WITH REORDER [10 10 10 10 10 10 50 100] -> 530 (Deadline Queue)
|
389 | 423 | if (queueType.equals(RpcExecutor.CALL_QUEUE_TYPE_DEADLINE_CONF_VALUE)) {
|
390 | 424 | assertEquals(530, totalTime);
|
391 |
| - } else if (queueType.equals(RpcExecutor.CALL_QUEUE_TYPE_FIFO_CONF_VALUE)) { |
| 425 | + } else if (queueType.equals(RpcExecutor.CALL_QUEUE_TYPE_FIFO_CONF_VALUE) || |
| 426 | + queueType.equals(RpcExecutor.CALL_QUEUE_TYPE_PLUGGABLE_CONF_VALUE)) { |
392 | 427 | assertEquals(930, totalTime);
|
393 | 428 | }
|
394 | 429 | } finally {
|
|
0 commit comments