Skip to content

Commit 71e254c

Browse files
author
Srikanth Padakanti
committed
Initial chekpoint Feature Request - Add support for a ForkJoinPool type
Signed-off-by: Srikanth Padakanti <[email protected]>
1 parent 30024e3 commit 71e254c

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

server/src/main/java/org/opensearch/threadpool/ThreadPool.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,22 +1039,31 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
10391039
builder.field("core", min);
10401040
assert max != -1;
10411041
builder.field("max", max);
1042+
if (keepAlive != null) {
1043+
builder.field("keep_alive", keepAlive.toString());
1044+
}
1045+
if (queueSize == null) {
1046+
builder.field("queue_size", -1);
1047+
} else {
1048+
builder.field("queue_size", queueSize.singles());
1049+
}
10421050
} else if (type == ThreadPoolType.FORK_JOIN) {
10431051
builder.field("size", -1);
10441052
builder.field("min", -1);
10451053
builder.field("max", -1);
10461054
builder.field("keep_alive", (Object) null);
1055+
builder.field("queue_size", -1);
10471056
} else {
10481057
assert max != -1;
10491058
builder.field("size", max);
1050-
}
1051-
if (keepAlive != null) {
1052-
builder.field("keep_alive", keepAlive.toString());
1053-
}
1054-
if (queueSize == null) {
1055-
builder.field("queue_size", -1);
1056-
} else {
1057-
builder.field("queue_size", queueSize.singles());
1059+
if (keepAlive != null) {
1060+
builder.field("keep_alive", keepAlive.toString());
1061+
}
1062+
if (queueSize == null) {
1063+
builder.field("queue_size", -1);
1064+
} else {
1065+
builder.field("queue_size", queueSize.singles());
1066+
}
10581067
}
10591068
builder.endObject();
10601069
return builder;

server/src/test/java/org/opensearch/threadpool/ThreadPoolSerializationTests.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ public void testThatToXContentWritesInteger() throws Exception {
130130
assertThat(map, hasKey("foo"));
131131
map = (Map<String, Object>) map.get("foo");
132132
assertThat(map, hasKey("queue_size"));
133-
assertThat(map.get("queue_size").toString(), is("1000"));
133+
if (threadPoolType == ThreadPool.ThreadPoolType.FORK_JOIN) {
134+
// ForkJoinPool always writes queue_size as -1
135+
assertThat(map.get("queue_size").toString(), is("-1"));
136+
} else {
137+
assertThat(map.get("queue_size").toString(), is("1000"));
138+
}
134139
}
135140

136141
public void testThatThreadPoolTypeIsSerializedCorrectly() throws IOException {

0 commit comments

Comments
 (0)