Clear alerts after each test run, so that we don't run into exceptions between wipe indices and node closing.
Improved stop logging Original commit: elastic/x-pack-elasticsearch@195a4cb75d
This commit is contained in:
parent
5be1c5964c
commit
8f0e454ac5
|
@ -135,9 +135,11 @@ public class AlertManager extends AbstractComponent {
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
if (started.compareAndSet(true, false)) {
|
if (started.compareAndSet(true, false)) {
|
||||||
|
logger.info("Stopping alert manager...");
|
||||||
scheduler.stop();
|
scheduler.stop();
|
||||||
actionManager.stop();
|
actionManager.stop();
|
||||||
alertsStore.stop();
|
alertsStore.stop();
|
||||||
|
logger.info("Alert manager has stopped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,6 +198,7 @@ public class AlertsStore extends AbstractComponent {
|
||||||
public void stop() {
|
public void stop() {
|
||||||
state.set(State.STOPPED);
|
state.set(State.STOPPED);
|
||||||
clear();
|
clear();
|
||||||
|
logger.info("Stopped alert store");
|
||||||
}
|
}
|
||||||
|
|
||||||
private IndexResponse persistAlert(String alertName, BytesReference alertSource, IndexRequest.OpType opType) {
|
private IndexResponse persistAlert(String alertName, BytesReference alertSource, IndexRequest.OpType opType) {
|
||||||
|
|
|
@ -128,9 +128,9 @@ public class AlertActionManager extends AbstractComponent {
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
if (state.compareAndSet(State.STARTED, State.STOPPED)) {
|
if (state.compareAndSet(State.STARTED, State.STOPPED)) {
|
||||||
logger.info("Stopping job queue...");
|
|
||||||
actionsToBeProcessed.clear();
|
actionsToBeProcessed.clear();
|
||||||
actionsToBeProcessed.add(END_ENTRY);
|
actionsToBeProcessed.add(END_ENTRY);
|
||||||
|
logger.info("Stopped job queue");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,10 @@ public class AlertScheduler extends AbstractComponent {
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
try {
|
try {
|
||||||
logger.info("Stopping scheduler");
|
|
||||||
if (!scheduler.isShutdown()) {
|
if (!scheduler.isShutdown()) {
|
||||||
scheduler.clear();
|
scheduler.clear();
|
||||||
scheduler.shutdown(false);
|
scheduler.shutdown(false);
|
||||||
|
logger.info("Stopped scheduler");
|
||||||
}
|
}
|
||||||
} catch (SchedulerException se){
|
} catch (SchedulerException se){
|
||||||
logger.error("Failed to stop quartz scheduler", se);
|
logger.error("Failed to stop quartz scheduler", se);
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||||
import org.junit.Before;
|
import org.junit.After;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -103,7 +103,7 @@ public class BasicAlertingTest extends ElasticsearchIntegrationTest {
|
||||||
assertHitCount(client().prepareCount(AlertsStore.ALERT_INDEX).get(), 0l);
|
assertHitCount(client().prepareCount(AlertsStore.ALERT_INDEX).get(), 0l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@After
|
||||||
public void clearAlerts() {
|
public void clearAlerts() {
|
||||||
// Clear all in-memory alerts on all nodes, perhaps there isn't an elected master at this point
|
// Clear all in-memory alerts on all nodes, perhaps there isn't an elected master at this point
|
||||||
for (AlertManager manager : internalCluster().getInstances(AlertManager.class)) {
|
for (AlertManager manager : internalCluster().getInstances(AlertManager.class)) {
|
||||||
|
|
Loading…
Reference in New Issue