From 72e9d9e4b7be9dea49e7bf5d57c5d4c647439a49 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Wed, 19 Nov 2014 21:32:18 +0100 Subject: [PATCH] Leftover from IndexAlert* to PutAlert* Original commit: elastic/x-pack-elasticsearch@6af1e77e430e87c2a8416eab716897edf11c12b7 --- .../alerts/client/AlertsClient.java | 18 +++++++++--------- .../alerts/client/NodeAlertsClient.java | 8 ++++---- .../alerts/rest/RestPutAlertAction.java | 2 +- .../actions/put/PutAlertRequestBuilder.java | 2 +- .../alerts/BasicAlertingTest.java | 12 ++++++------ .../alerts/NoMasterNodeTests.java | 4 ++-- .../alerts/actions/AlertActionsTest.java | 4 ++-- .../alerts/actions/AlertStatsTests.java | 2 +- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/elasticsearch/alerts/client/AlertsClient.java b/src/main/java/org/elasticsearch/alerts/client/AlertsClient.java index f5f2e4a381b..a5cc2a25fa8 100644 --- a/src/main/java/org/elasticsearch/alerts/client/AlertsClient.java +++ b/src/main/java/org/elasticsearch/alerts/client/AlertsClient.java @@ -88,35 +88,35 @@ public interface AlertsClient extends ElasticsearchClient { ActionFuture deleteAlert(DeleteAlertRequest request); /** - * Creates a request builder to build a request to index an alert + * Creates a request builder to build a request to put an alert * - * @param alertName The name of the alert to index + * @param alertName The name of the alert to put * @return The builder to create the alert */ - PutAlertRequestBuilder prepareIndexAlert(String alertName); + PutAlertRequestBuilder preparePutAlert(String alertName); /** - * Creates a request builder to build a request to index an alert + * Creates a request builder to build a request to put an alert * * @return The builder */ - PutAlertRequestBuilder prepareIndexAlert(); + PutAlertRequestBuilder preparePutAlert(); /** - * Indexes an alert and registers it with the scheduler + * Put an alert and registers it with the scheduler * * @param request The request containing the alert to index and register * @param listener The listener for the response containing the IndexResponse for this alert */ - void indexAlert(PutAlertRequest request, ActionListener listener); + void putAlert(PutAlertRequest request, ActionListener listener); /** - * Indexes an alert and registers it with the scheduler + * Put an alert and registers it with the scheduler * * @param request The request containing the alert to index and register * @return The response containing the IndexResponse for this alert */ - ActionFuture indexAlert(PutAlertRequest request); + ActionFuture putAlert(PutAlertRequest request); /** diff --git a/src/main/java/org/elasticsearch/alerts/client/NodeAlertsClient.java b/src/main/java/org/elasticsearch/alerts/client/NodeAlertsClient.java index 47778a91f29..5dd047a867a 100644 --- a/src/main/java/org/elasticsearch/alerts/client/NodeAlertsClient.java +++ b/src/main/java/org/elasticsearch/alerts/client/NodeAlertsClient.java @@ -76,22 +76,22 @@ public class NodeAlertsClient implements AlertsClient { } @Override - public PutAlertRequestBuilder prepareIndexAlert(String alertName) { + public PutAlertRequestBuilder preparePutAlert(String alertName) { return new PutAlertRequestBuilder(this, alertName); } @Override - public PutAlertRequestBuilder prepareIndexAlert() { + public PutAlertRequestBuilder preparePutAlert() { return new PutAlertRequestBuilder(this, null); } @Override - public void indexAlert(PutAlertRequest request, ActionListener response) { + public void putAlert(PutAlertRequest request, ActionListener response) { execute(PutAlertAction.INSTANCE, request, response); } @Override - public ActionFuture indexAlert(PutAlertRequest request) { + public ActionFuture putAlert(PutAlertRequest request) { return execute(PutAlertAction.INSTANCE, request); } diff --git a/src/main/java/org/elasticsearch/alerts/rest/RestPutAlertAction.java b/src/main/java/org/elasticsearch/alerts/rest/RestPutAlertAction.java index 6d7c3a88c7d..5f083890bfd 100644 --- a/src/main/java/org/elasticsearch/alerts/rest/RestPutAlertAction.java +++ b/src/main/java/org/elasticsearch/alerts/rest/RestPutAlertAction.java @@ -41,7 +41,7 @@ public class RestPutAlertAction extends BaseRestHandler { PutAlertRequest putAlertRequest = new PutAlertRequest(); putAlertRequest.setAlertName(request.param("name")); putAlertRequest.setAlertSource(request.content(), request.contentUnsafe()); - alertsClient.indexAlert(putAlertRequest, new RestBuilderListener(channel) { + alertsClient.putAlert(putAlertRequest, new RestBuilderListener(channel) { @Override public RestResponse buildResponse(PutAlertResponse response, XContentBuilder builder) throws Exception { IndexResponse indexResponse = response.indexResponse(); diff --git a/src/main/java/org/elasticsearch/alerts/transport/actions/put/PutAlertRequestBuilder.java b/src/main/java/org/elasticsearch/alerts/transport/actions/put/PutAlertRequestBuilder.java index 53d6b27ea9d..16ebe724b90 100644 --- a/src/main/java/org/elasticsearch/alerts/transport/actions/put/PutAlertRequestBuilder.java +++ b/src/main/java/org/elasticsearch/alerts/transport/actions/put/PutAlertRequestBuilder.java @@ -58,6 +58,6 @@ public class PutAlertRequestBuilder @Override protected void doExecute(ActionListener listener) { - client.indexAlert(request, listener); + client.putAlert(request, listener); } } diff --git a/src/test/java/org/elasticsearch/alerts/BasicAlertingTest.java b/src/test/java/org/elasticsearch/alerts/BasicAlertingTest.java index 03d13f5ae96..a2b763e4215 100644 --- a/src/test/java/org/elasticsearch/alerts/BasicAlertingTest.java +++ b/src/test/java/org/elasticsearch/alerts/BasicAlertingTest.java @@ -39,7 +39,7 @@ public class BasicAlertingTest extends AbstractAlertingTests { client().prepareIndex("my-index", "my-type").setSource("field", "value").get(); SearchRequest searchRequest = createTriggerSearchRequest("my-index").source(searchSource().query(termQuery("field", "value"))); BytesReference alertSource = createAlertSource("0/5 * * * * ? *", searchRequest, "hits.total == 1"); - alertsClient.prepareIndexAlert("my-first-alert") + alertsClient.preparePutAlert("my-first-alert") .setAlertSource(alertSource) .get(); assertAlertTriggered("my-first-alert", 1); @@ -50,7 +50,7 @@ public class BasicAlertingTest extends AbstractAlertingTests { AlertsClient alertsClient = alertClient(); SearchRequest searchRequest = createTriggerSearchRequest("my-index").source(searchSource().query(termQuery("field", "value"))); BytesReference alertSource = createAlertSource("0/5 * * * * ? *", searchRequest, "hits.total == 1"); - alertsClient.prepareIndexAlert("my-first-alert") + alertsClient.preparePutAlert("my-first-alert") .setAlertSource(alertSource) .get(); @@ -70,7 +70,7 @@ public class BasicAlertingTest extends AbstractAlertingTests { client().prepareIndex("my-index", "my-type").setSource("field", "value").get(); SearchRequest searchRequest = createTriggerSearchRequest("my-index").source(searchSource().query(matchAllQuery())); BytesReference alertSource = createAlertSource("0/5 * * * * ? *", searchRequest, "hits.total == 1"); - PutAlertResponse indexResponse = alertsClient.prepareIndexAlert("my-first-alert") + PutAlertResponse indexResponse = alertsClient.preparePutAlert("my-first-alert") .setAlertSource(alertSource) .get(); assertThat(indexResponse.indexResponse().isCreated(), is(true)); @@ -103,7 +103,7 @@ public class BasicAlertingTest extends AbstractAlertingTests { .field("malformed_field", "x") .endObject().bytes(); try { - alertsClient.prepareIndexAlert("my-first-alert") + alertsClient.preparePutAlert("my-first-alert") .setAlertSource(alertSource) .get(); fail(); @@ -130,7 +130,7 @@ public class BasicAlertingTest extends AbstractAlertingTests { searchRequest.searchType(SearchType.QUERY_THEN_FETCH); // By accessing the actual hit we know that the fetch phase has been performed BytesReference alertSource = createAlertSource("0/5 * * * * ? *", searchRequest, "hits?.hits[0]._score == 1.0"); - PutAlertResponse indexResponse = alertsClient.prepareIndexAlert("my-first-alert") + PutAlertResponse indexResponse = alertsClient.preparePutAlert("my-first-alert") .setAlertSource(alertSource) .get(); assertThat(indexResponse.indexResponse().isCreated(), is(true)); @@ -167,7 +167,7 @@ public class BasicAlertingTest extends AbstractAlertingTests { assertAcked(prepareCreate("my-index").addMapping("my-type", "_timestamp", "enabled=true", "event_type", "type=string")); alertClient().prepareDeleteAlert(alertName).get(); - alertClient().prepareIndexAlert(alertName) + alertClient().preparePutAlert(alertName) .setAlertSource(createAlertSource(String.format("0/%s * * * * ? *", (scheduleTimeInMs / 1000)), request, "return hits.total >= 3")) .get(); diff --git a/src/test/java/org/elasticsearch/alerts/NoMasterNodeTests.java b/src/test/java/org/elasticsearch/alerts/NoMasterNodeTests.java index c2707e2d9e2..77fbd3fe32b 100644 --- a/src/test/java/org/elasticsearch/alerts/NoMasterNodeTests.java +++ b/src/test/java/org/elasticsearch/alerts/NoMasterNodeTests.java @@ -57,7 +57,7 @@ public class NoMasterNodeTests extends AbstractAlertingTests { client().prepareIndex("my-index", "my-type").setSource("field", "value").get(); SearchRequest searchRequest = createTriggerSearchRequest("my-index").source(searchSource().query(termQuery("field", "value"))); BytesReference alertSource = createAlertSource("0/5 * * * * ? *", searchRequest, "hits.total == 1"); - alertsClient.prepareIndexAlert("my-first-alert") + alertsClient.preparePutAlert("my-first-alert") .setAlertSource(alertSource) .get(); assertAlertTriggered("my-first-alert", 1); @@ -89,7 +89,7 @@ public class NoMasterNodeTests extends AbstractAlertingTests { DeleteAlertResponse response = alertsClient.prepareDeleteAlert("my-first-alert").get(); assertThat(response.deleteResponse().isFound(), is(true)); // Add a new alert and wait for it get triggered - alertsClient.prepareIndexAlert("my-second-alert") + alertsClient.preparePutAlert("my-second-alert") .setAlertSource(alertSource) .get(); assertAlertTriggered("my-second-alert", 2); diff --git a/src/test/java/org/elasticsearch/alerts/actions/AlertActionsTest.java b/src/test/java/org/elasticsearch/alerts/actions/AlertActionsTest.java index 076406bd1a2..249ebd66fc1 100644 --- a/src/test/java/org/elasticsearch/alerts/actions/AlertActionsTest.java +++ b/src/test/java/org/elasticsearch/alerts/actions/AlertActionsTest.java @@ -196,8 +196,8 @@ public class AlertActionsTest extends ElasticsearchIntegrationTest { AlertsClient alertsClient = internalCluster().getInstance(AlertsClient.class, internalCluster().getMasterName()); - PutAlertRequest alertRequest = alertsClient.prepareIndexAlert().setAlertName("my-first-alert").setAlertSource(jsonBuilder.bytes()).request(); - PutAlertResponse alertsResponse = alertsClient.indexAlert(alertRequest).actionGet(); + PutAlertRequest alertRequest = alertsClient.preparePutAlert().setAlertName("my-first-alert").setAlertSource(jsonBuilder.bytes()).request(); + PutAlertResponse alertsResponse = alertsClient.putAlert(alertRequest).actionGet(); assertNotNull(alertsResponse.indexResponse()); assertTrue(alertsResponse.indexResponse().isCreated()); diff --git a/src/test/java/org/elasticsearch/alerts/actions/AlertStatsTests.java b/src/test/java/org/elasticsearch/alerts/actions/AlertStatsTests.java index a469b88fad4..515a10ffe41 100644 --- a/src/test/java/org/elasticsearch/alerts/actions/AlertStatsTests.java +++ b/src/test/java/org/elasticsearch/alerts/actions/AlertStatsTests.java @@ -51,7 +51,7 @@ public class AlertStatsTests extends AbstractAlertingTests { SearchRequest searchRequest = createTriggerSearchRequest("my-index").source(searchSource().query(termQuery("field", "value"))); BytesReference alertSource = createAlertSource("* * * * * ? *", searchRequest, "hits.total == 1"); - alertClient().prepareIndexAlert("testAlert") + alertClient().preparePutAlert("testAlert") .setAlertSource(alertSource) .get();