Fixes after merge conflicts.
Original commit: elastic/x-pack-elasticsearch@65adad6ea7
This commit is contained in:
parent
3fcae91633
commit
b1f64f4103
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -105,8 +105,6 @@ public interface AlertsClient extends ElasticsearchClient<AlertsClient> {
|
|||
*/
|
||||
PutAlertRequestBuilder preparePutAlert();
|
||||
|
||||
|
||||
//@TODO : rename to putAlert
|
||||
/**
|
||||
* Put an alert and registers it with the scheduler
|
||||
*
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue