The queue_size value should be shown as an integer,

closes #10404
closes #13063
This commit is contained in:
xuzha 2015-08-23 17:50:07 -07:00 committed by Boaz Leskes
parent 76c472973e
commit f77b349c23
3 changed files with 24 additions and 1 deletions

View File

@ -727,7 +727,7 @@ public class ThreadPool extends AbstractComponent {
if (queueSize == null) {
builder.field(Fields.QUEUE_SIZE, -1);
} else {
builder.field(Fields.QUEUE_SIZE, queueSize.toString());
builder.field(Fields.QUEUE_SIZE, queueSize.singles());
}
builder.endObject();
return builder;

View File

@ -99,4 +99,23 @@ public class ThreadPoolSerializationTests extends ESTestCase {
assertThat(threadPool.info("index").getQueueSize(), is(nullValue()));
terminate(threadPool);
}
@Test
public void testThatToXContentWritesInteger() throws Exception {
ThreadPool.Info info = new ThreadPool.Info("foo", "search", 1, 10, TimeValue.timeValueMillis(3000), SizeValue.parseSizeValue("1k"));
XContentBuilder builder = jsonBuilder();
builder.startObject();
info.toXContent(builder, ToXContent.EMPTY_PARAMS);
builder.endObject();
BytesReference bytesReference = builder.bytes();
Map<String, Object> map;
try (XContentParser parser = XContentFactory.xContent(bytesReference).createParser(bytesReference)) {
map = parser.map();
}
assertThat(map, hasKey("foo"));
map = (Map<String, Object>) map.get("foo");
assertThat(map, hasKey("queue_size"));
assertThat(map.get("queue_size").toString(), is("1000"));
}
}

View File

@ -55,3 +55,7 @@ headers by default. Verbosity can be turned off with the `v` parameter:
GET _cat/shards?v=0
-----------------
==== Nodes Stats API
Queue lengths are now reported as basic numeric so they can easily processed by code. Before we used a human
readable format. For example, a queue with 1,000 items is now reported as `1000` instead of `1k`.