In org.elasticsearch.client.transport.support
:
public <Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> void execute(final Action<Request, Response, RequestBuilder> action, final Request request, ActionListener<Response> listener) {
final TransportActionNodeProxy<Request, Response> proxy = proxies.get(action);
//try to get action "cluster:admin/watcher/watch/delete" but returns null
nodesService.execute(new TransportClientNodesService.NodeListenerCallback<Response>() {
@Override
public void doWithNode(DiscoveryNode node, ActionListener<Response> listener) {
proxy.execute(node, request, listener);//proxy is null, so get NPE
}
}, listener);
}
The code to create client:
client = TransportClient.builder().settings(
Settings.settingsBuilder().put("cluster.name", "elasticsearch_dc_001").build()
).build()
.addTransportAddress(
new InetSocketTransportAddress(
InetAddress.getByName("x.x.x.x"), 9300
)
);
The code to delete watch:
DeleteWatchResponse deleteWatchResponse = watcherClient.prepareDeleteWatch(getName(config)).setForce(true).get();
Full stack trace:
Exception in thread "main" java.lang.NullPointerException
at org.elasticsearch.client.transport.support.TransportProxyClient$1.doWithNode(TransportProxyClient.java:58)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:202)
at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:272)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:347)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)
at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:67)
at com.enniu.cloud.services.elasticsearch.WatcherManager.deleteWatch(WatcherManager.java:115)
at com.enniu.cloud.services.elasticsearch.WatcherManager.lambda$delete$2(WatcherManager.java:100)
at com.enniu.cloud.services.elasticsearch.WatcherManager$$Lambda$2/2128859746.apply(Unknown Source)
at com.enniu.cloud.services.elasticsearch.WatcherManager.performOnWatch(WatcherManager.java:109)
at com.enniu.cloud.services.elasticsearch.WatcherManager.delete(WatcherManager.java:99)
at com.enniu.cloud.services.elasticsearch.WatcherManager.main(WatcherManager.java:133)
JAVA API version:
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>watcher</artifactId>
<version>2.0.0-rc1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>license</artifactId>
<version>2.0.0-rc1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.0.0-rc1</version>
</dependency>