Browse Source

_cat/threadpool remove "size" and add "time" params (#55736)

The rest spec and documentation for _cat/threadpool supports a "size" parameter.
However, the "size" parameter will have no impact since there are no values
of type "SizeValue" of the return value of this _cat api.

This commit removes the "size" param from the spec and documentation.

This commit also adds support for the "time" param since and support to
format the time param for the "keep_alive" column. By default, the output
should not change since the "TimeValue" rendered default (via RestTable)
is toString(), and the code prior to this also called toString().

closes #54478
Jake Landis 5 years ago
parent
commit
32269f1a6d

+ 1 - 2
docs/reference/cat/thread_pool.asciidoc

@@ -109,8 +109,7 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag=master-timeout]
 
 include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-s]
 
-`size`::
-(Optional, <<size-units, size unit>>) Multiplier used to display quantities.
+include::{docdir}/rest-api/common-parms.asciidoc[tag=time]
 
 include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-v]
 

+ 0 - 4
rest-api-spec/build.gradle

@@ -10,7 +10,3 @@ artifacts {
   restSpecs(new File(projectDir, "src/main/resources/rest-api-spec/api"))
   restTests(new File(projectDir, "src/main/resources/rest-api-spec/test"))
 }
-
-validateRestSpec {
-   ignore "cat.thread_pool.json"
-}

+ 9 - 12
rest-api-spec/src/main/resources/rest-api-spec/api/cat.thread_pool.json

@@ -32,21 +32,18 @@
         "type":"string",
         "description":"a short version of the Accept header, e.g. json, yaml"
       },
-      "size":{
+      "time":{
         "type":"enum",
-        "description":"The multiplier in which to display values",
+        "description":"The unit in which to display time values",
         "options":[
-          "",
-          "k",
+          "d",
+          "h",
           "m",
-          "g",
-          "t",
-          "p"
-        ],
-        "deprecated":{
-          "version":"7.8.0",
-          "description":"Setting this value has no effect and will be removed from the specification."
-        }
+          "s",
+          "ms",
+          "micros",
+          "nanos"
+        ]
       },
       "local":{
         "type":"boolean",

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

@@ -68,7 +68,6 @@
   - do:
       cat.thread_pool:
           thread_pool_patterns: write,search
-          size: ""
 
   - match:
       $body: |

+ 3 - 2
server/src/main/java/org/elasticsearch/rest/action/cat/RestThreadPoolAction.java

@@ -32,6 +32,7 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
 import org.elasticsearch.cluster.node.DiscoveryNodes;
 import org.elasticsearch.common.Table;
 import org.elasticsearch.common.regex.Regex;
+import org.elasticsearch.common.unit.TimeValue;
 import org.elasticsearch.monitor.process.ProcessInfo;
 import org.elasticsearch.rest.RestRequest;
 import org.elasticsearch.rest.RestResponse;
@@ -207,7 +208,7 @@ public class RestThreadPoolAction extends AbstractCatAction {
                 final ThreadPool.Info poolInfo = poolThreadInfo.get(entry.getKey());
 
                 Long maxQueueSize = null;
-                String keepAlive = null;
+                TimeValue keepAlive = null;
                 Integer core = null;
                 Integer max = null;
                 Integer size = null;
@@ -217,7 +218,7 @@ public class RestThreadPoolAction extends AbstractCatAction {
                         maxQueueSize = poolInfo.getQueueSize().singles();
                     }
                     if (poolInfo.getKeepAlive() != null) {
-                        keepAlive = poolInfo.getKeepAlive().toString();
+                        keepAlive = poolInfo.getKeepAlive();
                     }
 
                     if (poolInfo.getThreadPoolType() == ThreadPool.ThreadPoolType.SCALING) {