1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.ipc;
19
20 import java.util.Deque;
21 import java.util.concurrent.BlockingQueue;
22 import java.util.concurrent.ConcurrentLinkedDeque;
23 import java.util.concurrent.atomic.AtomicInteger;
24
25 import org.apache.hadoop.conf.Configuration;
26 import org.apache.hadoop.hbase.Abortable;
27 import org.apache.hadoop.hbase.classification.InterfaceAudience;
28
29
30
31
32
33
34
35
36 @InterfaceAudience.Private
37 public class FastPathBalancedQueueRpcExecutor extends BalancedQueueRpcExecutor {
38
39
40
41
42
43 private final Deque<FastPathRpcHandler> fastPathHandlerStack = new ConcurrentLinkedDeque<>();
44
45 public FastPathBalancedQueueRpcExecutor(final String name, final int handlerCount,
46 final int maxQueueLength, final PriorityFunction priority, final Configuration conf,
47 final Abortable abortable) {
48 super(name, handlerCount, maxQueueLength, priority, conf, abortable);
49
50 }
51
52 public FastPathBalancedQueueRpcExecutor(final String name, final int handlerCount,
53 final String callQueueType, final int maxQueueLength, final PriorityFunction priority,
54 final Configuration conf, final Abortable abortable) {
55 super(name, handlerCount, callQueueType, maxQueueLength, priority, conf, abortable);
56 }
57
58 @Override
59 protected RpcHandler getHandler(final String name, final double handlerFailureThreshhold,
60 final int handlerCount, final BlockingQueue<CallRunner> q,
61 final AtomicInteger activeHandlerCount, final AtomicInteger failedHandlerCount,
62 final Abortable abortable) {
63 return new FastPathRpcHandler(name, handlerFailureThreshhold, handlerCount, q,
64 activeHandlerCount, failedHandlerCount, abortable, fastPathHandlerStack);
65 }
66
67 @Override
68 public boolean dispatch(CallRunner callTask) throws InterruptedException {
69
70
71 if (currentQueueLimit == 0){
72 return false;
73 }
74 FastPathRpcHandler handler = popReadyHandler();
75 return handler != null? handler.loadCallRunner(callTask): super.dispatch(callTask);
76 }
77
78
79
80
81 private FastPathRpcHandler popReadyHandler() {
82 return this.fastPathHandlerStack.poll();
83 }
84 }