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:
Martijn van Groningen 2014-11-06 22:15:11 +01:00
parent 5be1c5964c
commit 8f0e454ac5
5 changed files with 7 additions and 4 deletions

View File

@ -135,9 +135,11 @@ public class AlertManager extends AbstractComponent {
public void stop() {
if (started.compareAndSet(true, false)) {
logger.info("Stopping alert manager...");
scheduler.stop();
actionManager.stop();
alertsStore.stop();
logger.info("Alert manager has stopped");
}
}

View File

@ -198,6 +198,7 @@ public class AlertsStore extends AbstractComponent {
public void stop() {
state.set(State.STOPPED);
clear();
logger.info("Stopped alert store");
}
private IndexResponse persistAlert(String alertName, BytesReference alertSource, IndexRequest.OpType opType) {

View File

@ -128,9 +128,9 @@ public class AlertActionManager extends AbstractComponent {
public void stop() {
if (state.compareAndSet(State.STARTED, State.STOPPED)) {
logger.info("Stopping job queue...");
actionsToBeProcessed.clear();
actionsToBeProcessed.add(END_ENTRY);
logger.info("Stopped job queue");
}
}

View File

@ -43,10 +43,10 @@ public class AlertScheduler extends AbstractComponent {
public void stop() {
try {
logger.info("Stopping scheduler");
if (!scheduler.isShutdown()) {
scheduler.clear();
scheduler.shutdown(false);
logger.info("Stopped scheduler");
}
} catch (SchedulerException se){
logger.error("Failed to stop quartz scheduler", se);

View File

@ -22,7 +22,7 @@ import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.junit.Before;
import org.junit.After;
import org.junit.Test;
import java.io.IOException;
@ -103,7 +103,7 @@ public class BasicAlertingTest extends ElasticsearchIntegrationTest {
assertHitCount(client().prepareCount(AlertsStore.ALERT_INDEX).get(), 0l);
}
@Before
@After
public void clearAlerts() {
// 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)) {