Skip to content

Commit 7eb593c

Browse files
committed
Introduce bridges for FailProcessorException, Releasable and RefCountingRunnable ES core components.
1 parent 67a81ed commit 7eb593c

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.logstashbridge.core;
11+
12+
import org.elasticsearch.ingest.common.FailProcessorException;
13+
import org.elasticsearch.logstashbridge.StableBridgeAPI;
14+
15+
public class FailProcessorExceptionBridge extends StableBridgeAPI.ProxyInternal<FailProcessorException> {
16+
protected FailProcessorExceptionBridge(FailProcessorException internalDelegate) {
17+
super(internalDelegate);
18+
}
19+
20+
public static boolean isInstanceOf(Throwable exception) {
21+
return exception instanceof FailProcessorException;
22+
}
23+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.logstashbridge.core;
11+
12+
import org.elasticsearch.action.support.RefCountingRunnable;
13+
import org.elasticsearch.logstashbridge.StableBridgeAPI;
14+
15+
public class RefCountingRunnableBridge extends StableBridgeAPI.ProxyInternal<RefCountingRunnable> {
16+
17+
private RefCountingRunnableBridge(final RefCountingRunnable delegate) {
18+
super(delegate);
19+
}
20+
21+
public RefCountingRunnableBridge(final Runnable delegate) {
22+
super(new RefCountingRunnable(delegate));
23+
}
24+
25+
public void close() {
26+
toInternal().close();
27+
}
28+
29+
public ReleasableBridge acquire() {
30+
return new ReleasableBridge.ProxyInternal(toInternal().acquire());
31+
}
32+
33+
@Override
34+
public RefCountingRunnable toInternal() {
35+
return this.internalDelegate;
36+
}
37+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.logstashbridge.core;
11+
12+
import org.elasticsearch.core.Releasable;
13+
import org.elasticsearch.logstashbridge.StableBridgeAPI;
14+
15+
public interface ReleasableBridge extends StableBridgeAPI<Releasable> {
16+
17+
void close();
18+
19+
class ProxyInternal extends StableBridgeAPI.ProxyInternal<Releasable> implements ReleasableBridge {
20+
21+
public ProxyInternal(final Releasable delegate) {
22+
super(delegate);
23+
}
24+
25+
@Override
26+
public void close() {
27+
toInternal().close();
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)