1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.hadoop.hbase.hbql.impl;
22
23 import org.apache.hadoop.hbase.hbql.client.HBqlException;
24 import org.apache.hadoop.hbase.hbql.client.QueryExecutorPool;
25
26 public class QueryExecutorPoolImpl extends ElementPool<CompletionQueueExecutor> implements QueryExecutorPool {
27
28 private final int minThreadCount;
29 private final int maxThreadCount;
30 private final long keepAliveSecs;
31 private final boolean threadsReadResults;
32 private final int completionQueueSize;
33
34 public QueryExecutorPoolImpl(final String poolName,
35 final int maxExecutorPoolSize,
36 final int minThreadCount,
37 final int maxThreadCount,
38 final long keepAliveSecs,
39 final boolean threadsReadResults,
40 final int completionQueueSize) {
41 super(poolName, maxExecutorPoolSize);
42 this.minThreadCount = minThreadCount;
43 this.maxThreadCount = maxThreadCount;
44 this.keepAliveSecs = keepAliveSecs;
45 this.threadsReadResults = threadsReadResults;
46 this.completionQueueSize = completionQueueSize;
47 }
48
49 public int getMinThreadCount() {
50 return this.minThreadCount;
51 }
52
53 public int getMaxThreadCount() {
54 return this.maxThreadCount;
55 }
56
57 public long getKeepAliveSecs() {
58 return this.keepAliveSecs;
59 }
60
61 public boolean getThreadsReadResults() {
62 return this.threadsReadResults;
63 }
64
65 public int getCompletionQueueSize() {
66 return this.completionQueueSize;
67 }
68
69 protected CompletionQueueExecutor newElement() throws HBqlException {
70 return this.getThreadsReadResults()
71 ? ResultExecutor.newPooledResultExecutor(this,
72 this.getMinThreadCount(),
73 this.getMaxThreadCount(),
74 this.getKeepAliveSecs(),
75 this.getCompletionQueueSize())
76 : ResultScannerExecutor.newPooledResultScannerExecutor(this,
77 this.getMinThreadCount(),
78 this.getMaxThreadCount(),
79 this.getKeepAliveSecs(),
80 this.getCompletionQueueSize());
81 }
82
83 public void shutdown() {
84 for (final CompletionQueueExecutor val : this.getElementPool()) {
85 val.shutdown();
86 }
87 }
88 }