Alerting: Split alerting into packages

This commit adds separate packages for actions,triggers,rest, and the scheduler.

Original commit: elastic/x-pack-elasticsearch@e104bbc521
This commit is contained in:
Brian Murphy 2014-10-24 12:32:18 +01:00
parent 9b7b2214c0
commit db9fae8021
23 changed files with 87 additions and 25 deletions

View File

@ -5,12 +5,12 @@
*/
package org.elasticsearch.alerting;
import org.elasticsearch.alerting.actions.AlertAction;
import org.elasticsearch.alerting.triggers.AlertTrigger;
import org.elasticsearch.common.joda.time.DateTime;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import java.io.IOException;
import java.util.List;

View File

@ -20,6 +20,11 @@ import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.alerting.actions.AlertAction;
import org.elasticsearch.alerting.actions.AlertActionManager;
import org.elasticsearch.alerting.scheduler.AlertScheduler;
import org.elasticsearch.alerting.triggers.AlertTrigger;
import org.elasticsearch.alerting.triggers.TriggerManager;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.Requests;
import org.elasticsearch.common.Nullable;

View File

@ -7,8 +7,8 @@ package org.elasticsearch.alerting;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.alerting.triggers.AlertTrigger;
import org.elasticsearch.common.joda.time.DateTime;
import org.elasticsearch.common.xcontent.XContentBuilder;
import java.util.Arrays;

View File

@ -5,6 +5,10 @@
*/
package org.elasticsearch.alerting;
import org.elasticsearch.alerting.actions.AlertActionManager;
import org.elasticsearch.alerting.rest.AlertRestHandler;
import org.elasticsearch.alerting.scheduler.AlertScheduler;
import org.elasticsearch.alerting.triggers.TriggerManager;
import org.elasticsearch.common.inject.AbstractModule;
public class AlertingModule extends AbstractModule {

View File

@ -3,8 +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.alerting;
package org.elasticsearch.alerting.actions;
import org.elasticsearch.alerting.AlertResult;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;

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.alerting;
package org.elasticsearch.alerting.actions;
public interface AlertActionFactory {
AlertAction createAction(Object parameters);

View File

@ -3,8 +3,15 @@
* 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.alerting;
package org.elasticsearch.alerting.actions;
import org.elasticsearch.alerting.Alert;
import org.elasticsearch.alerting.AlertManager;
import org.elasticsearch.alerting.AlertResult;
import org.elasticsearch.alerting.actions.AlertAction;
import org.elasticsearch.alerting.actions.AlertActionFactory;
import org.elasticsearch.alerting.actions.EmailAlertActionFactory;
import org.elasticsearch.alerting.actions.IndexAlertActionFactory;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.inject.Inject;

View File

@ -3,20 +3,16 @@
* 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.alerting;
package org.elasticsearch.alerting.actions;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.alerting.AlertResult;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHitField;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.AddressException;

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.alerting;
package org.elasticsearch.alerting.actions;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchIllegalArgumentException;
@ -11,7 +11,7 @@ import org.elasticsearch.ElasticsearchIllegalArgumentException;
import java.util.List;
import java.util.Map;
public class EmailAlertActionFactory implements AlertActionFactory{
public class EmailAlertActionFactory implements AlertActionFactory {
@Override
public AlertAction createAction(Object parameters) {

View File

@ -3,10 +3,11 @@
* 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.alerting;
package org.elasticsearch.alerting.actions;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.alerting.AlertResult;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;

View File

@ -3,10 +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.alerting;
package org.elasticsearch.alerting.actions;
import org.elasticsearch.ElasticsearchIllegalArgumentException;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.Client;
import java.util.Locale;

View File

@ -0,0 +1,8 @@
/*
* 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.alerting.actions;

View File

@ -3,9 +3,11 @@
* 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.alerting;
package org.elasticsearch.alerting.rest;
import org.elasticsearch.ElasticsearchIllegalArgumentException;
import org.elasticsearch.alerting.Alert;
import org.elasticsearch.alerting.AlertManager;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;

View File

@ -0,0 +1,8 @@
/*
* 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.alerting.rest;

View File

@ -3,8 +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.alerting;
package org.elasticsearch.alerting.scheduler;
import org.elasticsearch.alerting.scheduler.AlertScheduler;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

View File

@ -3,11 +3,16 @@
* 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.alerting;
package org.elasticsearch.alerting.scheduler;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.alerting.Alert;
import org.elasticsearch.alerting.actions.AlertActionManager;
import org.elasticsearch.alerting.AlertManager;
import org.elasticsearch.alerting.AlertResult;
import org.elasticsearch.alerting.triggers.TriggerManager;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterChangedEvent;
import org.elasticsearch.cluster.ClusterService;
@ -208,7 +213,7 @@ public class AlertScheduler extends AbstractLifecycleComponent implements Cluste
}
public void addAlert(String alertName, Alert alert) {
JobDetail job = JobBuilder.newJob(org.elasticsearch.alerting.AlertExecutorJob.class).withIdentity(alertName).build();
JobDetail job = JobBuilder.newJob(AlertExecutorJob.class).withIdentity(alertName).build();
job.getJobDataMap().put("manager",this);
CronTrigger cronTrigger = TriggerBuilder.newTrigger()
.withSchedule(CronScheduleBuilder.cronSchedule(alert.schedule()))

View File

@ -0,0 +1,8 @@
/*
* 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.alerting.scheduler;

View File

@ -3,9 +3,10 @@
* 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.alerting;
package org.elasticsearch.alerting.triggers;
import org.elasticsearch.ElasticsearchIllegalArgumentException;
import org.elasticsearch.alerting.triggers.ScriptedAlertTrigger;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;

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.alerting;
package org.elasticsearch.alerting.triggers;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.xcontent.ToXContent;

View File

@ -3,11 +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.alerting;
package org.elasticsearch.alerting.triggers;
import org.elasticsearch.ElasticsearchIllegalArgumentException;
import org.elasticsearch.ElasticsearchIllegalStateException;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.alerting.Alert;
import org.elasticsearch.alerting.AlertManager;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;

View File

@ -0,0 +1,8 @@
/*
* 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.alerting.triggers;

View File

@ -6,7 +6,7 @@
package org.elasticsearch.plugin.alerting;
import org.elasticsearch.alerting.AlertManager;
import org.elasticsearch.alerting.AlertScheduler;
import org.elasticsearch.alerting.scheduler.AlertScheduler;
import org.elasticsearch.alerting.AlertingModule;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.component.LifecycleComponent;

View File

@ -5,6 +5,12 @@
*/
package org.elasticsearch.alerting;
import org.elasticsearch.alerting.actions.AlertAction;
import org.elasticsearch.alerting.actions.AlertActionFactory;
import org.elasticsearch.alerting.actions.AlertActionManager;
import org.elasticsearch.alerting.scheduler.AlertScheduler;
import org.elasticsearch.alerting.triggers.AlertTrigger;
import org.elasticsearch.alerting.triggers.ScriptedAlertTrigger;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;