Skip to content

Commit 40d4538

Browse files
committed
Revert "Align thread pool info to thread pool configuration (#29123)"
This reverts commit 1798c9f.
1 parent ca799f4 commit 40d4538

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

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

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
import java.util.concurrent.ScheduledThreadPoolExecutor;
5959
import java.util.concurrent.ThreadPoolExecutor;
6060
import java.util.concurrent.TimeUnit;
61-
import java.util.stream.Collectors;
6261

6362
import static java.util.Collections.unmodifiableMap;
6463

@@ -139,9 +138,7 @@ public static ThreadPoolType fromType(String type) {
139138
THREAD_POOL_TYPES = Collections.unmodifiableMap(map);
140139
}
141140

142-
private final Map<String, ExecutorHolder> executors;
143-
144-
private final ThreadPoolInfo threadPoolInfo;
141+
private Map<String, ExecutorHolder> executors = new HashMap<>();
145142

146143
private final CachedTimeThread cachedTimeThread;
147144

@@ -210,15 +207,6 @@ public ThreadPool(final Settings settings, final ExecutorBuilder<?>... customBui
210207

211208
executors.put(Names.SAME, new ExecutorHolder(DIRECT_EXECUTOR, new Info(Names.SAME, ThreadPoolType.DIRECT)));
212209
this.executors = unmodifiableMap(executors);
213-
214-
final List<Info> infos =
215-
executors
216-
.values()
217-
.stream()
218-
.filter(holder -> holder.info.getName().equals("same") == false)
219-
.map(holder -> holder.info)
220-
.collect(Collectors.toList());
221-
this.threadPoolInfo = new ThreadPoolInfo(infos);
222210
this.scheduler = Scheduler.initScheduler(settings);
223211
TimeValue estimatedTimeInterval = ESTIMATED_TIME_INTERVAL_SETTING.get(settings);
224212
this.cachedTimeThread = new CachedTimeThread(EsExecutors.threadName(settings, "[timer]"), estimatedTimeInterval.millis());
@@ -251,7 +239,16 @@ public Counter estimatedTimeInMillisCounter() {
251239
}
252240

253241
public ThreadPoolInfo info() {
254-
return threadPoolInfo;
242+
List<Info> infos = new ArrayList<>();
243+
for (ExecutorHolder holder : executors.values()) {
244+
String name = holder.info.getName();
245+
// no need to have info on "same" thread pool
246+
if ("same".equals(name)) {
247+
continue;
248+
}
249+
infos.add(holder.info);
250+
}
251+
return new ThreadPoolInfo(infos);
255252
}
256253

257254
public Info info(String name) {
@@ -658,29 +655,32 @@ public SizeValue getQueueSize() {
658655
@Override
659656
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
660657
builder.startObject(name);
661-
builder.field("type", type.getType());
662-
663-
if (type == ThreadPoolType.SCALING) {
664-
assert min != -1;
665-
builder.field("core", min);
666-
assert max != -1;
667-
builder.field("max", max);
668-
} else {
669-
assert max != -1;
670-
builder.field("size", max);
658+
builder.field(Fields.TYPE, type.getType());
659+
if (min != -1) {
660+
builder.field(Fields.MIN, min);
661+
}
662+
if (max != -1) {
663+
builder.field(Fields.MAX, max);
671664
}
672665
if (keepAlive != null) {
673-
builder.field("keep_alive", keepAlive.toString());
666+
builder.field(Fields.KEEP_ALIVE, keepAlive.toString());
674667
}
675668
if (queueSize == null) {
676-
builder.field("queue_size", -1);
669+
builder.field(Fields.QUEUE_SIZE, -1);
677670
} else {
678-
builder.field("queue_size", queueSize.singles());
671+
builder.field(Fields.QUEUE_SIZE, queueSize.singles());
679672
}
680673
builder.endObject();
681674
return builder;
682675
}
683676

677+
static final class Fields {
678+
static final String TYPE = "type";
679+
static final String MIN = "min";
680+
static final String MAX = "max";
681+
static final String KEEP_ALIVE = "keep_alive";
682+
static final String QUEUE_SIZE = "queue_size";
683+
}
684684
}
685685

686686
/**

0 commit comments

Comments
 (0)