@@ -229,6 +229,7 @@ public class Watcher extends Plugin implements ActionPlugin, ScriptPlugin, Reloa
229
229
private SetOnce <JiraService > jiraService = new SetOnce <>();
230
230
private SetOnce <SlackService > slackService = new SetOnce <>();
231
231
private SetOnce <PagerDutyService > pagerDutyService = new SetOnce <>();
232
+ List <NotificationService > reloadableServices = new ArrayList <>();
232
233
233
234
public Watcher (final Settings settings ) {
234
235
this .settings = settings ;
@@ -278,10 +279,16 @@ public Collection<Object> createComponents(Client client, ClusterService cluster
278
279
279
280
// notification
280
281
emailService .set (new EmailService (settings , cryptoService , clusterService .getClusterSettings ()));
282
+ reloadableServices .add (emailService .get ());
281
283
hipChatService .set (new HipChatService (settings , httpClient , clusterService .getClusterSettings ()));
284
+ reloadableServices .add (hipChatService .get ());
282
285
jiraService .set (new JiraService (settings , httpClient , clusterService .getClusterSettings ()));
286
+ reloadableServices .add (jiraService .get ());
283
287
slackService .set (new SlackService (settings , httpClient , clusterService .getClusterSettings ()));
288
+ reloadableServices .add (slackService .get ());
284
289
pagerDutyService .set (new PagerDutyService (settings , httpClient , clusterService .getClusterSettings ()));
290
+ reloadableServices .add (pagerDutyService .get ());
291
+
285
292
286
293
TextTemplateEngine templateEngine = new TextTemplateEngine (settings , scriptService );
287
294
Map <String , EmailAttachmentParser > emailAttachmentParsers = new HashMap <>();
@@ -624,18 +631,6 @@ public void close() throws IOException {
624
631
IOUtils .closeWhileHandlingException (httpClient );
625
632
}
626
633
627
- /**
628
- * Used to detect which {@link NotificationService} get reloaded. Also useful for testing the reload in tests.
629
- * @return
630
- */
631
- protected List <NotificationService > getReloadableServices () {
632
- return Arrays .asList (
633
- emailService .get (),
634
- hipChatService .get (),
635
- jiraService .get (),
636
- slackService .get (),
637
- pagerDutyService .get ());
638
- }
639
634
640
635
/**
641
636
* Reloads all reloadable services' settings.
@@ -648,7 +643,7 @@ protected List<NotificationService> getReloadableServices() {
648
643
*/
649
644
@ Override
650
645
public void reload (Settings settings ) throws Exception {
651
- for (NotificationService service : getReloadableServices () ) {
646
+ for (NotificationService service : reloadableServices ) {
652
647
service .reload (settings );
653
648
}
654
649
}
0 commit comments