Skip to content

Commit b20e2fc

Browse files
authored
[8.12] Add stable ThreadPool constructor to LogstashInternalBridge (#105163) (#105165)
1 parent 9c3015d commit b20e2fc

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

docs/changelog/105165.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 105165
2+
summary: Backport stable `ThreadPool` constructor from `LogstashInternalBridge`
3+
area: Ingest Node
4+
type: bug
5+
issues: []

server/src/main/java/org/elasticsearch/ingest/LogstashInternalBridge.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
package org.elasticsearch.ingest;
1010

11+
import org.elasticsearch.common.settings.Settings;
12+
import org.elasticsearch.threadpool.ThreadPool;
13+
1114
/**
1215
* This Elastic-internal API bridge class exposes package-private components of Ingest
1316
* in a way that can be consumed by Logstash's Elastic Integration Filter without
@@ -33,4 +36,12 @@ public static boolean isReroute(final IngestDocument ingestDocument) {
3336
public static void resetReroute(final IngestDocument ingestDocument) {
3437
ingestDocument.resetReroute();
3538
}
39+
40+
/**
41+
* @param settings
42+
* @return a new {@link ThreadPool}
43+
*/
44+
public static ThreadPool createThreadPool(final Settings settings) {
45+
return new ThreadPool(settings);
46+
}
3647
}

server/src/test/java/org/elasticsearch/ingest/LogstashInternalBridgeTests.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@
88

99
package org.elasticsearch.ingest;
1010

11+
import org.elasticsearch.common.settings.Settings;
12+
import org.elasticsearch.node.Node;
1113
import org.elasticsearch.test.ESTestCase;
14+
import org.elasticsearch.threadpool.ThreadPool;
15+
16+
import java.util.Objects;
17+
import java.util.concurrent.TimeUnit;
1218

1319
import static org.elasticsearch.ingest.TestIngestDocument.emptyIngestDocument;
1420
import static org.hamcrest.Matchers.equalTo;
1521
import static org.hamcrest.Matchers.is;
22+
import static org.hamcrest.Matchers.notNullValue;
1623

1724
public class LogstashInternalBridgeTests extends ESTestCase {
1825
public void testIngestDocumentRerouteBridge() {
@@ -29,4 +36,17 @@ public void testIngestDocumentRerouteBridge() {
2936
assertThat(ingestDocument.getFieldValue("_index", String.class), is(equalTo("somewhere")));
3037
assertThat(LogstashInternalBridge.isReroute(ingestDocument), is(false));
3138
}
39+
40+
public void testCreateThreadPool() {
41+
final Settings settings = Settings.builder().put(Node.NODE_NAME_SETTING.getKey(), "TEST").build();
42+
ThreadPool threadPool = null;
43+
try {
44+
threadPool = LogstashInternalBridge.createThreadPool(settings);
45+
assertThat(threadPool, is(notNullValue()));
46+
} finally {
47+
if (Objects.nonNull(threadPool)) {
48+
ThreadPool.terminate(threadPool, 10L, TimeUnit.SECONDS);
49+
}
50+
}
51+
}
3252
}

0 commit comments

Comments
 (0)