Skip to content

Commit bb6a907

Browse files
committed
migrate ThreadPoolBridge to interface pattern
1 parent eb43cde commit bb6a907

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

libs/logstash-bridge/src/main/java/org/elasticsearch/logstashbridge/threadpool/ThreadPoolBridge.java

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,38 @@
1919
/**
2020
* An external bridge for {@link ThreadPool}
2121
*/
22-
public class ThreadPoolBridge extends StableBridgeAPI.ProxyInternal<ThreadPool> {
22+
public interface ThreadPoolBridge extends StableBridgeAPI<ThreadPool> {
2323

24-
public ThreadPoolBridge(final SettingsBridge settingsBridge) {
25-
this(new ThreadPool(settingsBridge.toInternal(), MeterRegistry.NOOP, new DefaultBuiltInExecutorBuilders()));
26-
}
24+
long relativeTimeInMillis();
2725

28-
public ThreadPoolBridge(final ThreadPool delegate) {
29-
super(delegate);
30-
}
26+
long absoluteTimeInMillis();
3127

32-
public static boolean terminate(final ThreadPoolBridge pool, final long timeout, final TimeUnit timeUnit) {
33-
return ThreadPool.terminate(pool.toInternal(), timeout, timeUnit);
34-
}
28+
boolean terminate(long timeout, TimeUnit timeUnit);
3529

36-
public long relativeTimeInMillis() {
37-
return internalDelegate.relativeTimeInMillis();
30+
static ThreadPoolBridge create(final SettingsBridge bridgedSettings) {
31+
final ThreadPool internal = new ThreadPool(bridgedSettings.toInternal(), MeterRegistry.NOOP, new DefaultBuiltInExecutorBuilders());
32+
return new ProxyInternal(internal);
3833
}
3934

40-
public long absoluteTimeInMillis() {
41-
return internalDelegate.absoluteTimeInMillis();
35+
class ProxyInternal extends StableBridgeAPI.ProxyInternal<ThreadPool> implements ThreadPoolBridge {
36+
37+
ProxyInternal(final ThreadPool delegate) {
38+
super(delegate);
39+
}
40+
41+
@Override
42+
public long relativeTimeInMillis() {
43+
return internalDelegate.relativeTimeInMillis();
44+
}
45+
46+
@Override
47+
public long absoluteTimeInMillis() {
48+
return internalDelegate.absoluteTimeInMillis();
49+
}
50+
51+
@Override
52+
public boolean terminate(final long timeout, final TimeUnit timeUnit) {
53+
return ThreadPool.terminate(internalDelegate, timeout, timeUnit);
54+
}
4255
}
4356
}

0 commit comments

Comments
 (0)