diff --git a/src/main/java/org/elasticsearch/alerts/AlertManager.java b/src/main/java/org/elasticsearch/alerts/AlertManager.java index bdf26702f3a..5d6fbd4b675 100644 --- a/src/main/java/org/elasticsearch/alerts/AlertManager.java +++ b/src/main/java/org/elasticsearch/alerts/AlertManager.java @@ -150,7 +150,7 @@ public class AlertManager extends AbstractComponent { alert.setAckState(AlertAckState.NEEDS_ACK); } } else { - entry.setEntryState(AlertActionState.THROTTLED); + entry.setState(AlertActionState.THROTTLED); } alert.lastActionFire(entry.getFireTime()); alertsStore.updateAlert(alert); diff --git a/src/main/java/org/elasticsearch/alerts/actions/AlertActionManager.java b/src/main/java/org/elasticsearch/alerts/actions/AlertActionManager.java index c03e6dd7250..f5060bafd6c 100644 --- a/src/main/java/org/elasticsearch/alerts/actions/AlertActionManager.java +++ b/src/main/java/org/elasticsearch/alerts/actions/AlertActionManager.java @@ -316,11 +316,11 @@ public class AlertActionManager extends AbstractComponent { logger.info("Running an alert action entry for [{}]", entry.getAlertName()); TriggerResult trigger = alertManager.executeAlert(entry); if (trigger.isTriggered()) { - if (entry.getEntryState() != AlertActionState.THROTTLED) { - entry.setEntryState(AlertActionState.ACTION_PERFORMED); + if (entry.getState() != AlertActionState.THROTTLED) { + entry.setState(AlertActionState.ACTION_PERFORMED); } } else { - entry.setEntryState(AlertActionState.NO_ACTION_NEEDED); + entry.setState(AlertActionState.NO_ACTION_NEEDED); } updateHistoryEntry(entry); } catch (Exception e) { diff --git a/src/main/java/org/elasticsearch/alerts/client/AlertsClient.java b/src/main/java/org/elasticsearch/alerts/client/AlertsClient.java index baa95a3b47b..b210d88c947 100644 --- a/src/main/java/org/elasticsearch/alerts/client/AlertsClient.java +++ b/src/main/java/org/elasticsearch/alerts/client/AlertsClient.java @@ -105,8 +105,6 @@ public interface AlertsClient extends ElasticsearchClient { */ PutAlertRequestBuilder preparePutAlert(); - - //@TODO : rename to putAlert /** * Put an alert and registers it with the scheduler * diff --git a/src/test/java/org/elasticsearch/alerts/AlertThrottleTests.java b/src/test/java/org/elasticsearch/alerts/AlertThrottleTests.java index 20b71bc9682..a1051886748 100644 --- a/src/test/java/org/elasticsearch/alerts/AlertThrottleTests.java +++ b/src/test/java/org/elasticsearch/alerts/AlertThrottleTests.java @@ -37,7 +37,7 @@ import static org.hamcrest.core.IsEqual.equalTo; /** */ -@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.SUITE, numClientNodes = 0, transportClientRatio = 0, numDataNodes = 1) +@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST, numClientNodes = 0, transportClientRatio = 0, numDataNodes = 1) public class AlertThrottleTests extends AbstractAlertingTests { @Test @@ -62,7 +62,7 @@ public class AlertThrottleTests extends AbstractAlertingTests { XContentBuilder jsonBuilder = XContentFactory.jsonBuilder(); alert.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS); - PutAlertResponse putAlertResponse = alertsClient.prepareIndexAlert().setAlertName("throttled-alert").setAlertSource(jsonBuilder.bytes()).get(); + PutAlertResponse putAlertResponse = alertsClient.preparePutAlert().setAlertName("throttled-alert").setAlertSource(jsonBuilder.bytes()).get(); assertTrue(putAlertResponse.indexResponse().isCreated()); @@ -118,7 +118,7 @@ public class AlertThrottleTests extends AbstractAlertingTests { CountResponse countOfThrottledActions = client() .prepareCount(AlertActionManager.ALERT_HISTORY_INDEX) - .setQuery(QueryBuilders.matchQuery(AlertActionState.FIELD_NAME, AlertActionState.THROTTLED.toString())) + .setQuery(QueryBuilders.matchQuery(AlertActionManager.STATE, AlertActionState.THROTTLED.toString())) .get(); assertThat(countOfThrottledActions.getCount(), greaterThan(0L)); @@ -148,7 +148,7 @@ public class AlertThrottleTests extends AbstractAlertingTests { XContentBuilder jsonBuilder = XContentFactory.jsonBuilder(); alert.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS); - PutAlertResponse putAlertResponse = alertsClient.prepareIndexAlert().setAlertName("throttled-alert").setAlertSource(jsonBuilder.bytes()).get(); + PutAlertResponse putAlertResponse = alertsClient.preparePutAlert().setAlertName("throttled-alert").setAlertSource(jsonBuilder.bytes()).get(); assertTrue(putAlertResponse.indexResponse().isCreated()); Thread.sleep(5*1000); @@ -176,7 +176,7 @@ public class AlertThrottleTests extends AbstractAlertingTests { CountResponse countOfThrottledActions = client() .prepareCount(AlertActionManager.ALERT_HISTORY_INDEX) - .setQuery(QueryBuilders.matchQuery(AlertActionState.FIELD_NAME, AlertActionState.THROTTLED.toString())) + .setQuery(QueryBuilders.matchQuery(AlertActionManager.STATE, AlertActionState.THROTTLED.toString())) .get(); assertThat(countOfThrottledActions.getCount(), greaterThan(0L)); diff --git a/src/test/java/org/elasticsearch/alerts/BootStrapTest.java b/src/test/java/org/elasticsearch/alerts/BootStrapTest.java index 57db757ba5a..a0d32f2bf35 100644 --- a/src/test/java/org/elasticsearch/alerts/BootStrapTest.java +++ b/src/test/java/org/elasticsearch/alerts/BootStrapTest.java @@ -48,19 +48,8 @@ public class BootStrapTest extends AbstractAlertingTests { .setConsistencyLevel(WriteConsistencyLevel.ALL) .get(); -<<<<<<< HEAD - AlertsStatsRequest alertsStatsRequest = alertClient().prepareAlertsStats().request(); - AlertsStatsResponse response = alertClient().alertsStats(alertsStatsRequest).actionGet(); - - assertTrue(response.isAlertActionManagerStarted()); - assertTrue(response.isAlertManagerStarted()); - assertThat(response.getNumberOfRegisteredAlerts(), equalTo(1L)); - client().admin().indices().prepareRefresh(AlertsStore.ALERT_INDEX).get(); - -======= ->>>>>>> a975bee9f0371ecdf8881f90e90f02769dac90fc String oldMaster = internalTestCluster().getMasterName(); try { internalTestCluster().stopCurrentMasterNode(); @@ -79,9 +68,11 @@ public class BootStrapTest extends AbstractAlertingTests { AlertsStatsRequest alertsStatsRequest = alertClient().prepareAlertsStats().request(); AlertsStatsResponse response = alertClient().alertsStats(alertsStatsRequest).actionGet(); + alertsStatsRequest = alertClient().prepareAlertsStats().request(); + response = alertClient().alertsStats(alertsStatsRequest).actionGet(); + assertTrue(response.isAlertActionManagerStarted()); assertTrue(response.isAlertManagerStarted()); - assertThat(response.getNumberOfRegisteredAlerts(), equalTo(1L)); } diff --git a/src/test/java/org/elasticsearch/alerts/actions/AlertActionsTest.java b/src/test/java/org/elasticsearch/alerts/actions/AlertActionsTest.java index 215ae98a0f6..3cc3eabf034 100644 --- a/src/test/java/org/elasticsearch/alerts/actions/AlertActionsTest.java +++ b/src/test/java/org/elasticsearch/alerts/actions/AlertActionsTest.java @@ -23,12 +23,7 @@ import org.elasticsearch.alerts.triggers.TriggerManager; import org.elasticsearch.alerts.triggers.TriggerResult; import org.elasticsearch.common.joda.time.DateTime; import org.elasticsearch.common.joda.time.DateTimeZone; -<<<<<<< HEAD -import org.elasticsearch.common.settings.ImmutableSettings; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; -======= ->>>>>>> a975bee9f0371ecdf8881f90e90f02769dac90fc import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory;