public BalancedQueueRpcExecutor(final String name, final int handlerCount, final String callQueueType, final int maxQueueLength, final PriorityFunction priority, final Configuration conf, final Abortable abortable) { super(name, handlerCount, callQueueType, maxQueueLength, priority, conf, abortable); this.balancer = getBalancer(this.numCallQueues); initializeQueues(this.numCallQueues); }
@Override public boolean dispatch(CallRunner callTask) throws InterruptedException { FastPathHandler handler = popReadyHandler(); return handler != null? handler.loadCallRunner(callTask): super.dispatch(callTask); }
maxQueueLength, priority, conf, server); } else { callExecutor = new BalancedQueueRpcExecutor("default.BQ", handlerCount, maxQueueLength, priority, conf, server);
@Test public void testIndexPriorityWritesToIndexHandler() throws Exception { RpcScheduler mock = Mockito.mock(RpcScheduler.class); PriorityFunction qosFunction = Mockito.mock(PriorityFunction.class); Abortable abortable = new AbortServer(); PhoenixRpcScheduler scheduler = new PhoenixRpcScheduler(conf, mock, 200, 250,qosFunction,abortable); BalancedQueueRpcExecutor executor = new BalancedQueueRpcExecutor("test-queue", 1, 1,qosFunction,conf,abortable); scheduler.setIndexExecutorForTesting(executor); dispatchCallWithPriority(scheduler, 200); List<BlockingQueue<CallRunner>> queues = executor.getQueues(); assertEquals(1, queues.size()); BlockingQueue<CallRunner> queue = queues.get(0); queue.poll(20, TimeUnit.SECONDS); // try again, this time we tweak the ranges we support scheduler = new PhoenixRpcScheduler(conf, mock, 101, 110,qosFunction,abortable); scheduler.setIndexExecutorForTesting(executor); dispatchCallWithPriority(scheduler, 101); queue.poll(20, TimeUnit.SECONDS); Mockito.verify(mock, Mockito.times(2)).init(Mockito.any(Context.class)); scheduler.stop(); executor.stop(); }
public PhoenixRpcScheduler(Configuration conf, RpcScheduler delegate, int indexPriority, int metadataPriority, PriorityFunction priorityFunction, Abortable abortable) { // copied from org.apache.hadoop.hbase.ipc.SimpleRpcScheduler in HBase 0.98.4 int indexHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_HANDLER_COUNT); int metadataHandlerCount = conf.getInt(QueryServices.METADATA_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_HANDLER_COUNT); int maxIndexQueueLength = conf.getInt(CALLQUEUE_LENGTH_CONF_KEY, indexHandlerCount*DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER); int maxMetadataQueueLength = conf.getInt(CALLQUEUE_LENGTH_CONF_KEY, metadataHandlerCount*DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER); this.indexPriority = indexPriority; this.metadataPriority = metadataPriority; this.delegate = delegate; this.indexCallExecutor = new BalancedQueueRpcExecutor("Index", indexHandlerCount, maxIndexQueueLength, priorityFunction,conf,abortable); this.metadataCallExecutor = new BalancedQueueRpcExecutor("Metadata", metadataHandlerCount, maxMetadataQueueLength, priorityFunction,conf,abortable); }
public PhoenixRpcScheduler(Configuration conf, RpcScheduler delegate, int indexPriority, int metadataPriority, PriorityFunction priorityFunction, Abortable abortable) { // copied from org.apache.hadoop.hbase.ipc.SimpleRpcScheduler in HBase 0.98.4 int indexHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_HANDLER_COUNT); int metadataHandlerCount = conf.getInt(QueryServices.METADATA_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_HANDLER_COUNT); int maxIndexQueueLength = conf.getInt(CALLQUEUE_LENGTH_CONF_KEY, indexHandlerCount*DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER); int maxMetadataQueueLength = conf.getInt(CALLQUEUE_LENGTH_CONF_KEY, metadataHandlerCount*DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER); this.indexPriority = indexPriority; this.metadataPriority = metadataPriority; this.delegate = delegate; this.indexCallExecutor = new BalancedQueueRpcExecutor("Index", indexHandlerCount, maxIndexQueueLength, priorityFunction,conf,abortable); this.metadataCallExecutor = new BalancedQueueRpcExecutor("Metadata", metadataHandlerCount, maxMetadataQueueLength, priorityFunction,conf,abortable); }
public BalancedQueueRpcExecutor(final String name, final int handlerCount, final int numQueues, final Configuration conf, final Abortable abortable, final Class<? extends BlockingQueue> queueClass, Object... initargs) { super(name, Math.max(handlerCount, numQueues), conf, abortable); queues = new ArrayList<BlockingQueue<CallRunner>>(numQueues); this.balancer = getBalancer(numQueues); initializeQueues(numQueues, queueClass, initargs); }
public PhoenixRpcScheduler(Configuration conf, RpcScheduler delegate, int indexPriority, int metadataPriority, PriorityFunction priorityFunction, Abortable abortable) { // copied from org.apache.hadoop.hbase.ipc.SimpleRpcScheduler in HBase 0.98.4 int indexHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_HANDLER_COUNT); int metadataHandlerCount = conf.getInt(QueryServices.METADATA_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_HANDLER_COUNT); int maxIndexQueueLength = conf.getInt(CALLQUEUE_LENGTH_CONF_KEY, indexHandlerCount*DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER); int maxMetadataQueueLength = conf.getInt(CALLQUEUE_LENGTH_CONF_KEY, metadataHandlerCount*DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER); this.indexPriority = indexPriority; this.metadataPriority = metadataPriority; this.delegate = delegate; this.indexCallExecutor = new BalancedQueueRpcExecutor("Index", indexHandlerCount, maxIndexQueueLength, priorityFunction,conf,abortable); this.metadataCallExecutor = new BalancedQueueRpcExecutor("Metadata", metadataHandlerCount, maxMetadataQueueLength, priorityFunction,conf,abortable); }
callExecutor = new BalancedQueueRpcExecutor("B.default", handlerCount, numCallQueues, conf, abortable, BoundedPriorityBlockingQueue.class, maxQueueLength, callPriority); } else { callExecutor = new BalancedQueueRpcExecutor("B.default", handlerCount, numCallQueues, maxQueueLength, conf, abortable); new BalancedQueueRpcExecutor("Priority", priorityHandlerCount, 2, maxQueueLength) : null; replicationHandlerCount > 0 ? new BalancedQueueRpcExecutor("Replication", replicationHandlerCount, 1, maxQueueLength, conf, abortable) : null;