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

View File

@ -6,7 +6,7 @@
package org.elasticsearch.license;
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.cluster.ClusterState;
import org.elasticsearch.common.unit.TimeValue;
@ -58,7 +58,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do not work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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);
listener.actionGet();
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
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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);
PutJobAction.Response response = listener.actionGet();
assertNotNull(response);
@ -88,7 +88,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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);
PutJobAction.Response response = putJobListener.actionGet();
assertNotNull(response);
@ -101,7 +101,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do not work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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);
listener.actionGet();
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
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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);
OpenJobAction.Response response = listener.actionGet();
assertNotNull(response);
@ -138,7 +138,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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);
PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse);
@ -151,7 +151,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do not work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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 PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), listener);
listener.actionGet();
@ -169,7 +169,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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 PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), listener);
PutDatafeedAction.Response response = listener.actionGet();
@ -183,24 +183,23 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
// 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);
PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse);
// put datafeed
PlainListenableActionFuture<PutDatafeedAction.Response> putDatafeedListener = new PlainListenableActionFuture<>(
client.threadPool());
PlainActionFuture<PutDatafeedAction.Response> putDatafeedListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).putDatafeed(
new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), putDatafeedListener);
PutDatafeedAction.Response putDatafeedResponse = putDatafeedListener.actionGet();
assertNotNull(putDatafeedResponse);
// 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);
OpenJobAction.Response openJobResponse = openJobListener.actionGet();
assertNotNull(openJobResponse);
// 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);
listener.actionGet();
}
@ -231,12 +230,12 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
// 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);
OpenJobAction.Response openJobResponse = openJobListener.actionGet();
assertNotNull(openJobResponse);
// 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);
listener.actionGet();
}
@ -281,17 +280,16 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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);
PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse);
PlainListenableActionFuture<PutDatafeedAction.Response> putDatafeedListener = new PlainListenableActionFuture<>(
client.threadPool());
PlainActionFuture<PutDatafeedAction.Response> putDatafeedListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).putDatafeed(
new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), putDatafeedListener);
PutDatafeedAction.Response putDatafeedResponse = putDatafeedListener.actionGet();
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);
OpenJobAction.Response openJobResponse = openJobListener.actionGet();
assertNotNull(openJobResponse);
@ -314,7 +312,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do not work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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);
listener.actionGet();
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())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
// 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);
OpenJobAction.Response openJobResponse = openJobListener.actionGet();
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);
StartDatafeedAction.Response response = listener.actionGet();
assertNotNull(response);
@ -351,22 +349,20 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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);
PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse);
PlainListenableActionFuture<PutDatafeedAction.Response> putDatafeedListener = new PlainListenableActionFuture<>(
client.threadPool());
PlainActionFuture<PutDatafeedAction.Response> putDatafeedListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).putDatafeed(
new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), putDatafeedListener);
PutDatafeedAction.Response putDatafeedResponse = putDatafeedListener.actionGet();
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);
OpenJobAction.Response openJobResponse = openJobListener.actionGet();
assertNotNull(openJobResponse);
PlainListenableActionFuture<StartDatafeedAction.Response> startDatafeedListener = new PlainListenableActionFuture<>(
client.threadPool());
PlainActionFuture<StartDatafeedAction.Response> startDatafeedListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).startDatafeed(new StartDatafeedAction.Request("foobar", 0L), startDatafeedListener);
StartDatafeedAction.Response startDatafeedResponse = startDatafeedListener.actionGet();
assertNotNull(startDatafeedResponse);
@ -381,8 +377,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
client.addTransportAddress(internalCluster().getDataNodeInstance(Transport.class).boundAddress().publishAddress());
PlainListenableActionFuture<StopDatafeedAction.Response> listener = new PlainListenableActionFuture<>(
client.threadPool());
PlainActionFuture<StopDatafeedAction.Response> listener = PlainActionFuture.newFuture();
new MachineLearningClient(client).stopDatafeed(new StopDatafeedAction.Request("foobar"), listener);
if (invalidLicense) {
// 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
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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);
PutJobAction.Response putJobResponse = putJobListener.actionGet();
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);
OpenJobAction.Response openJobResponse = openJobListener.actionGet();
assertNotNull(openJobResponse);
@ -422,7 +417,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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");
request.setCloseTimeout(TimeValue.timeValueSeconds(20));
if (invalidLicense) {
@ -445,7 +440,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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);
PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse);
@ -457,7 +452,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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);
listener.actionGet();
}
@ -469,12 +464,11 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
// test that license restricted apis do now work
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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);
PutJobAction.Response putJobResponse = putJobListener.actionGet();
assertNotNull(putJobResponse);
PlainListenableActionFuture<PutDatafeedAction.Response> putDatafeedListener = new PlainListenableActionFuture<>(
client.threadPool());
PlainActionFuture<PutDatafeedAction.Response> putDatafeedListener = PlainActionFuture.newFuture();
new MachineLearningClient(client).putDatafeed(
new PutDatafeedAction.Request(createDatafeed("foobar", "foo", Collections.singletonList("foo"))), putDatafeedListener);
PutDatafeedAction.Response putDatafeedResponse = putDatafeedListener.actionGet();
@ -487,7 +481,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
try (TransportClient client = new TestXPackTransportClient(internalCluster().transportClient().settings())) {
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);
listener.actionGet();
}