Leftover from IndexAlert* to PutAlert*
Original commit: elastic/x-pack-elasticsearch@6af1e77e43
This commit is contained in:
parent
c2e4fe375d
commit
72e9d9e4b7
|
@ -88,35 +88,35 @@ public interface AlertsClient extends ElasticsearchClient<AlertsClient> {
|
|||
ActionFuture<DeleteAlertResponse> 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<PutAlertResponse> listener);
|
||||
void putAlert(PutAlertRequest request, ActionListener<PutAlertResponse> 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<PutAlertResponse> indexAlert(PutAlertRequest request);
|
||||
ActionFuture<PutAlertResponse> putAlert(PutAlertRequest request);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<PutAlertResponse> response) {
|
||||
public void putAlert(PutAlertRequest request, ActionListener<PutAlertResponse> response) {
|
||||
execute(PutAlertAction.INSTANCE, request, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionFuture<PutAlertResponse> indexAlert(PutAlertRequest request) {
|
||||
public ActionFuture<PutAlertResponse> putAlert(PutAlertRequest request) {
|
||||
return execute(PutAlertAction.INSTANCE, request);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<PutAlertResponse>(channel) {
|
||||
alertsClient.putAlert(putAlertRequest, new RestBuilderListener<PutAlertResponse>(channel) {
|
||||
@Override
|
||||
public RestResponse buildResponse(PutAlertResponse response, XContentBuilder builder) throws Exception {
|
||||
IndexResponse indexResponse = response.indexResponse();
|
||||
|
|
|
@ -58,6 +58,6 @@ public class PutAlertRequestBuilder
|
|||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<PutAlertResponse> listener) {
|
||||
client.indexAlert(request, listener);
|
||||
client.putAlert(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue