More changes for configuration manager and email action renaming.

Original commit: elastic/x-pack-elasticsearch@1c5087e79a
This commit is contained in:
Brian Murphy 2014-12-05 11:46:23 +00:00
parent d8b751f6ed
commit 920f7ea2a9
2 changed files with 14 additions and 11 deletions

View File

@ -30,9 +30,12 @@ public class ConfigurationManager extends AbstractComponent {
public static final String CONFIG_TYPE = "config";
public static final String CONFIG_INDEX = AlertsStore.ALERT_INDEX;
public static final String GLOBAL_CONFIG_NAME = "global";
private volatile boolean readyToRead = false;
private final CopyOnWriteArrayList<ConfigurableComponentListener> registeredComponents;
private volatile boolean readyToRead = false;
@Inject
public ConfigurationManager(Settings settings, Client client) {
super(settings);
@ -95,6 +98,15 @@ public class ConfigurationManager extends AbstractComponent {
}
}
/**
* Registers an component to receive config updates
*/
public void registerListener(ConfigurableComponentListener configListener) {
if (!registeredComponents.contains(configListener)) {
registeredComponents.add(configListener);
}
}
private void ensureReady() {
if (!readyToRead) {
throw new ElasticsearchException("Config index [" + CONFIG_INDEX + "] is not known to be started");
@ -116,13 +128,4 @@ public class ConfigurationManager extends AbstractComponent {
}
}
}
/**
* Registers an component to receive config updates
*/
public void registerListener(ConfigurableComponentListener configListener) {
if (!registeredComponents.contains(configListener)) {
registeredComponents.add(configListener);
}
}
}

View File

@ -28,7 +28,7 @@ public class AlertActionRegistry extends AbstractComponent {
public AlertActionRegistry(Settings settings, Client client, ConfigurationManager configurationManager) {
super(settings);
actionImplemented = ImmutableOpenMap.<String, AlertActionFactory>builder()
.fPut("email", new SnptAlertActionFactory(configurationManager))
.fPut("email", new SmtpAlertActionFactory(configurationManager))
.fPut("index", new IndexAlertActionFactory(client, configurationManager))
.build();
}