|
38 | 38 | import org.elasticsearch.node.Node;
|
39 | 39 | import org.elasticsearch.plugins.ActionPlugin;
|
40 | 40 | import org.elasticsearch.plugins.Plugin;
|
| 41 | +import org.elasticsearch.plugins.ReloadablePlugin; |
41 | 42 | import org.elasticsearch.plugins.ScriptPlugin;
|
42 | 43 | import org.elasticsearch.rest.RestController;
|
43 | 44 | import org.elasticsearch.rest.RestHandler;
|
|
123 | 124 | import org.elasticsearch.xpack.watcher.input.simple.SimpleInputFactory;
|
124 | 125 | import org.elasticsearch.xpack.watcher.input.transform.TransformInput;
|
125 | 126 | import org.elasticsearch.xpack.watcher.input.transform.TransformInputFactory;
|
| 127 | +import org.elasticsearch.xpack.watcher.notification.NotificationService; |
126 | 128 | import org.elasticsearch.xpack.watcher.notification.email.Account;
|
127 | 129 | import org.elasticsearch.xpack.watcher.notification.email.EmailService;
|
128 | 130 | import org.elasticsearch.xpack.watcher.notification.email.HtmlSanitizer;
|
|
197 | 199 |
|
198 | 200 | import static java.util.Collections.emptyList;
|
199 | 201 |
|
200 |
| -public class Watcher extends Plugin implements ActionPlugin, ScriptPlugin { |
| 202 | +public class Watcher extends Plugin implements ActionPlugin, ScriptPlugin, ReloadablePlugin { |
201 | 203 |
|
202 | 204 | // This setting is only here for backward compatibility reasons as 6.x indices made use of it. It can be removed in 8.x.
|
203 | 205 | @Deprecated
|
@@ -240,6 +242,7 @@ public class Watcher extends Plugin implements ActionPlugin, ScriptPlugin {
|
240 | 242 | protected final boolean transportClient;
|
241 | 243 | protected final boolean enabled;
|
242 | 244 | protected final Environment env;
|
| 245 | + protected List<NotificationService> reloadableServices = new ArrayList<>(); |
243 | 246 |
|
244 | 247 | public Watcher(Settings settings) {
|
245 | 248 | this.settings = settings;
|
@@ -294,6 +297,12 @@ public Collection<Object> createComponents(Client client, ClusterService cluster
|
294 | 297 | SlackService slackService = new SlackService(settings, httpClient, clusterService.getClusterSettings());
|
295 | 298 | PagerDutyService pagerDutyService = new PagerDutyService(settings, httpClient, clusterService.getClusterSettings());
|
296 | 299 |
|
| 300 | + reloadableServices.add(emailService); |
| 301 | + reloadableServices.add(hipChatService); |
| 302 | + reloadableServices.add(jiraService); |
| 303 | + reloadableServices.add(slackService); |
| 304 | + reloadableServices.add(pagerDutyService); |
| 305 | + |
297 | 306 | TextTemplateEngine templateEngine = new TextTemplateEngine(settings, scriptService);
|
298 | 307 | Map<String, EmailAttachmentParser> emailAttachmentParsers = new HashMap<>();
|
299 | 308 | emailAttachmentParsers.put(HttpEmailAttachementParser.TYPE, new HttpEmailAttachementParser(httpClient, httpTemplateParser,
|
@@ -635,4 +644,15 @@ public List<ScriptContext> getContexts() {
|
635 | 644 | public void close() throws IOException {
|
636 | 645 | IOUtils.closeWhileHandlingException(httpClient);
|
637 | 646 | }
|
| 647 | + |
| 648 | + /** |
| 649 | + * Reloads all the reloadable services in watcher. |
| 650 | + */ |
| 651 | + @Override |
| 652 | + public void reload(Settings settings) { |
| 653 | + if (enabled == false || transportClient) { |
| 654 | + return; |
| 655 | + } |
| 656 | + reloadableServices.forEach(s -> s.reload(settings)); |
| 657 | + } |
638 | 658 | }
|
0 commit comments