[cleanup] Refactoring of the code base

- Renamed `AlertingModule` to `AlertsModule`
- Started modularizing the code base.. each module has its own guice module and `AlertsModule` spawn all the sub-modules
- Renamed `*Helper` classes to `*Utils` for consistency sake and moved all utilities to `support` package
- Moved `AlertsPlugin` to the base package (no need for `plugin` package... it just creates noise)
- Moved `State` to be inner enum within `AlertsService` (that's where it belongs)
- Moved all the rest actions to `rest.action` package

Original commit: elastic/x-pack-elasticsearch@4ce9bf8dcd
This commit is contained in:
uboness 2015-02-03 14:55:28 +01:00
parent 4b38006f64
commit 79ee2ed62e
39 changed files with 255 additions and 204 deletions

View File

@ -7,6 +7,7 @@ package org.elasticsearch.alerts;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.alerts.actions.AlertAction;
import org.elasticsearch.alerts.support.AlertUtils;
import org.elasticsearch.alerts.triggers.AlertTrigger;
import org.elasticsearch.common.joda.time.DateTime;
import org.elasticsearch.common.unit.TimeValue;

View File

@ -19,6 +19,7 @@ import java.io.IOException;
* ACKED : This alert has been acknowleged, subsequent positive triggers will not cause actions to occur, a negative trigger will move the alert back into NOT_TRIGGERED state
*/
public enum AlertAckState implements ToXContent {
NOT_ACKABLE, ///@TODO perhaps null
NEEDS_ACK,
ACKED,

View File

@ -9,48 +9,40 @@ package org.elasticsearch.alerts;
import org.elasticsearch.alerts.actions.AlertActionRegistry;
import org.elasticsearch.alerts.actions.AlertActionService;
import org.elasticsearch.alerts.client.AlertsClientModule;
import org.elasticsearch.alerts.rest.*;
import org.elasticsearch.alerts.scheduler.AlertScheduler;
import org.elasticsearch.alerts.rest.AlertsRestModule;
import org.elasticsearch.alerts.scheduler.AlertsSchedulerModule;
import org.elasticsearch.alerts.support.TemplateUtils;
import org.elasticsearch.alerts.support.init.InitializingModule;
import org.elasticsearch.alerts.transport.AlertsTransportModule;
import org.elasticsearch.alerts.triggers.TriggerService;
import org.elasticsearch.common.collect.ImmutableList;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.inject.SpawnModules;
public class AlertingModule extends AbstractModule implements SpawnModules {
public class AlertsModule extends AbstractModule implements SpawnModules {
@Override
public Iterable<? extends Module> spawnModules() {
return ImmutableList.of(
new InitializingModule(),
new AlertsSchedulerModule(),
new AlertsTransportModule(),
new AlertsClientModule());
new AlertsClientModule(),
new AlertsRestModule());
}
@Override
protected void configure() {
// Core components
bind(TemplateHelper.class).asEagerSingleton();
bind(TemplateUtils.class).asEagerSingleton();
bind(AlertsStore.class).asEagerSingleton();
bind(AlertService.class).asEagerSingleton();
bind(AlertsService.class).asEagerSingleton();
bind(AlertActionService.class).asEagerSingleton();
bind(TriggerService.class).asEagerSingleton();
bind(AlertScheduler.class).asEagerSingleton();
bind(AlertActionRegistry.class).asEagerSingleton();
bind(ConfigurationService.class).asEagerSingleton();
// Rest layer
bind(RestPutAlertAction.class).asEagerSingleton();
bind(RestDeleteAlertAction.class).asEagerSingleton();
bind(RestAlertsStatsAction.class).asEagerSingleton();
bind(RestGetAlertAction.class).asEagerSingleton();
bind(RestAlertServiceAction.class).asEagerSingleton();
bind(RestConfigAlertAction.class).asEagerSingleton();
bind(RestAckAlertAction.class).asEagerSingleton();
}
}

View File

@ -3,9 +3,9 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.plugin;
package org.elasticsearch.alerts;
import org.elasticsearch.alerts.AlertingModule;
import org.elasticsearch.alerts.AlertsModule;
import org.elasticsearch.alerts.support.init.InitializingService;
import org.elasticsearch.common.collect.ImmutableList;
import org.elasticsearch.common.collect.Lists;
@ -20,11 +20,11 @@ import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilde
public class AlertsPlugin extends AbstractPlugin {
public static final String ALERT_THREAD_POOL_NAME = "alerts";
public static final String NAME = "alerts";
public static final String SCHEDULER_THREAD_POOL_NAME = "alerts_scheduler";
@Override public String name() {
return ALERT_THREAD_POOL_NAME;
return NAME;
}
@Override public String description() {
@ -33,9 +33,7 @@ public class AlertsPlugin extends AbstractPlugin {
@Override
public Collection<Class<? extends Module>> modules() {
Collection<Class<? extends Module>> modules = Lists.newArrayList();
modules.add(AlertingModule.class);
return modules;
return ImmutableList.<Class<? extends Module>>of(AlertsModule.class);
}
@Override
@ -50,8 +48,8 @@ public class AlertsPlugin extends AbstractPlugin {
@Override
public Settings additionalSettings() {
return settingsBuilder()
.put("threadpool." + ALERT_THREAD_POOL_NAME + ".type", "fixed")
.put("threadpool." + ALERT_THREAD_POOL_NAME + ".size", 32) // Executing an alert involves a lot of wait time for networking (search, several index requests + optional trigger logic)
.put("threadpool." + NAME + ".type", "fixed")
.put("threadpool." + NAME + ".size", 32) // Executing an alert involves a lot of wait time for networking (search, several index requests + optional trigger logic)
.put("threadpool." + SCHEDULER_THREAD_POOL_NAME + ".type", "cached")
.build();
}

View File

@ -7,6 +7,7 @@ package org.elasticsearch.alerts;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchIllegalArgumentException;
import org.elasticsearch.ElasticsearchIllegalStateException;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.index.IndexResponse;
@ -16,6 +17,7 @@ import org.elasticsearch.alerts.actions.AlertActionRegistry;
import org.elasticsearch.alerts.actions.AlertActionService;
import org.elasticsearch.alerts.actions.AlertHistory;
import org.elasticsearch.alerts.scheduler.AlertScheduler;
import org.elasticsearch.alerts.support.AlertUtils;
import org.elasticsearch.alerts.support.init.proxy.ClientProxy;
import org.elasticsearch.alerts.support.init.proxy.ScriptServiceProxy;
import org.elasticsearch.alerts.triggers.TriggerResult;
@ -45,7 +47,7 @@ import java.util.concurrent.atomic.AtomicReference;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
public class AlertService extends AbstractComponent {
public class AlertsService extends AbstractComponent {
private final ClientProxy client;
private final AlertScheduler scheduler;
@ -62,18 +64,18 @@ public class AlertService extends AbstractComponent {
private volatile boolean manuallyStopped;
@Inject
public AlertService(Settings settings, ClientProxy client, ClusterService clusterService, AlertScheduler scheduler, AlertsStore alertsStore,
IndicesService indicesService, TriggerService triggerService, AlertActionService actionManager,
AlertActionRegistry actionRegistry, ThreadPool threadPool, ScriptServiceProxy scriptService) {
public AlertsService(Settings settings, ClientProxy client, ClusterService clusterService, AlertScheduler scheduler, AlertsStore alertsStore,
IndicesService indicesService, TriggerService triggerService, AlertActionService actionManager,
AlertActionRegistry actionRegistry, ThreadPool threadPool, ScriptServiceProxy scriptService) {
super(settings);
this.client = client;
this.scheduler = scheduler;
this.threadPool = threadPool;
this.scheduler.setAlertService(this);
this.scheduler.setAlertsService(this);
this.alertsStore = alertsStore;
this.triggerService = triggerService;
this.actionManager = actionManager;
this.actionManager.setAlertService(this);
this.actionManager.setAlertsService(this);
this.actionRegistry = actionRegistry;
this.clusterService = clusterService;
this.scriptService = scriptService;
@ -379,4 +381,54 @@ public class AlertService extends AbstractComponent {
}
/**
* Encapsulates the state of the alerts plugin.
*/
public static enum State {
/**
* The alerts plugin is not running and not functional.
*/
STOPPED(0),
/**
* The alerts plugin is performing the necessary operations to get into a started state.
*/
STARTING(1),
/**
* The alerts plugin is running and completely functional.
*/
STARTED(2),
/**
* The alerts plugin is shutting down and not functional.
*/
STOPPING(3);
private final byte id;
State(int id) {
this.id = (byte) id;
}
public byte getId() {
return id;
}
public static State fromId(byte id) {
switch (id) {
case 0:
return STOPPED;
case 1:
return STARTING;
case 2:
return STARTED;
case 3:
return STOPPING;
default:
throw new ElasticsearchIllegalArgumentException("Unknown id: " + id);
}
}
}
}

View File

@ -18,6 +18,8 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.alerts.actions.AlertAction;
import org.elasticsearch.alerts.actions.AlertActionRegistry;
import org.elasticsearch.alerts.support.AlertUtils;
import org.elasticsearch.alerts.support.TemplateUtils;
import org.elasticsearch.alerts.support.init.proxy.ClientProxy;
import org.elasticsearch.alerts.triggers.TriggerService;
import org.elasticsearch.cluster.ClusterState;
@ -61,7 +63,7 @@ public class AlertsStore extends AbstractComponent {
private final ClientProxy client;
private final TriggerService triggerService;
private final TemplateHelper templateHelper;
private final TemplateUtils templateUtils;
private final ConcurrentMap<String, Alert> alertMap;
private final AlertActionRegistry alertActionRegistry;
private final AtomicBoolean started = new AtomicBoolean(false);
@ -71,11 +73,11 @@ public class AlertsStore extends AbstractComponent {
@Inject
public AlertsStore(Settings settings, ClientProxy client, AlertActionRegistry alertActionRegistry,
TriggerService triggerService, TemplateHelper templateHelper) {
TriggerService triggerService, TemplateUtils templateUtils) {
super(settings);
this.client = client;
this.alertActionRegistry = alertActionRegistry;
this.templateHelper = templateHelper;
this.templateUtils = templateUtils;
this.alertMap = ConcurrentCollections.newConcurrentMap();
this.triggerService = triggerService;
// Not using component settings, to let AlertsStore and AlertActionManager share the same settings
@ -161,7 +163,7 @@ public class AlertsStore extends AbstractComponent {
alertMap.clear();
return false;
}
templateHelper.checkAndUploadIndexTemplate(state, "alerts");
templateUtils.checkAndUploadIndexTemplate(state, "alerts");
started.set(true);
return true;
} else {
@ -170,7 +172,7 @@ public class AlertsStore extends AbstractComponent {
}
} else {
logger.info("No previous .alert index, skip loading of alerts");
templateHelper.checkAndUploadIndexTemplate(state, "alerts");
templateUtils.checkAndUploadIndexTemplate(state, "alerts");
started.set(true);
return true;
}

View File

@ -1,59 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts;
import org.elasticsearch.ElasticsearchIllegalArgumentException;
/**
* Encapsulates the state of the alerts plugin.
*/
public enum State {
/**
* The alerts plugin is not running and not functional.
*/
STOPPED(0),
/**
* The alerts plugin is performing the necessary operations to get into a started state.
*/
STARTING(1),
/**
* The alerts plugin is running and completely functional.
*/
STARTED(2),
/**
* The alerts plugin is shutting down and not functional.
*/
STOPPING(3);
private final byte id;
State(int id) {
this.id = (byte) id;
}
public byte getId() {
return id;
}
public static State fromId(byte id) {
switch (id) {
case 0:
return STOPPED;
case 1:
return STARTING;
case 2:
return STARTED;
case 3:
return STOPPING;
default:
throw new ElasticsearchIllegalArgumentException("Unknown id: " + id);
}
}
}

View File

@ -16,7 +16,9 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.alerts.*;
import org.elasticsearch.alerts.plugin.AlertsPlugin;
import org.elasticsearch.alerts.AlertsPlugin;
import org.elasticsearch.alerts.support.AlertUtils;
import org.elasticsearch.alerts.support.TemplateUtils;
import org.elasticsearch.alerts.support.init.proxy.ClientProxy;
import org.elasticsearch.alerts.triggers.TriggerResult;
import org.elasticsearch.alerts.triggers.TriggerService;
@ -67,11 +69,11 @@ public class AlertActionService extends AbstractComponent {
public static final String ALERT_HISTORY_TYPE = "alerthistory";
private final ClientProxy client;
private AlertService alertService;
private AlertsService alertsService;
private final ThreadPool threadPool;
private final AlertsStore alertsStore;
private final TriggerService triggerService;
private final TemplateHelper templateHelper;
private final TemplateUtils templateUtils;
private final AlertActionRegistry actionRegistry;
private final int scrollSize;
@ -85,22 +87,22 @@ public class AlertActionService extends AbstractComponent {
@Inject
public AlertActionService(Settings settings, ClientProxy client, AlertActionRegistry actionRegistry,
ThreadPool threadPool, AlertsStore alertsStore, TriggerService triggerService,
TemplateHelper templateHelper) {
TemplateUtils templateUtils) {
super(settings);
this.client = client;
this.actionRegistry = actionRegistry;
this.threadPool = threadPool;
this.alertsStore = alertsStore;
this.triggerService = triggerService;
this.templateHelper = templateHelper;
this.templateUtils = templateUtils;
// Not using component settings, to let AlertsStore and AlertActionManager share the same settings
this.scrollTimeout = settings.getAsTime("alerts.scroll.timeout", TimeValue.timeValueSeconds(30));
this.scrollSize = settings.getAsInt("alerts.scroll.size", 100);
}
public void setAlertService(AlertService alertService){
this.alertService = alertService;
public void setAlertsService(AlertsService alertsService){
this.alertsService = alertsService;
}
public boolean start(ClusterState state) {
@ -111,7 +113,7 @@ public class AlertActionService extends AbstractComponent {
String[] indices = state.metaData().concreteIndices(IndicesOptions.lenientExpandOpen(), ALERT_HISTORY_INDEX_PREFIX + "*");
if (indices.length == 0) {
logger.info("No previous .alerthistory index, skip loading of alert actions");
templateHelper.checkAndUploadIndexTemplate(state, "alerthistory");
templateUtils.checkAndUploadIndexTemplate(state, "alerthistory");
doStart();
return true;
}
@ -135,7 +137,7 @@ public class AlertActionService extends AbstractComponent {
actionsToBeProcessed.clear();
return false;
}
templateHelper.checkAndUploadIndexTemplate(state, "alerthistory");
templateUtils.checkAndUploadIndexTemplate(state, "alerthistory");
doStart();
return true;
}
@ -368,7 +370,7 @@ public class AlertActionService extends AbstractComponent {
}
updateHistoryEntry(entry, AlertActionState.SEARCH_UNDERWAY);
logger.debug("Running an alert action entry for [{}]", entry.getAlertName());
TriggerResult result = alertService.executeAlert(entry);
TriggerResult result = alertsService.executeAlert(entry);
entry.setTriggerResponse(result.getTriggerResponse());
if (result.isTriggered()) {
entry.setTriggered(true);
@ -410,7 +412,7 @@ public class AlertActionService extends AbstractComponent {
while (started()) {
AlertHistory entry = actionsToBeProcessed.take();
if (entry != null) {
threadPool.executor(AlertsPlugin.ALERT_THREAD_POOL_NAME).execute(new AlertHistoryRunnable(entry));
threadPool.executor(AlertsPlugin.NAME).execute(new AlertHistoryRunnable(entry));
}
}
} catch (Exception e) {

View File

@ -7,7 +7,7 @@ package org.elasticsearch.alerts.actions;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.alerts.Alert;
import org.elasticsearch.alerts.AlertUtils;
import org.elasticsearch.alerts.support.AlertUtils;
import org.elasticsearch.alerts.triggers.AlertTrigger;
import org.elasticsearch.common.joda.time.DateTime;
import org.elasticsearch.common.xcontent.ToXContent;

View File

@ -0,0 +1,36 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.rest;
import org.elasticsearch.alerts.rest.action.*;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.inject.PreProcessModule;
import org.elasticsearch.rest.RestModule;
/**
*
*/
public class AlertsRestModule extends AbstractModule implements PreProcessModule {
@Override
public void processModule(Module module) {
if (module instanceof RestModule) {
RestModule restModule = (RestModule) module;
restModule.addRestAction(RestPutAlertAction.class);
restModule.addRestAction(RestDeleteAlertAction.class);
restModule.addRestAction(RestAlertsStatsAction.class);
restModule.addRestAction(RestGetAlertAction.class);
restModule.addRestAction(RestAlertServiceAction.class);
restModule.addRestAction(RestConfigAlertAction.class);
restModule.addRestAction(RestAckAlertAction.class);
}
}
@Override
protected void configure() {
}
}

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.rest;
package org.elasticsearch.alerts.rest.action;
import org.elasticsearch.alerts.AlertsStore;
import org.elasticsearch.alerts.client.AlertsClient;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.rest;
package org.elasticsearch.alerts.rest.action;
import org.elasticsearch.alerts.AlertsStore;
import org.elasticsearch.alerts.client.AlertsClient;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.rest;
package org.elasticsearch.alerts.rest.action;
import org.elasticsearch.alerts.AlertsStore;
import org.elasticsearch.alerts.client.AlertsClient;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.rest;
package org.elasticsearch.alerts.rest.action;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.alerts.AlertsStore;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.rest;
package org.elasticsearch.alerts.rest.action;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.alerts.AlertsStore;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.rest;
package org.elasticsearch.alerts.rest.action;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.alerts.AlertsStore;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.rest;
package org.elasticsearch.alerts.rest.action;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.alerts.AlertsStore;

View File

@ -1,6 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.rest;

View File

@ -7,8 +7,8 @@ package org.elasticsearch.alerts.scheduler;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.alerts.Alert;
import org.elasticsearch.alerts.AlertService;
import org.elasticsearch.alerts.plugin.AlertsPlugin;
import org.elasticsearch.alerts.AlertsService;
import org.elasticsearch.alerts.AlertsPlugin;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.joda.time.DateTime;
@ -26,7 +26,7 @@ public class AlertScheduler extends AbstractComponent {
// Not happy about it, but otherwise we're stuck with Quartz's SimpleThreadPool
private volatile static ThreadPool threadPool;
private AlertService alertService;
private AlertsService alertsService;
private volatile Scheduler scheduler;
@Inject
@ -35,8 +35,8 @@ public class AlertScheduler extends AbstractComponent {
AlertScheduler.threadPool = threadPool;
}
public void setAlertService(AlertService alertService){
this.alertService = alertService;
public void setAlertsService(AlertsService alertsService){
this.alertsService = alertsService;
}
/**
@ -88,7 +88,7 @@ public class AlertScheduler extends AbstractComponent {
public void executeAlert(String alertName, JobExecutionContext jobExecutionContext){
DateTime scheduledFireTime = new DateTime(jobExecutionContext.getScheduledFireTime());
DateTime fireTime = new DateTime(jobExecutionContext.getFireTime());
alertService.scheduleAlert(alertName, scheduledFireTime, fireTime);
alertsService.scheduleAlert(alertName, scheduledFireTime, fireTime);
}
public boolean remove(String alertName) {

View File

@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.scheduler;
import org.elasticsearch.common.inject.AbstractModule;
/**
*
*/
public class AlertsSchedulerModule extends AbstractModule {
@Override
protected void configure() {
bind(AlertScheduler.class).asEagerSingleton();
}
}

View File

@ -1,6 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.scheduler;

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts;
package org.elasticsearch.alerts.support;
import org.elasticsearch.ElasticsearchIllegalArgumentException;
import org.elasticsearch.ElasticsearchIllegalStateException;

View File

@ -3,12 +3,13 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts;
package org.elasticsearch.alerts.support;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest;
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse;
import org.elasticsearch.action.admin.indices.template.put.TransportPutIndexTemplateAction;
import org.elasticsearch.alerts.AlertsStore;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData;
import org.elasticsearch.common.component.AbstractComponent;
@ -25,12 +26,12 @@ import java.util.regex.Pattern;
/**
*/
public class TemplateHelper extends AbstractComponent {
public class TemplateUtils extends AbstractComponent {
private final TransportPutIndexTemplateAction transportPutIndexTemplateAction;
@Inject
public TemplateHelper(Settings settings, TransportPutIndexTemplateAction transportPutIndexTemplateAction) {
public TemplateUtils(Settings settings, TransportPutIndexTemplateAction transportPutIndexTemplateAction) {
super(settings);
this.transportPutIndexTemplateAction = transportPutIndexTemplateAction;
}

View File

@ -9,7 +9,7 @@ import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeOperationAction;
import org.elasticsearch.alerts.AlertService;
import org.elasticsearch.alerts.AlertsService;
import org.elasticsearch.alerts.AlertsStore;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.ClusterState;
@ -25,13 +25,13 @@ import org.elasticsearch.transport.TransportService;
*/
public class TransportAckAlertAction extends TransportMasterNodeOperationAction<AckAlertRequest, AckAlertResponse> {
private final AlertService alertService;
private final AlertsService alertsService;
@Inject
public TransportAckAlertAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters, AlertService alertService) {
ThreadPool threadPool, ActionFilters actionFilters, AlertsService alertsService) {
super(settings, AckAlertAction.NAME, transportService, clusterService, threadPool, actionFilters);
this.alertService = alertService;
this.alertsService = alertsService;
}
@Override
@ -52,7 +52,7 @@ public class TransportAckAlertAction extends TransportMasterNodeOperationAction<
@Override
protected void masterOperation(AckAlertRequest request, ClusterState state, ActionListener<AckAlertResponse> listener) throws ElasticsearchException {
try {
AckAlertResponse response = new AckAlertResponse(alertService.ackAlert(request.getAlertName()));
AckAlertResponse response = new AckAlertResponse(alertsService.ackAlert(request.getAlertName()));
listener.onResponse(response);
} catch (Exception e) {
listener.onFailure(e);

View File

@ -9,7 +9,7 @@ import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeOperationAction;
import org.elasticsearch.alerts.AlertService;
import org.elasticsearch.alerts.AlertsService;
import org.elasticsearch.alerts.AlertsStore;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.ClusterState;
@ -25,13 +25,13 @@ import org.elasticsearch.transport.TransportService;
*/
public class TransportDeleteAlertAction extends TransportMasterNodeOperationAction<DeleteAlertRequest, DeleteAlertResponse> {
private final AlertService alertService;
private final AlertsService alertsService;
@Inject
public TransportDeleteAlertAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters, AlertService alertService) {
ThreadPool threadPool, ActionFilters actionFilters, AlertsService alertsService) {
super(settings, DeleteAlertAction.NAME, transportService, clusterService, threadPool, actionFilters);
this.alertService = alertService;
this.alertsService = alertsService;
}
@Override
@ -52,7 +52,7 @@ public class TransportDeleteAlertAction extends TransportMasterNodeOperationActi
@Override
protected void masterOperation(DeleteAlertRequest request, ClusterState state, ActionListener<DeleteAlertResponse> listener) throws ElasticsearchException {
try {
DeleteAlertResponse response = new DeleteAlertResponse(alertService.deleteAlert(request.getAlertName()));
DeleteAlertResponse response = new DeleteAlertResponse(alertsService.deleteAlert(request.getAlertName()));
listener.onResponse(response);
} catch (Exception e) {
listener.onFailure(e);

View File

@ -11,7 +11,7 @@ import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeOperationAction;
import org.elasticsearch.alerts.Alert;
import org.elasticsearch.alerts.AlertService;
import org.elasticsearch.alerts.AlertsService;
import org.elasticsearch.alerts.AlertsStore;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.ClusterState;
@ -32,13 +32,13 @@ import java.io.IOException;
*/
public class TransportGetAlertAction extends TransportMasterNodeOperationAction<GetAlertRequest, GetAlertResponse> {
private final AlertService alertService;
private final AlertsService alertsService;
@Inject
public TransportGetAlertAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters, AlertService alertService) {
ThreadPool threadPool, ActionFilters actionFilters, AlertsService alertsService) {
super(settings, GetAlertAction.NAME, transportService, clusterService, threadPool, actionFilters);
this.alertService = alertService;
this.alertsService = alertsService;
}
@Override
@ -58,7 +58,7 @@ public class TransportGetAlertAction extends TransportMasterNodeOperationAction<
@Override
protected void masterOperation(GetAlertRequest request, ClusterState state, ActionListener<GetAlertResponse> listener) throws ElasticsearchException {
Alert alert = alertService.getAlert(request.alertName());
Alert alert = alertsService.getAlert(request.alertName());
GetResult getResult;
if (alert != null) {
BytesReference alertSource = null;

View File

@ -10,7 +10,7 @@ import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeOperationAction;
import org.elasticsearch.alerts.AlertService;
import org.elasticsearch.alerts.AlertsService;
import org.elasticsearch.alerts.AlertsStore;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.ClusterState;
@ -25,13 +25,13 @@ import org.elasticsearch.transport.TransportService;
*/
public class TransportPutAlertAction extends TransportMasterNodeOperationAction<PutAlertRequest, PutAlertResponse> {
private final AlertService alertService;
private final AlertsService alertsService;
@Inject
public TransportPutAlertAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters, AlertService alertService) {
ThreadPool threadPool, ActionFilters actionFilters, AlertsService alertsService) {
super(settings, PutAlertAction.NAME, transportService, clusterService, threadPool, actionFilters);
this.alertService = alertService;
this.alertsService = alertsService;
}
@Override
@ -52,7 +52,7 @@ public class TransportPutAlertAction extends TransportMasterNodeOperationAction<
@Override
protected void masterOperation(PutAlertRequest request, ClusterState state, ActionListener<PutAlertResponse> listener) throws ElasticsearchException {
try {
IndexResponse indexResponse = alertService.putAlert(request.getAlertName(), request.getAlertSource());
IndexResponse indexResponse = alertsService.putAlert(request.getAlertName(), request.getAlertSource());
listener.onResponse(new PutAlertResponse(indexResponse));
} catch (Exception e) {
listener.onFailure(e);

View File

@ -10,7 +10,7 @@ import org.elasticsearch.ElasticsearchIllegalArgumentException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeOperationAction;
import org.elasticsearch.alerts.AlertService;
import org.elasticsearch.alerts.AlertsService;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
@ -24,12 +24,12 @@ import org.elasticsearch.transport.TransportService;
*/
public class TransportAlertsServiceAction extends TransportMasterNodeOperationAction<AlertsServiceRequest, AlertsServiceResponse> {
private final AlertService alertService;
private final AlertsService alertsService;
@Inject
public TransportAlertsServiceAction(Settings settings, String actionName, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, AlertService alertService) {
public TransportAlertsServiceAction(Settings settings, String actionName, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, AlertsService alertsService) {
super(settings, actionName, transportService, clusterService, threadPool, actionFilters);
this.alertService = alertService;
this.alertsService = alertsService;
}
@Override
@ -51,14 +51,14 @@ public class TransportAlertsServiceAction extends TransportMasterNodeOperationAc
protected void masterOperation(AlertsServiceRequest request, ClusterState state, ActionListener<AlertsServiceResponse> listener) throws ElasticsearchException {
switch (request.getCommand()) {
case "start":
alertService.start();
alertsService.start();
break;
case "stop":
alertService.stop();
alertsService.stop();
break;
case "restart":
alertService.start();
alertService.stop();
alertsService.start();
alertsService.stop();
break;
default:
listener.onFailure(new ElasticsearchIllegalArgumentException("Command [" + request.getCommand() + "] is undefined"));

View File

@ -7,8 +7,8 @@ package org.elasticsearch.alerts.transport.actions.stats;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.alerts.AlertsBuild;
import org.elasticsearch.alerts.AlertsService;
import org.elasticsearch.alerts.AlertsVersion;
import org.elasticsearch.alerts.State;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@ -22,7 +22,7 @@ public class AlertsStatsResponse extends ActionResponse {
private AlertsVersion version;
private AlertsBuild build;
private long numberOfRegisteredAlerts;
private State alertManagerState;
private AlertsService.State alertManagerState;
private boolean alertActionManagerStarted;
private long alertActionManagerQueueSize;
private long alertActionManagerLargestQueueSize;
@ -55,11 +55,11 @@ public class AlertsStatsResponse extends ActionResponse {
/**
* Returns the state of the alert manager.
*/
public State getAlertManagerStarted() {
public AlertsService.State getAlertManagerStarted() {
return alertManagerState;
}
void setAlertManagerState(State alertManagerState) {
void setAlertManagerState(AlertsService.State alertManagerState) {
this.alertManagerState = alertManagerState;
}
@ -113,7 +113,7 @@ public class AlertsStatsResponse extends ActionResponse {
numberOfRegisteredAlerts = in.readLong();
alertActionManagerQueueSize = in.readLong();
alertActionManagerLargestQueueSize = in.readLong();
alertManagerState = State.fromId(in.readByte());
alertManagerState = AlertsService.State.fromId(in.readByte());
alertActionManagerStarted = in.readBoolean();
version = AlertsVersion.readVersion(in);
build = AlertsBuild.readBuild(in);

View File

@ -9,7 +9,7 @@ import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.TransportMasterNodeOperationAction;
import org.elasticsearch.alerts.AlertService;
import org.elasticsearch.alerts.AlertsService;
import org.elasticsearch.alerts.AlertsBuild;
import org.elasticsearch.alerts.AlertsVersion;
import org.elasticsearch.alerts.actions.AlertActionService;
@ -27,15 +27,15 @@ import org.elasticsearch.transport.TransportService;
*/
public class TransportAlertsStatsAction extends TransportMasterNodeOperationAction<AlertsStatsRequest, AlertsStatsResponse> {
private final AlertService alertService;
private final AlertsService alertsService;
private final AlertActionService alertActionService;
@Inject
public TransportAlertsStatsAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters, AlertService alertService,
ThreadPool threadPool, ActionFilters actionFilters, AlertsService alertsService,
AlertActionService alertActionService) {
super(settings, AlertsStatsAction.NAME, transportService, clusterService, threadPool, actionFilters);
this.alertService = alertService;
this.alertsService = alertsService;
this.alertActionService = alertActionService;
}
@ -57,10 +57,10 @@ public class TransportAlertsStatsAction extends TransportMasterNodeOperationActi
@Override
protected void masterOperation(AlertsStatsRequest request, ClusterState state, ActionListener<AlertsStatsResponse> listener) throws ElasticsearchException {
AlertsStatsResponse statsResponse = new AlertsStatsResponse();
statsResponse.setAlertManagerState(alertService.getState());
statsResponse.setAlertManagerState(alertsService.getState());
statsResponse.setAlertActionManagerStarted(alertActionService.started());
statsResponse.setAlertActionManagerQueueSize(alertActionService.getQueueSize());
statsResponse.setNumberOfRegisteredAlerts(alertService.getNumberOfAlerts());
statsResponse.setNumberOfRegisteredAlerts(alertsService.getNumberOfAlerts());
statsResponse.setAlertActionManagerLargestQueueSize(alertActionService.getLargestQueueSize());
statsResponse.setVersion(AlertsVersion.CURRENT);
statsResponse.setBuild(AlertsBuild.CURRENT);

View File

@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.alerts.triggers;
import org.elasticsearch.common.inject.AbstractModule;
/**
*
*/
public class AlertsTriggerModule extends AbstractModule {
@Override
protected void configure() {
bind(TriggerService.class).asEagerSingleton();
}
}

View File

@ -9,7 +9,7 @@ import org.elasticsearch.ElasticsearchIllegalArgumentException;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.alerts.Alert;
import org.elasticsearch.alerts.AlertUtils;
import org.elasticsearch.alerts.support.AlertUtils;
import org.elasticsearch.alerts.support.init.proxy.ClientProxy;
import org.elasticsearch.alerts.support.init.proxy.ScriptServiceProxy;
import org.elasticsearch.common.collect.ImmutableOpenMap;

View File

@ -1,2 +1,2 @@
plugin=org.elasticsearch.alerts.plugin.AlertsPlugin
plugin=org.elasticsearch.alerts.AlertsPlugin
version=${project.version}

View File

@ -11,7 +11,7 @@ import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.alerts.actions.AlertActionService;
import org.elasticsearch.alerts.actions.AlertActionState;
import org.elasticsearch.alerts.client.AlertsClient;
import org.elasticsearch.alerts.plugin.AlertsPlugin;
import org.elasticsearch.alerts.support.AlertUtils;
import org.elasticsearch.alerts.transport.actions.stats.AlertsStatsResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterState;
@ -71,7 +71,7 @@ public abstract class AbstractAlertingTests extends ElasticsearchIntegrationTest
public void startAlertsIfNodesExist() throws Exception {
if (internalTestCluster().size() > 0) {
AlertsStatsResponse response = alertClient().prepareAlertsStats().get();
if (response.getAlertManagerStarted() == State.STOPPED) {
if (response.getAlertManagerStarted() == AlertsService.State.STOPPED) {
logger.info("[{}#{}]: starting alerts", getTestClass().getSimpleName(), getTestName());
startAlerting();
} else {
@ -223,7 +223,7 @@ public abstract class AbstractAlertingTests extends ElasticsearchIntegrationTest
assertBusy(new Runnable() {
@Override
public void run() {
assertThat(alertClient().prepareAlertsStats().get().getAlertManagerStarted(), is(State.STARTED));
assertThat(alertClient().prepareAlertsStats().get().getAlertManagerStarted(), is(AlertsService.State.STARTED));
}
});
}
@ -232,7 +232,7 @@ public abstract class AbstractAlertingTests extends ElasticsearchIntegrationTest
assertBusy(new Runnable() {
@Override
public void run() {
assertThat(alertClient().prepareAlertsStats().get().getAlertManagerStarted(), is(State.STOPPED));
assertThat(alertClient().prepareAlertsStats().get().getAlertManagerStarted(), is(AlertsService.State.STOPPED));
}
});
}
@ -330,29 +330,29 @@ public abstract class AbstractAlertingTests extends ElasticsearchIntegrationTest
// First manually stop alerting on non elected master node, this will prevent that alerting becomes active
// on these nodes
for (String node : nodes) {
AlertService alertService = _testCluster.getInstance(AlertService.class, node);
assertThat(alertService.getState(), equalTo(State.STOPPED));
alertService.stop(); // Prevents these nodes from starting alerting when new elected master node is picked.
AlertsService alertsService = _testCluster.getInstance(AlertsService.class, node);
assertThat(alertsService.getState(), equalTo(AlertsService.State.STOPPED));
alertsService.stop(); // Prevents these nodes from starting alerting when new elected master node is picked.
}
// Then stop alerting on elected master node and wait until alerting has stopped on it.
final AlertService alertService = _testCluster.getInstance(AlertService.class, masterNode);
final AlertsService alertsService = _testCluster.getInstance(AlertsService.class, masterNode);
try {
assertBusy(new Runnable() {
@Override
public void run() {
assertThat(alertService.getState(), not(equalTo(State.STARTING)));
assertThat(alertsService.getState(), not(equalTo(AlertsService.State.STARTING)));
}
});
} catch (Exception e) {
throw new RuntimeException(e);
}
alertService.stop();
alertsService.stop();
try {
assertBusy(new Runnable() {
@Override
public void run() {
assertThat(alertService.getState(), equalTo(State.STOPPED));
assertThat(alertsService.getState(), equalTo(AlertsService.State.STOPPED));
}
});
} catch (Exception e) {

View File

@ -50,7 +50,7 @@ public class BootStrapTest extends AbstractAlertingTests {
AlertsStatsResponse response = alertClient().prepareAlertsStats().get();
assertTrue(response.isAlertActionManagerStarted());
assertThat(response.getAlertManagerStarted(), equalTo(State.STARTED));
assertThat(response.getAlertManagerStarted(), equalTo(AlertsService.State.STARTED));
assertThat(response.getNumberOfRegisteredAlerts(), equalTo(1L));
}
@ -61,7 +61,7 @@ public class BootStrapTest extends AbstractAlertingTests {
AlertsStatsResponse response = alertClient().prepareAlertsStats().get();
assertTrue(response.isAlertActionManagerStarted());
assertThat(response.getAlertManagerStarted(), equalTo(State.STARTED));
assertThat(response.getAlertManagerStarted(), equalTo(AlertsService.State.STARTED));
assertThat(response.getNumberOfRegisteredAlerts(), equalTo(0L));
SearchRequest searchRequest = createTriggerSearchRequest("my-index").source(searchSource().query(termQuery("field", "value")));
@ -94,7 +94,7 @@ public class BootStrapTest extends AbstractAlertingTests {
response = alertClient().prepareAlertsStats().get();
assertTrue(response.isAlertActionManagerStarted());
assertThat(response.getAlertManagerStarted(), equalTo(State.STARTED));
assertThat(response.getAlertManagerStarted(), equalTo(AlertsService.State.STARTED));
assertThat(response.getNumberOfRegisteredAlerts(), equalTo(0L));
assertThat(response.getAlertActionManagerLargestQueueSize(), equalTo(1L));
}
@ -140,7 +140,7 @@ public class BootStrapTest extends AbstractAlertingTests {
AlertsStatsResponse response = alertClient().prepareAlertsStats().get();
assertTrue(response.isAlertActionManagerStarted());
assertThat(response.getAlertManagerStarted(), equalTo(State.STARTED));
assertThat(response.getAlertManagerStarted(), equalTo(AlertsService.State.STARTED));
long expectedMaximumQueueSize = numberOfAlertHistoryEntriesPerIndex * numberOfAlertHistoryIndices ;
assertThat(response.getAlertActionManagerLargestQueueSize(), equalTo(expectedMaximumQueueSize));

View File

@ -141,8 +141,8 @@ public class NoMasterNodeTests extends AbstractAlertingTests {
}
}), equalTo(true));
// Ensure that the alert manager doesn't run elsewhere
for (AlertService alertService : internalTestCluster().getInstances(AlertService.class)) {
assertThat(alertService.getState(), is(State.STOPPED));
for (AlertsService alertsService : internalTestCluster().getInstances(AlertsService.class)) {
assertThat(alertsService.getState(), is(AlertsService.State.STOPPED));
}
}

View File

@ -9,6 +9,7 @@ import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.alerts.actions.AlertAction;
import org.elasticsearch.alerts.actions.IndexAlertAction;
import org.elasticsearch.alerts.support.AlertUtils;
import org.elasticsearch.alerts.transport.actions.put.PutAlertResponse;
import org.elasticsearch.alerts.triggers.ScriptedTrigger;
import org.elasticsearch.common.joda.time.DateTime;

View File

@ -11,6 +11,7 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.ShardSearchFailure;
import org.elasticsearch.alerts.*;
import org.elasticsearch.alerts.client.AlertsClient;
import org.elasticsearch.alerts.support.AlertUtils;
import org.elasticsearch.alerts.transport.actions.delete.DeleteAlertRequest;
import org.elasticsearch.alerts.transport.actions.delete.DeleteAlertResponse;
import org.elasticsearch.alerts.transport.actions.get.GetAlertRequest;
@ -110,11 +111,11 @@ public class AlertActionsTest extends AbstractAlertingTests {
.setSource(jsonBuilder().startObject().startObject("template").startObject("match_all").endObject().endObject().endObject())
.get();
final AlertService alertService = internalTestCluster().getInstance(AlertService.class, internalTestCluster().getMasterName());
final AlertsService alertsService = internalTestCluster().getInstance(AlertsService.class, internalTestCluster().getMasterName());
assertBusy(new Runnable() {
@Override
public void run() {
assertThat(alertService.getState(), is(State.STARTED));
assertThat(alertsService.getState(), is(AlertsService.State.STARTED));
}
});
final AtomicBoolean alertActionInvoked = new AtomicBoolean(false);

View File

@ -6,10 +6,7 @@
package org.elasticsearch.alerts.actions;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.alerts.AbstractAlertingTests;
import org.elasticsearch.alerts.AlertsBuild;
import org.elasticsearch.alerts.AlertsVersion;
import org.elasticsearch.alerts.State;
import org.elasticsearch.alerts.*;
import org.elasticsearch.alerts.client.AlertsClient;
import org.elasticsearch.alerts.transport.actions.stats.AlertsStatsRequest;
import org.elasticsearch.alerts.transport.actions.stats.AlertsStatsResponse;
@ -36,7 +33,7 @@ public class AlertStatsTests extends AbstractAlertingTests {
AlertsStatsResponse response = alertClient().alertsStats(alertsStatsRequest).actionGet();
assertTrue(response.isAlertActionManagerStarted());
assertThat(response.getAlertManagerStarted(), equalTo(State.STARTED));
assertThat(response.getAlertManagerStarted(), equalTo(AlertsService.State.STARTED));
assertThat(response.getAlertActionManagerQueueSize(), equalTo(0L));
assertThat(response.getNumberOfRegisteredAlerts(), equalTo(0L));
assertThat(response.getAlertActionManagerLargestQueueSize(), equalTo(0L));
@ -52,7 +49,7 @@ public class AlertStatsTests extends AbstractAlertingTests {
AlertsStatsResponse response = alertsClient.alertsStats(alertsStatsRequest).actionGet();
assertTrue(response.isAlertActionManagerStarted());
assertThat(response.getAlertManagerStarted(), equalTo(State.STARTED));
assertThat(response.getAlertManagerStarted(), equalTo(AlertsService.State.STARTED));
SearchRequest searchRequest = createTriggerSearchRequest("my-index").source(searchSource().query(termQuery("field", "value")));
BytesReference alertSource = createAlertSource("* * * * * ? *", searchRequest, "hits.total == 1");
@ -67,7 +64,7 @@ public class AlertStatsTests extends AbstractAlertingTests {
Thread.sleep(waitTime.getMillis());
assertTrue(response.isAlertActionManagerStarted());
assertThat(response.getAlertManagerStarted(), equalTo(State.STARTED));
assertThat(response.getAlertManagerStarted(), equalTo(AlertsService.State.STARTED));
assertThat(response.getNumberOfRegisteredAlerts(), equalTo(1L));
//assertThat(response.getAlertActionManagerLargestQueueSize(), greaterThan(0L));
}