Remove unneeded usages of listenable futures (elastic/x-pack-elasticsearch#1261)

This is related to elastic/elasticsearch#24412. That commit changed how
ListenableActionFuture implementations are created. This commit
updates x-pack to be compatible with those changes. In particular, all
the usages of ListenableActionFuture in x-pack could be replaced with
PlainActionFuture as the "listening" functionality was not being used.

Original commit: elastic/x-pack-elasticsearch@7c8d8e3df9
This commit is contained in:
Tim Brooks 2017-05-03 09:23:39 -05:00 committed by GitHub
parent d140b3028d
commit 106a26b399
2 changed files with 63 additions and 96 deletions

View File

@ -7,7 +7,7 @@ package org.elasticsearch.xpack.ml.client;
import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.PlainListenableActionFuture; import org.elasticsearch.action.support.PlainActionFuture;
import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.xpack.ml.action.CloseJobAction; import org.elasticsearch.xpack.ml.action.CloseJobAction;
import org.elasticsearch.xpack.ml.action.DeleteDatafeedAction; import org.elasticsearch.xpack.ml.action.DeleteDatafeedAction;
@ -51,8 +51,7 @@ public class MachineLearningClient {
} }
public ActionFuture<CloseJobAction.Response> closeJob(CloseJobAction.Request request) { public ActionFuture<CloseJobAction.Response> closeJob(CloseJobAction.Request request) {
PlainListenableActionFuture<CloseJobAction.Response> listener = PlainActionFuture<CloseJobAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(CloseJobAction.INSTANCE, request, listener); client.execute(CloseJobAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -64,8 +63,7 @@ public class MachineLearningClient {
public ActionFuture<DeleteDatafeedAction.Response> deleteDatafeed( public ActionFuture<DeleteDatafeedAction.Response> deleteDatafeed(
DeleteDatafeedAction.Request request) { DeleteDatafeedAction.Request request) {
PlainListenableActionFuture<DeleteDatafeedAction.Response> listener = PlainActionFuture<DeleteDatafeedAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(DeleteDatafeedAction.INSTANCE, request, listener); client.execute(DeleteDatafeedAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -77,8 +75,7 @@ public class MachineLearningClient {
public ActionFuture<DeleteFilterAction.Response> deleteFilter( public ActionFuture<DeleteFilterAction.Response> deleteFilter(
DeleteFilterAction.Request request) { DeleteFilterAction.Request request) {
PlainListenableActionFuture<DeleteFilterAction.Response> listener = PlainActionFuture<DeleteFilterAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(DeleteFilterAction.INSTANCE, request, listener); client.execute(DeleteFilterAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -89,8 +86,7 @@ public class MachineLearningClient {
} }
public ActionFuture<DeleteJobAction.Response> deleteJob(DeleteJobAction.Request request) { public ActionFuture<DeleteJobAction.Response> deleteJob(DeleteJobAction.Request request) {
PlainListenableActionFuture<DeleteJobAction.Response> listener = PlainActionFuture<DeleteJobAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(DeleteJobAction.INSTANCE, request, listener); client.execute(DeleteJobAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -102,8 +98,7 @@ public class MachineLearningClient {
public ActionFuture<DeleteModelSnapshotAction.Response> deleteModelSnapshot( public ActionFuture<DeleteModelSnapshotAction.Response> deleteModelSnapshot(
DeleteModelSnapshotAction.Request request) { DeleteModelSnapshotAction.Request request) {
PlainListenableActionFuture<DeleteModelSnapshotAction.Response> listener = PlainActionFuture<DeleteModelSnapshotAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(DeleteModelSnapshotAction.INSTANCE, request, listener); client.execute(DeleteModelSnapshotAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -114,8 +109,7 @@ public class MachineLearningClient {
} }
public ActionFuture<FlushJobAction.Response> flushJob(FlushJobAction.Request request) { public ActionFuture<FlushJobAction.Response> flushJob(FlushJobAction.Request request) {
PlainListenableActionFuture<FlushJobAction.Response> listener = PlainActionFuture<FlushJobAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(FlushJobAction.INSTANCE, request, listener); client.execute(FlushJobAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -126,8 +120,7 @@ public class MachineLearningClient {
} }
public ActionFuture<GetBucketsAction.Response> getBuckets(GetBucketsAction.Request request) { public ActionFuture<GetBucketsAction.Response> getBuckets(GetBucketsAction.Request request) {
PlainListenableActionFuture<GetBucketsAction.Response> listener = PlainActionFuture<GetBucketsAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(GetBucketsAction.INSTANCE, request, listener); client.execute(GetBucketsAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -139,8 +132,7 @@ public class MachineLearningClient {
public ActionFuture<GetCategoriesAction.Response> getCategories( public ActionFuture<GetCategoriesAction.Response> getCategories(
GetCategoriesAction.Request request) { GetCategoriesAction.Request request) {
PlainListenableActionFuture<GetCategoriesAction.Response> listener = PlainActionFuture<GetCategoriesAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(GetCategoriesAction.INSTANCE, request, listener); client.execute(GetCategoriesAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -152,8 +144,7 @@ public class MachineLearningClient {
public ActionFuture<GetDatafeedsAction.Response> getDatafeeds( public ActionFuture<GetDatafeedsAction.Response> getDatafeeds(
GetDatafeedsAction.Request request) { GetDatafeedsAction.Request request) {
PlainListenableActionFuture<GetDatafeedsAction.Response> listener = PlainActionFuture<GetDatafeedsAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(GetDatafeedsAction.INSTANCE, request, listener); client.execute(GetDatafeedsAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -165,8 +156,7 @@ public class MachineLearningClient {
public ActionFuture<GetDatafeedsStatsAction.Response> getDatafeedsStats( public ActionFuture<GetDatafeedsStatsAction.Response> getDatafeedsStats(
GetDatafeedsStatsAction.Request request) { GetDatafeedsStatsAction.Request request) {
PlainListenableActionFuture<GetDatafeedsStatsAction.Response> listener = PlainActionFuture<GetDatafeedsStatsAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(GetDatafeedsStatsAction.INSTANCE, request, listener); client.execute(GetDatafeedsStatsAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -177,21 +167,19 @@ public class MachineLearningClient {
} }
public ActionFuture<GetFiltersAction.Response> getFilters(GetFiltersAction.Request request) { public ActionFuture<GetFiltersAction.Response> getFilters(GetFiltersAction.Request request) {
PlainListenableActionFuture<GetFiltersAction.Response> listener = PlainActionFuture<GetFiltersAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(GetFiltersAction.INSTANCE, request, listener); client.execute(GetFiltersAction.INSTANCE, request, listener);
return listener; return listener;
} }
public void getInfluencers(GetInfluencersAction.Request request, public void getInfluencers(GetInfluencersAction.Request request,
ActionListener<GetInfluencersAction.Response> listener) { ActionListener<GetInfluencersAction.Response> listener) {
client.execute(GetInfluencersAction.INSTANCE, request, listener); client.execute(GetInfluencersAction.INSTANCE, request, listener);
} }
public ActionFuture<GetInfluencersAction.Response> getInfluencers( public ActionFuture<GetInfluencersAction.Response> getInfluencers(
GetInfluencersAction.Request request) { GetInfluencersAction.Request request) {
PlainListenableActionFuture<GetInfluencersAction.Response> listener = PlainActionFuture<GetInfluencersAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(GetInfluencersAction.INSTANCE, request, listener); client.execute(GetInfluencersAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -202,8 +190,7 @@ public class MachineLearningClient {
} }
public ActionFuture<GetJobsAction.Response> getJobs(GetJobsAction.Request request) { public ActionFuture<GetJobsAction.Response> getJobs(GetJobsAction.Request request) {
PlainListenableActionFuture<GetJobsAction.Response> listener = PlainActionFuture<GetJobsAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(GetJobsAction.INSTANCE, request, listener); client.execute(GetJobsAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -215,8 +202,7 @@ public class MachineLearningClient {
public ActionFuture<GetJobsStatsAction.Response> getJobsStats( public ActionFuture<GetJobsStatsAction.Response> getJobsStats(
GetJobsStatsAction.Request request) { GetJobsStatsAction.Request request) {
PlainListenableActionFuture<GetJobsStatsAction.Response> listener = PlainActionFuture<GetJobsStatsAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(GetJobsStatsAction.INSTANCE, request, listener); client.execute(GetJobsStatsAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -228,8 +214,7 @@ public class MachineLearningClient {
public ActionFuture<GetModelSnapshotsAction.Response> getModelSnapshots( public ActionFuture<GetModelSnapshotsAction.Response> getModelSnapshots(
GetModelSnapshotsAction.Request request) { GetModelSnapshotsAction.Request request) {
PlainListenableActionFuture<GetModelSnapshotsAction.Response> listener = PlainActionFuture<GetModelSnapshotsAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(GetModelSnapshotsAction.INSTANCE, request, listener); client.execute(GetModelSnapshotsAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -240,8 +225,7 @@ public class MachineLearningClient {
} }
public ActionFuture<GetRecordsAction.Response> getRecords(GetRecordsAction.Request request) { public ActionFuture<GetRecordsAction.Response> getRecords(GetRecordsAction.Request request) {
PlainListenableActionFuture<GetRecordsAction.Response> listener = PlainActionFuture<GetRecordsAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(GetRecordsAction.INSTANCE, request, listener); client.execute(GetRecordsAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -252,8 +236,7 @@ public class MachineLearningClient {
} }
public ActionFuture<OpenJobAction.Response> openJob(OpenJobAction.Request request) { public ActionFuture<OpenJobAction.Response> openJob(OpenJobAction.Request request) {
PlainListenableActionFuture<OpenJobAction.Response> listener = PlainActionFuture<OpenJobAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(OpenJobAction.INSTANCE, request, listener); client.execute(OpenJobAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -264,8 +247,7 @@ public class MachineLearningClient {
} }
public ActionFuture<PostDataAction.Response> postData(PostDataAction.Request request) { public ActionFuture<PostDataAction.Response> postData(PostDataAction.Request request) {
PlainListenableActionFuture<PostDataAction.Response> listener = PlainActionFuture<PostDataAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(PostDataAction.INSTANCE, request, listener); client.execute(PostDataAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -276,8 +258,7 @@ public class MachineLearningClient {
} }
public ActionFuture<PutDatafeedAction.Response> putDatafeed(PutDatafeedAction.Request request) { public ActionFuture<PutDatafeedAction.Response> putDatafeed(PutDatafeedAction.Request request) {
PlainListenableActionFuture<PutDatafeedAction.Response> listener = PlainActionFuture<PutDatafeedAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(PutDatafeedAction.INSTANCE, request, listener); client.execute(PutDatafeedAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -288,8 +269,7 @@ public class MachineLearningClient {
} }
public ActionFuture<PutFilterAction.Response> putFilter(PutFilterAction.Request request) { public ActionFuture<PutFilterAction.Response> putFilter(PutFilterAction.Request request) {
PlainListenableActionFuture<PutFilterAction.Response> listener = PlainActionFuture<PutFilterAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(PutFilterAction.INSTANCE, request, listener); client.execute(PutFilterAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -300,8 +280,7 @@ public class MachineLearningClient {
} }
public ActionFuture<PutJobAction.Response> putJob(PutJobAction.Request request) { public ActionFuture<PutJobAction.Response> putJob(PutJobAction.Request request) {
PlainListenableActionFuture<PutJobAction.Response> listener = PlainActionFuture<PutJobAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(PutJobAction.INSTANCE, request, listener); client.execute(PutJobAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -313,8 +292,7 @@ public class MachineLearningClient {
public ActionFuture<RevertModelSnapshotAction.Response> revertModelSnapshot( public ActionFuture<RevertModelSnapshotAction.Response> revertModelSnapshot(
RevertModelSnapshotAction.Request request) { RevertModelSnapshotAction.Request request) {
PlainListenableActionFuture<RevertModelSnapshotAction.Response> listener = PlainActionFuture<RevertModelSnapshotAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(RevertModelSnapshotAction.INSTANCE, request, listener); client.execute(RevertModelSnapshotAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -326,8 +304,7 @@ public class MachineLearningClient {
public ActionFuture<StartDatafeedAction.Response> startDatafeed( public ActionFuture<StartDatafeedAction.Response> startDatafeed(
StartDatafeedAction.Request request) { StartDatafeedAction.Request request) {
PlainListenableActionFuture<StartDatafeedAction.Response> listener = PlainActionFuture<StartDatafeedAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(StartDatafeedAction.INSTANCE, request, listener); client.execute(StartDatafeedAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -339,8 +316,7 @@ public class MachineLearningClient {
public ActionFuture<StopDatafeedAction.Response> stopDatafeed( public ActionFuture<StopDatafeedAction.Response> stopDatafeed(
StopDatafeedAction.Request request) { StopDatafeedAction.Request request) {
PlainListenableActionFuture<StopDatafeedAction.Response> listener = PlainActionFuture<StopDatafeedAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(StopDatafeedAction.INSTANCE, request, listener); client.execute(StopDatafeedAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -352,8 +328,7 @@ public class MachineLearningClient {
public ActionFuture<PutDatafeedAction.Response> updateDatafeed( public ActionFuture<PutDatafeedAction.Response> updateDatafeed(
UpdateDatafeedAction.Request request) { UpdateDatafeedAction.Request request) {
PlainListenableActionFuture<PutDatafeedAction.Response> listener = PlainActionFuture<PutDatafeedAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(UpdateDatafeedAction.INSTANCE, request, listener); client.execute(UpdateDatafeedAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -364,8 +339,7 @@ public class MachineLearningClient {
} }
public ActionFuture<PutJobAction.Response> updateJob(UpdateJobAction.Request request) { public ActionFuture<PutJobAction.Response> updateJob(UpdateJobAction.Request request) {
PlainListenableActionFuture<PutJobAction.Response> listener = PlainActionFuture<PutJobAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(UpdateJobAction.INSTANCE, request, listener); client.execute(UpdateJobAction.INSTANCE, request, listener);
return listener; return listener;
} }
@ -377,8 +351,7 @@ public class MachineLearningClient {
public ActionFuture<UpdateModelSnapshotAction.Response> updateModelSnapshot( public ActionFuture<UpdateModelSnapshotAction.Response> updateModelSnapshot(
UpdateModelSnapshotAction.Request request) { UpdateModelSnapshotAction.Request request) {
PlainListenableActionFuture<UpdateModelSnapshotAction.Response> listener = PlainActionFuture<UpdateModelSnapshotAction.Response> listener = PlainActionFuture.newFuture();
new PlainListenableActionFuture<>(client.threadPool());
client.execute(UpdateModelSnapshotAction.INSTANCE, request, listener); client.execute(UpdateModelSnapshotAction.INSTANCE, request, listener);
return listener; return listener;
} }

View File

@ -6,7 +6,7 @@
package org.elasticsearch.license; package org.elasticsearch.license;
import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.action.support.PlainListenableActionFuture; import org.elasticsearch.action.support.PlainActionFuture;
import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
@ -58,7 +58,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do not work // test that license restricted apis do not work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> listener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<PutJobAction.Response> listener = PlainActionFuture. newFuture();
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), listener); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), listener);
listener.actionGet(); listener.actionGet();
fail("put job action should not be enabled!"); fail("put job action should not be enabled!");
@ -75,7 +75,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work // test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> listener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<PutJobAction.Response> listener = PlainActionFuture.newFuture();
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), listener); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), listener);
PutJobAction.Response response = listener.actionGet(); PutJobAction.Response response = listener.actionGet();
assertNotNull(response); assertNotNull(response);
@ -88,7 +88,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work // test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> putJobListener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<PutJobAction.Response> putJobListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener);
PutJobAction.Response response = putJobListener.actionGet(); PutJobAction.Response response = putJobListener.actionGet();
assertNotNull(response); assertNotNull(response);
@ -101,7 +101,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do not work // test that license restricted apis do not work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<OpenJobAction.Response> listener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<OpenJobAction.Response> listener = PlainActionFuture.newFuture();
new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), listener); new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), listener);
listener.actionGet(); listener.actionGet();
fail("open job action should not be enabled!"); fail("open job action should not be enabled!");
@ -125,7 +125,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work // test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<OpenJobAction.Response> listener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<OpenJobAction.Response> listener = PlainActionFuture.newFuture();
new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), listener); new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), listener);
OpenJobAction.Response response = listener.actionGet(); OpenJobAction.Response response = listener.actionGet();
assertNotNull(response); assertNotNull(response);
@ -138,7 +138,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work // test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> putJobListener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<PutJobAction.Response> putJobListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener);
PutJobAction.Response putJobResponse = putJobListener.actionGet(); PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse); assertNotNull(putJobResponse);
@ -151,7 +151,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do not work // test that license restricted apis do not work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutDatafeedAction.Response> listener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<PutDatafeedAction.Response> listener = PlainActionFuture.newFuture();
new MachineLearningClient(client).putDatafeed( new MachineLearningClient(client).putDatafeed(
new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), listener); new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), listener);
listener.actionGet(); listener.actionGet();
@ -169,7 +169,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work // test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutDatafeedAction.Response> listener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<PutDatafeedAction.Response> listener = PlainActionFuture.newFuture();
new MachineLearningClient(client).putDatafeed( new MachineLearningClient(client).putDatafeed(
new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), listener); new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), listener);
PutDatafeedAction.Response response = listener.actionGet(); PutDatafeedAction.Response response = listener.actionGet();
@ -183,24 +183,23 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
// put job // put job
PlainListenableActionFuture<PutJobAction.Response> putJobListener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<PutJobAction.Response> putJobListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener);
PutJobAction.Response putJobResponse = putJobListener.actionGet(); PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse); assertNotNull(putJobResponse);
// put datafeed // put datafeed
PlainListenableActionFuture<PutDatafeedAction.Response> putDatafeedListener = new PlainListenableActionFuture<>( PlainActionFuture<PutDatafeedAction.Response> putDatafeedListener = PlainActionFuture.newFuture();
client.threadPool());
new MachineLearningClient(client).putDatafeed( new MachineLearningClient(client).putDatafeed(
new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), putDatafeedListener); new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), putDatafeedListener);
PutDatafeedAction.Response putDatafeedResponse = putDatafeedListener.actionGet(); PutDatafeedAction.Response putDatafeedResponse = putDatafeedListener.actionGet();
assertNotNull(putDatafeedResponse); assertNotNull(putDatafeedResponse);
// open job // open job
PlainListenableActionFuture<OpenJobAction.Response> openJobListener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<OpenJobAction.Response> openJobListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), openJobListener); new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), openJobListener);
OpenJobAction.Response openJobResponse = openJobListener.actionGet(); OpenJobAction.Response openJobResponse = openJobListener.actionGet();
assertNotNull(openJobResponse); assertNotNull(openJobResponse);
// start datafeed // start datafeed
PlainListenableActionFuture<StartDatafeedAction.Response> listener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<StartDatafeedAction.Response> listener = PlainActionFuture.newFuture();
new MachineLearningClient(client).startDatafeed(new StartDatafeedAction.Request("foobar", 0L), listener); new MachineLearningClient(client).startDatafeed(new StartDatafeedAction.Request("foobar", 0L), listener);
listener.actionGet(); listener.actionGet();
} }
@ -231,12 +230,12 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
// open job // open job
PlainListenableActionFuture<OpenJobAction.Response> openJobListener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<OpenJobAction.Response> openJobListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), openJobListener); new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), openJobListener);
OpenJobAction.Response openJobResponse = openJobListener.actionGet(); OpenJobAction.Response openJobResponse = openJobListener.actionGet();
assertNotNull(openJobResponse); assertNotNull(openJobResponse);
// start datafeed // start datafeed
PlainListenableActionFuture<StartDatafeedAction.Response> listener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<StartDatafeedAction.Response> listener = PlainActionFuture.newFuture();
new MachineLearningClient(client).startDatafeed(new StartDatafeedAction.Request("foobar", 0L), listener); new MachineLearningClient(client).startDatafeed(new StartDatafeedAction.Request("foobar", 0L), listener);
listener.actionGet(); listener.actionGet();
} }
@ -281,17 +280,16 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work // test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> putJobListener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<PutJobAction.Response> putJobListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener);
PutJobAction.Response putJobResponse = putJobListener.actionGet(); PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse); assertNotNull(putJobResponse);
PlainListenableActionFuture<PutDatafeedAction.Response> putDatafeedListener = new PlainListenableActionFuture<>( PlainActionFuture<PutDatafeedAction.Response> putDatafeedListener = PlainActionFuture.newFuture();
client.threadPool());
new MachineLearningClient(client).putDatafeed( new MachineLearningClient(client).putDatafeed(
new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), putDatafeedListener); new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), putDatafeedListener);
PutDatafeedAction.Response putDatafeedResponse = putDatafeedListener.actionGet(); PutDatafeedAction.Response putDatafeedResponse = putDatafeedListener.actionGet();
assertNotNull(putDatafeedResponse); assertNotNull(putDatafeedResponse);
PlainListenableActionFuture<OpenJobAction.Response> openJobListener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<OpenJobAction.Response> openJobListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), openJobListener); new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), openJobListener);
OpenJobAction.Response openJobResponse = openJobListener.actionGet(); OpenJobAction.Response openJobResponse = openJobListener.actionGet();
assertNotNull(openJobResponse); assertNotNull(openJobResponse);
@ -314,7 +312,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do not work // test that license restricted apis do not work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<StartDatafeedAction.Response> listener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<StartDatafeedAction.Response> listener = PlainActionFuture.newFuture();
new MachineLearningClient(client).startDatafeed(new StartDatafeedAction.Request("foobar", 0L), listener); new MachineLearningClient(client).startDatafeed(new StartDatafeedAction.Request("foobar", 0L), listener);
listener.actionGet(); listener.actionGet();
fail("start datafeed action should not be enabled!"); fail("start datafeed action should not be enabled!");
@ -332,12 +330,12 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
// re-open job now that the license is valid again // re-open job now that the license is valid again
PlainListenableActionFuture<OpenJobAction.Response> openJobListener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<OpenJobAction.Response> openJobListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), openJobListener); new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), openJobListener);
OpenJobAction.Response openJobResponse = openJobListener.actionGet(); OpenJobAction.Response openJobResponse = openJobListener.actionGet();
assertNotNull(openJobResponse); assertNotNull(openJobResponse);
PlainListenableActionFuture<StartDatafeedAction.Response> listener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<StartDatafeedAction.Response> listener = PlainActionFuture.newFuture();
new MachineLearningClient(client).startDatafeed(new StartDatafeedAction.Request("foobar", 0L), listener); new MachineLearningClient(client).startDatafeed(new StartDatafeedAction.Request("foobar", 0L), listener);
StartDatafeedAction.Response response = listener.actionGet(); StartDatafeedAction.Response response = listener.actionGet();
assertNotNull(response); assertNotNull(response);
@ -351,22 +349,20 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work // test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> putJobListener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<PutJobAction.Response> putJobListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener);
PutJobAction.Response putJobResponse = putJobListener.actionGet(); PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse); assertNotNull(putJobResponse);
PlainListenableActionFuture<PutDatafeedAction.Response> putDatafeedListener = new PlainListenableActionFuture<>( PlainActionFuture<PutDatafeedAction.Response> putDatafeedListener = PlainActionFuture.newFuture();
client.threadPool());
new MachineLearningClient(client).putDatafeed( new MachineLearningClient(client).putDatafeed(
new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), putDatafeedListener); new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), putDatafeedListener);
PutDatafeedAction.Response putDatafeedResponse = putDatafeedListener.actionGet(); PutDatafeedAction.Response putDatafeedResponse = putDatafeedListener.actionGet();
assertNotNull(putDatafeedResponse); assertNotNull(putDatafeedResponse);
PlainListenableActionFuture<OpenJobAction.Response> openJobListener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<OpenJobAction.Response> openJobListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), openJobListener); new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), openJobListener);
OpenJobAction.Response openJobResponse = openJobListener.actionGet(); OpenJobAction.Response openJobResponse = openJobListener.actionGet();
assertNotNull(openJobResponse); assertNotNull(openJobResponse);
PlainListenableActionFuture<StartDatafeedAction.Response> startDatafeedListener = new PlainListenableActionFuture<>( PlainActionFuture<StartDatafeedAction.Response> startDatafeedListener = PlainActionFuture.newFuture();
client.threadPool());
new MachineLearningClient(client).startDatafeed(new StartDatafeedAction.Request("foobar", 0L), startDatafeedListener); new MachineLearningClient(client).startDatafeed(new StartDatafeedAction.Request("foobar", 0L), startDatafeedListener);
StartDatafeedAction.Response startDatafeedResponse = startDatafeedListener.actionGet(); StartDatafeedAction.Response startDatafeedResponse = startDatafeedListener.actionGet();
assertNotNull(startDatafeedResponse); assertNotNull(startDatafeedResponse);
@ -381,8 +377,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<StopDatafeedAction.Response> listener = new PlainListenableActionFuture<>( PlainActionFuture<StopDatafeedAction.Response> listener = PlainActionFuture.newFuture();
client.threadPool());
new MachineLearningClient(client).stopDatafeed(new StopDatafeedAction.Request("foobar"), listener); new MachineLearningClient(client).stopDatafeed(new StopDatafeedAction.Request("foobar"), listener);
if (invalidLicense) { if (invalidLicense) {
// the stop datafeed due to invalid license happens async, so check if the datafeed turns into stopped state: // the stop datafeed due to invalid license happens async, so check if the datafeed turns into stopped state:
@ -403,11 +398,11 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work // test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> putJobListener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<PutJobAction.Response> putJobListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener);
PutJobAction.Response putJobResponse = putJobListener.actionGet(); PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse); assertNotNull(putJobResponse);
PlainListenableActionFuture<OpenJobAction.Response> openJobListener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<OpenJobAction.Response> openJobListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), openJobListener); new MachineLearningClient(client).openJob(new OpenJobAction.Request("foo"), openJobListener);
OpenJobAction.Response openJobResponse = openJobListener.actionGet(); OpenJobAction.Response openJobResponse = openJobListener.actionGet();
assertNotNull(openJobResponse); assertNotNull(openJobResponse);
@ -422,7 +417,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<CloseJobAction.Response> listener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<CloseJobAction.Response> listener = PlainActionFuture.newFuture();
CloseJobAction.Request request = new CloseJobAction.Request("foo"); CloseJobAction.Request request = new CloseJobAction.Request("foo");
request.setCloseTimeout(TimeValue.timeValueSeconds(20)); request.setCloseTimeout(TimeValue.timeValueSeconds(20));
if (invalidLicense) { if (invalidLicense) {
@ -445,7 +440,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work // test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> putJobListener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<PutJobAction.Response> putJobListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener);
PutJobAction.Response putJobResponse = putJobListener.actionGet(); PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse); assertNotNull(putJobResponse);
@ -457,7 +452,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<DeleteJobAction.Response> listener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<DeleteJobAction.Response> listener = PlainActionFuture.newFuture();
new MachineLearningClient(client).deleteJob(new DeleteJobAction.Request("foo"), listener); new MachineLearningClient(client).deleteJob(new DeleteJobAction.Request("foo"), listener);
listener.actionGet(); listener.actionGet();
} }
@ -469,12 +464,11 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work // test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<PutJobAction.Response> putJobListener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<PutJobAction.Response> putJobListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener); new MachineLearningClient(client).putJob(new PutJobAction.Request(createJob("foo")), putJobListener);
PutJobAction.Response putJobResponse = putJobListener.actionGet(); PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse); assertNotNull(putJobResponse);
PlainListenableActionFuture<PutDatafeedAction.Response> putDatafeedListener = new PlainListenableActionFuture<>( PlainActionFuture<PutDatafeedAction.Response> putDatafeedListener = PlainActionFuture.newFuture();
client.threadPool());
new MachineLearningClient(client).putDatafeed( new MachineLearningClient(client).putDatafeed(
new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), putDatafeedListener); new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), putDatafeedListener);
PutDatafeedAction.Response putDatafeedResponse = putDatafeedListener.actionGet(); PutDatafeedAction.Response putDatafeedResponse = putDatafeedListener.actionGet();
@ -487,7 +481,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) { try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress()); client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<DeleteDatafeedAction.Response> listener = new PlainListenableActionFuture<>(client.threadPool()); PlainActionFuture<DeleteDatafeedAction.Response> listener = PlainActionFuture.newFuture();
new MachineLearningClient(client).deleteDatafeed(new DeleteDatafeedAction.Request("foobar"), listener); new MachineLearningClient(client).deleteDatafeed(new DeleteDatafeedAction.Request("foobar"), listener);
listener.actionGet(); listener.actionGet();
} }