Skip to content

Commit 8fdca6a

Browse files
authored
Align cat thread pool info to thread pool config (#29195)
Today we report thread pool info using a common object. This means that we use a shared set of terminology that is not consistent with the terminology used to the configure thread pools. This holds in particular for the minimum and maximum number of threads in the thread pool where we use the following terminology: thread pool info | fixed | scaling min core size max max size A previous change addressed this for the nodes info API. This commit changes the display of thread pool info in the cat thread pool API too to be dependent on the type of the thread pool so that we can align the terminology in the output of thread pool info with the terminology used to configure a thread pool.
1 parent 8e2f2be commit 8fdca6a

File tree

3 files changed

+34
-22
lines changed

3 files changed

+34
-22
lines changed

docs/reference/cat/thread_pool.asciidoc

+4-3
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,15 @@ in the table below.
113113
|Field Name |Alias |Description
114114
|`type` |`t` |The current (*) type of thread pool (`fixed` or `scaling`)
115115
|`active` |`a` |The number of active threads in the current thread pool
116-
|`size` |`s` |The number of threads in the current thread pool
116+
|`pool_size` |`psz` |The number of threads in the current thread pool
117117
|`queue` |`q` |The number of tasks in the queue for the current thread pool
118118
|`queue_size` |`qs` |The maximum number of tasks permitted in the queue for the current thread pool
119119
|`rejected` |`r` |The number of tasks rejected by the thread pool executor
120120
|`largest` |`l` |The highest number of active threads in the current thread pool
121121
|`completed` |`c` |The number of tasks completed by the thread pool executor
122-
|`min` |`mi` |The configured minimum number of active threads allowed in the current thread pool
123-
|`max` |`ma` |The configured maximum number of active threads allowed in the current thread pool
122+
|`core` |`cr` |The configured core number of active threads allowed in the current thread pool
123+
|`max` |`mx` |The configured maximum number of active threads allowed in the current thread pool
124+
|`size` |`sz` |The configured fixed number of active threads allowed in the current thread pool
124125
|`keep_alive` |`k` |The configured keep alive time for threads
125126
|=======================================================================
126127

rest-api-spec/src/main/resources/rest-api-spec/test/cat.thread_pool/10_basic.yml

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
---
22
"Test cat thread_pool output":
33

4+
- skip:
5+
version: " - 6.99.99"
6+
reason: this API was changed in a backwards-incompatible fashion in 7.0.0 so we need to skip in a mixed cluster
7+
48
- do:
59
cat.thread_pool: {}
610

@@ -46,25 +50,25 @@
4650
- do:
4751
cat.thread_pool:
4852
thread_pool_patterns: bulk
49-
h: id,name,type,active,size,queue,queue_size,rejected,largest,completed,min,max,keep_alive
53+
h: id,name,type,active,pool_size,queue,queue_size,rejected,largest,completed,core,max,size,keep_alive
5054
v: true
5155

5256
- match:
5357
$body: |
54-
/^ id \s+ name \s+ type \s+ active \s+ size \s+ queue \s+ queue_size \s+ rejected \s+ largest \s+ completed \s+ min \s+ max \s+ keep_alive \n
55-
(\S+ \s+ bulk \s+ fixed \s+ \d+ \s+ \d+ \s+ \d+ \s+ (-1|\d+) \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d* \s+ \d* \s+ \S* \n)+ $/
58+
/^ id \s+ name \s+ type \s+ active \s+ pool_size \s+ queue \s+ queue_size \s+ rejected \s+ largest \s+ completed \s+ core \s+ max \s+ size \s+ keep_alive \n
59+
(\S+ \s+ bulk \s+ fixed \s+ \d+ \s+ \d+ \s+ \d+ \s+ (-1|\d+) \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d* \s+ \d* \s+ \d* \s+ \S* \n)+ $/
5660
5761
- do:
5862
cat.thread_pool:
5963
thread_pool_patterns: fetch*
60-
h: id,name,type,active,size,queue,queue_size,rejected,largest,completed,min,max,keep_alive
64+
h: id,name,type,active,pool_size,queue,queue_size,rejected,largest,completed,core,max,size,keep_alive
6165
v: true
6266

6367
- match:
6468
$body: |
65-
/^ id \s+ name \s+ type \s+ active \s+ size \s+ queue \s+ queue_size \s+ rejected \s+ largest \s+ completed \s+ min \s+ max \s+ keep_alive \n
66-
(\S+ \s+ fetch_shard_started \s+ scaling \s+ \d+ \s+ \d+ \s+ \d+ \s+ (-1|\d+) \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d* \s+ \d* \s+ \S* \n
67-
\S+ \s+ fetch_shard_store \s+ scaling \s+ \d+ \s+ \d+ \s+ \d+ \s+ (-1|\d+) \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d* \s+ \d* \s+ \S* \n)+ $/
69+
/^ id \s+ name \s+ type \s+ active \s+ pool_size \s+ queue \s+ queue_size \s+ rejected \s+ largest \s+ completed \s+ core \s+ max \s+ size \s+ keep_alive \n
70+
(\S+ \s+ fetch_shard_started \s+ scaling \s+ \d+ \s+ \d+ \s+ \d+ \s+ (-1|\d+) \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d* \s+ \d* \s+ \d* \s+ \S* \n
71+
\S+ \s+ fetch_shard_store \s+ scaling \s+ \d+ \s+ \d+ \s+ \d+ \s+ (-1|\d+) \s+ \d+ \s+ \d+ \s+ \d+ \s+ \d* \s+ \d* \s+ \d* \s+ \S* \n)+ $/
6872
6973
- do:
7074
cat.thread_pool:

server/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java

+19-12
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,15 @@ protected Table getTableWithHeader(final RestRequest request) {
124124
table.addCell("name", "default:true;alias:n;desc:thread pool name");
125125
table.addCell("type", "alias:t;default:false;desc:thread pool type");
126126
table.addCell("active", "alias:a;default:true;text-align:right;desc:number of active threads");
127-
table.addCell("size", "alias:s;default:false;text-align:right;desc:number of threads");
127+
table.addCell("pool_size", "alias:psz;default:false;text-align:right;desc:number of threads");
128128
table.addCell("queue", "alias:q;default:true;text-align:right;desc:number of tasks currently in queue");
129129
table.addCell("queue_size", "alias:qs;default:false;text-align:right;desc:maximum number of tasks permitted in queue");
130130
table.addCell("rejected", "alias:r;default:true;text-align:right;desc:number of rejected tasks");
131131
table.addCell("largest", "alias:l;default:false;text-align:right;desc:highest number of seen active threads");
132132
table.addCell("completed", "alias:c;default:false;text-align:right;desc:number of completed tasks");
133-
table.addCell("min", "alias:mi;default:false;text-align:right;desc:minimum number of threads");
134-
table.addCell("max", "alias:ma;default:false;text-align:right;desc:maximum number of threads");
133+
table.addCell("core", "alias:cr;default:false;text-align:right;desc:core number of threads in a scaling thread pool");
134+
table.addCell("max", "alias:mx;default:false;text-align:right;desc:maximum number of threads in a scaling thread pool");
135+
table.addCell("size", "alias:sz;default:false;text-align:right;desc:number of threads in a fixed thread pool");
135136
table.addCell("keep_alive", "alias:ka;default:false;text-align:right;desc:thread keep alive time");
136137
table.endHeaders();
137138
return table;
@@ -201,8 +202,9 @@ private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoR
201202

202203
Long maxQueueSize = null;
203204
String keepAlive = null;
204-
Integer minThreads = null;
205-
Integer maxThreads = null;
205+
Integer core = null;
206+
Integer max = null;
207+
Integer size = null;
206208

207209
if (poolInfo != null) {
208210
if (poolInfo.getQueueSize() != null) {
@@ -211,11 +213,15 @@ private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoR
211213
if (poolInfo.getKeepAlive() != null) {
212214
keepAlive = poolInfo.getKeepAlive().toString();
213215
}
214-
if (poolInfo.getMin() >= 0) {
215-
minThreads = poolInfo.getMin();
216-
}
217-
if (poolInfo.getMax() >= 0) {
218-
maxThreads = poolInfo.getMax();
216+
217+
if (poolInfo.getThreadPoolType() == ThreadPool.ThreadPoolType.SCALING) {
218+
assert poolInfo.getMin() >= 0;
219+
core = poolInfo.getMin();
220+
assert poolInfo.getMax() > 0;
221+
max = poolInfo.getMax();
222+
} else {
223+
assert poolInfo.getMin() == poolInfo.getMax() && poolInfo.getMax() > 0;
224+
size = poolInfo.getMax();
219225
}
220226
}
221227

@@ -228,8 +234,9 @@ private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoR
228234
table.addCell(poolStats == null ? null : poolStats.getRejected());
229235
table.addCell(poolStats == null ? null : poolStats.getLargest());
230236
table.addCell(poolStats == null ? null : poolStats.getCompleted());
231-
table.addCell(minThreads);
232-
table.addCell(maxThreads);
237+
table.addCell(core);
238+
table.addCell(max);
239+
table.addCell(size);
233240
table.addCell(keepAlive);
234241

235242
table.endRow();

0 commit comments

Comments
 (0)