Remove extraneous methods and change IndexAlertAction.NAME

This commit removes the uneeded addAlert methods in AlertManager and AlertsStore and
also changes the IndexAlertAction.NAME to "indices:data/write/alert/index"

Original commit: elastic/x-pack-elasticsearch@19013dcf3e
This commit is contained in:
Brian Murphy 2014-11-06 11:14:58 +00:00
parent bce97abc1d
commit f86544497a
3 changed files with 1 additions and 29 deletions

View File

@ -97,19 +97,6 @@ public class AlertManager extends AbstractComponent {
return result.v2(); return result.v2();
} }
public IndexResponse addAlert(Alert alert) {
ensureStarted();
IndexResponse indexResponse = null;
try {
indexResponse = alertsStore.createAlert(alert);
} catch (IOException ioe) {
throw new ElasticsearchException("Failed to create alert [" + alert + "]", ioe);
}
scheduler.add(alert.alertName(), alert);
return indexResponse;
}
public List<Alert> getAllAlerts() { public List<Alert> getAllAlerts() {
ensureStarted(); ensureStarted();
return ImmutableList.copyOf(alertsStore.getAlerts().values()); return ImmutableList.copyOf(alertsStore.getAlerts().values());

View File

@ -99,21 +99,6 @@ public class AlertsStore extends AbstractComponent {
return new Tuple<>(alert, response); return new Tuple<>(alert, response);
} }
/**
* Creates an alert with the specified and fails if an alert with the name already exists.
*/
public IndexResponse createAlert(Alert alert) throws IOException {
if (alertMap.putIfAbsent(alert.alertName(), alert) == null) {
XContentBuilder jsonBuilder = XContentFactory.jsonBuilder();
alert.toXContent(jsonBuilder, ToXContent.EMPTY_PARAMS);
IndexResponse response = persistAlert(alert.alertName(), jsonBuilder.bytes(), IndexRequest.OpType.CREATE);
alert.version(response.getVersion());
return response;
} else {
throw new ElasticsearchIllegalArgumentException("There is already an alert named [" + alert.alertName() + "]");
}
}
public IndexResponse updateAlert(Alert alert) throws IOException { public IndexResponse updateAlert(Alert alert) throws IOException {
return updateAlert(alert, false); return updateAlert(alert, false);
} }

View File

@ -13,7 +13,7 @@ import org.elasticsearch.alerts.client.AlertsClientInterface;
public class IndexAlertAction extends AlertsClientAction<IndexAlertRequest, IndexAlertResponse, IndexAlertRequestBuilder> { public class IndexAlertAction extends AlertsClientAction<IndexAlertRequest, IndexAlertResponse, IndexAlertRequestBuilder> {
public static final IndexAlertAction INSTANCE = new IndexAlertAction(); public static final IndexAlertAction INSTANCE = new IndexAlertAction();
public static final String NAME = "indices:data/write/alert/create"; public static final String NAME = "indices:data/write/alert/index";
private IndexAlertAction() { private IndexAlertAction() {
super(NAME); super(NAME);