Core: Transport classes are now managed by Guide and are injected into the AlertsClient
Original commit: elastic/x-pack-elasticsearch@3cfdd3dc71
This commit is contained in:
parent
ecdfdb11d9
commit
e5293ba0c3
|
@ -9,11 +9,16 @@ package org.elasticsearch.alerts;
|
|||
import org.elasticsearch.alerts.actions.AlertActionManager;
|
||||
import org.elasticsearch.alerts.actions.AlertActionRegistry;
|
||||
import org.elasticsearch.alerts.client.AlertsClient;
|
||||
import org.elasticsearch.alerts.client.AlertsClientInterface;
|
||||
import org.elasticsearch.alerts.rest.RestAlertsStatsAction;
|
||||
import org.elasticsearch.alerts.rest.RestDeleteAlertAction;
|
||||
import org.elasticsearch.alerts.rest.RestGetAlertAction;
|
||||
import org.elasticsearch.alerts.rest.RestIndexAlertAction;
|
||||
import org.elasticsearch.alerts.scheduler.AlertScheduler;
|
||||
import org.elasticsearch.alerts.transport.actions.delete.TransportDeleteAlertAction;
|
||||
import org.elasticsearch.alerts.transport.actions.get.TransportGetAlertAction;
|
||||
import org.elasticsearch.alerts.transport.actions.index.TransportIndexAlertAction;
|
||||
import org.elasticsearch.alerts.transport.actions.stats.TransportAlertStatsAction;
|
||||
import org.elasticsearch.alerts.triggers.TriggerManager;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
|
||||
|
@ -22,6 +27,7 @@ public class AlertingModule extends AbstractModule {
|
|||
|
||||
@Override
|
||||
protected void configure() {
|
||||
// Core components
|
||||
bind(TemplateHelper.class).asEagerSingleton();
|
||||
bind(AlertsStore.class).asEagerSingleton();
|
||||
bind(AlertManager.class).asEagerSingleton();
|
||||
|
@ -29,12 +35,19 @@ public class AlertingModule extends AbstractModule {
|
|||
bind(TriggerManager.class).asEagerSingleton();
|
||||
bind(AlertScheduler.class).asEagerSingleton();
|
||||
bind(AlertActionRegistry.class).asEagerSingleton();
|
||||
|
||||
// Transport and client layer
|
||||
bind(TransportIndexAlertAction.class).asEagerSingleton();
|
||||
bind(TransportDeleteAlertAction.class).asEagerSingleton();
|
||||
bind(TransportGetAlertAction.class).asEagerSingleton();
|
||||
bind(TransportAlertStatsAction.class).asEagerSingleton();
|
||||
bind(AlertsClientInterface.class).to(AlertsClient.class).asEagerSingleton();
|
||||
|
||||
// Rest layer
|
||||
bind(RestIndexAlertAction.class).asEagerSingleton();
|
||||
bind(RestDeleteAlertAction.class).asEagerSingleton();
|
||||
bind(RestAlertsStatsAction.class).asEagerSingleton();
|
||||
bind(RestGetAlertAction.class).asEagerSingleton();
|
||||
//bind(AlertsClientInterface.class).to(AlertsClient.class).asEagerSingleton();
|
||||
bind(AlertsClient.class).asEagerSingleton();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,56 +6,34 @@
|
|||
package org.elasticsearch.alerts.client;
|
||||
|
||||
import org.elasticsearch.action.*;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.TransportAction;
|
||||
import org.elasticsearch.alerts.AlertManager;
|
||||
import org.elasticsearch.alerts.actions.AlertActionManager;
|
||||
import org.elasticsearch.alerts.transport.actions.index.*;
|
||||
import org.elasticsearch.alerts.transport.actions.delete.*;
|
||||
import org.elasticsearch.alerts.transport.actions.get.*;
|
||||
import org.elasticsearch.alerts.transport.actions.index.*;
|
||||
import org.elasticsearch.alerts.transport.actions.stats.*;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.support.Headers;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AlertsClient implements AlertsClientInterface {
|
||||
|
||||
private final Headers headers;
|
||||
private final Map<GenericAction, TransportAction> internalActions;
|
||||
private final ThreadPool threadPool;
|
||||
private final ImmutableMap<GenericAction, TransportAction> internalActions;
|
||||
|
||||
@Inject
|
||||
public AlertsClient(ThreadPool threadPool,
|
||||
Settings settings,
|
||||
Headers headers,
|
||||
ActionFilters filters,
|
||||
TransportService transportService, ClusterService clusterService, AlertManager alertManager,
|
||||
Client client, AlertActionManager alertActionManager) {
|
||||
public AlertsClient(ThreadPool threadPool, Headers headers, TransportIndexAlertAction transportIndexAlertAction,
|
||||
TransportGetAlertAction transportGetAlertAction, TransportDeleteAlertAction transportDeleteAlertAction,
|
||||
TransportAlertStatsAction transportAlertStatsAction) {
|
||||
this.headers = headers;
|
||||
internalActions = new HashMap<>();
|
||||
this.threadPool = threadPool;
|
||||
|
||||
internalActions.put(IndexAlertAction.INSTANCE, new TransportIndexAlertAction(settings,
|
||||
IndexAlertAction.NAME, transportService, clusterService, threadPool, filters, alertManager));
|
||||
|
||||
internalActions.put(GetAlertAction.INSTANCE, new TransportGetAlertAction(settings,
|
||||
GetAlertAction.NAME, threadPool, filters, client));
|
||||
|
||||
internalActions.put(DeleteAlertAction.INSTANCE, new TransportDeleteAlertAction(settings,
|
||||
DeleteAlertAction.NAME, transportService, clusterService, threadPool, filters, alertManager));
|
||||
|
||||
internalActions.put(AlertsStatsAction.INSTANCE, new TransportAlertStatsAction(settings,
|
||||
AlertsStatsAction.NAME, transportService, clusterService, threadPool, filters, alertManager,
|
||||
alertActionManager));
|
||||
|
||||
|
||||
internalActions = ImmutableMap.<GenericAction, TransportAction>builder()
|
||||
.put(IndexAlertAction.INSTANCE, transportIndexAlertAction)
|
||||
.put(GetAlertAction.INSTANCE, transportGetAlertAction)
|
||||
.put(DeleteAlertAction.INSTANCE, transportDeleteAlertAction)
|
||||
.put(AlertsStatsAction.INSTANCE, transportAlertStatsAction)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
*/
|
||||
package org.elasticsearch.alerts.client;
|
||||
|
||||
import org.elasticsearch.action.*;
|
||||
import org.elasticsearch.alerts.Alert;
|
||||
import org.elasticsearch.action.Action;
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionRequestBuilder;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
|
||||
/**
|
||||
* Created by brian on 10/29/14.
|
||||
* Base alert action class.
|
||||
*/
|
||||
|
||||
public abstract class AlertsClientAction<Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder, AlertsClientInterface>>
|
||||
extends Action<Request, Response, RequestBuilder, AlertsClientInterface> {
|
||||
public abstract class AlertsClientAction<Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder, AlertsClientInterface>> extends Action<Request, Response, RequestBuilder, AlertsClientInterface> {
|
||||
|
||||
protected AlertsClientAction(String name) {
|
||||
super(name);
|
||||
|
|
|
@ -29,10 +29,9 @@ public class TransportDeleteAlertAction extends TransportMasterNodeOperationActi
|
|||
private final AlertManager alertManager;
|
||||
|
||||
@Inject
|
||||
public TransportDeleteAlertAction(Settings settings, String actionName, TransportService transportService,
|
||||
ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
AlertManager alertManager) {
|
||||
super(settings, actionName, transportService, clusterService, threadPool, actionFilters);
|
||||
public TransportDeleteAlertAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters, AlertManager alertManager) {
|
||||
super(settings, DeleteAlertAction.NAME, transportService, clusterService, threadPool, actionFilters);
|
||||
this.alertManager = alertManager;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,8 @@ public class TransportGetAlertAction extends TransportAction<GetAlertRequest, G
|
|||
private final Client client;
|
||||
|
||||
@Inject
|
||||
public TransportGetAlertAction(Settings settings, String actionName, ThreadPool threadPool,
|
||||
ActionFilters actionFilters, Client client) {
|
||||
super(settings, actionName, threadPool, actionFilters);
|
||||
public TransportGetAlertAction(Settings settings, ThreadPool threadPool, ActionFilters actionFilters, Client client) {
|
||||
super(settings, GetAlertAction.NAME, threadPool, actionFilters);
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,9 @@ public class TransportIndexAlertAction extends TransportMasterNodeOperationActio
|
|||
private final AlertManager alertManager;
|
||||
|
||||
@Inject
|
||||
public TransportIndexAlertAction(Settings settings, String actionName, TransportService transportService,
|
||||
ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
AlertManager alertManager) {
|
||||
super(settings, actionName, transportService, clusterService, threadPool, actionFilters);
|
||||
public TransportIndexAlertAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters, AlertManager alertManager) {
|
||||
super(settings, IndexAlertAction.NAME, transportService, clusterService, threadPool, actionFilters);
|
||||
this.alertManager = alertManager;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,10 +28,10 @@ public class TransportAlertStatsAction extends TransportMasterNodeOperationActio
|
|||
private final AlertActionManager alertActionManager;
|
||||
|
||||
@Inject
|
||||
public TransportAlertStatsAction(Settings settings, String actionName, TransportService transportService,
|
||||
ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
AlertManager alertManager, AlertActionManager alertActionManager) {
|
||||
super(settings, actionName, transportService, clusterService, threadPool, actionFilters);
|
||||
public TransportAlertStatsAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters, AlertManager alertManager,
|
||||
AlertActionManager alertActionManager) {
|
||||
super(settings, AlertsStatsAction.NAME, transportService, clusterService, threadPool, actionFilters);
|
||||
this.alertManager = alertManager;
|
||||
this.alertActionManager = alertActionManager;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue