From 734d3f2c78eb8bf988e7bb3107dc7fbcf8f18cab Mon Sep 17 00:00:00 2001 From: "Lee, Jeong Han" Date: Mon, 11 Nov 2024 12:11:41 -0800 Subject: [PATCH 1/4] add standalone option to the application.properties --- .../alarm/logging/AlarmLoggingService.java | 48 ++++++++++++++----- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/services/alarm-logger/src/main/java/org/phoebus/alarm/logging/AlarmLoggingService.java b/services/alarm-logger/src/main/java/org/phoebus/alarm/logging/AlarmLoggingService.java index d35c03076a..bcc161acd4 100644 --- a/services/alarm-logger/src/main/java/org/phoebus/alarm/logging/AlarmLoggingService.java +++ b/services/alarm-logger/src/main/java/org/phoebus/alarm/logging/AlarmLoggingService.java @@ -62,6 +62,7 @@ private static void help() System.out.println("-properties /opt/alarm_logger.properties - Properties file to be used (instead of command line arguments)"); System.out.println("-date_span_units M - Date units for the time based index to span."); System.out.println("-date_span_value 1 - Date value for the time based index to span."); + System.out.println("-standalone false - Standalone Alarm Logger Service without Alarm (Kafka) Server"); System.out.println("-logging logging.properties - Load log settings"); System.out.println(); } @@ -210,6 +211,14 @@ else if (cmd.equals("-date_span_value")) properties.put("date_span_value",iter.next()); iter.remove(); } + else if (cmd.equals("-standalone")) + { + if (!iter.hasNext()) + throw new Exception("Missing -standalone false or true"); + iter.remove(); + properties.put("standalone",iter.next()); + iter.remove(); + } else if (cmd.equals("-logging")) { if (! iter.hasNext()) @@ -265,18 +274,29 @@ else if(cmd.equals("-thread_pool_size")){ final List topicNames = Arrays.asList(properties.getProperty("alarm_topics").split(",")); logger.info("Starting logger for '..State': " + topicNames); - // Start a new stream consumer for each topic - topicNames.forEach(topic -> { - try - { - Scheduler.execute(new AlarmMessageLogger(topic)); - Scheduler.execute(new AlarmCmdLogger(topic)); - } - catch (Exception ex) - { - logger.log(Level.SEVERE, "Creation of alarm logging service for '" + topic + "' failed", ex); - } - }); + final boolean standalone = Boolean.valueOf(properties.gerProperty("standalone")); + + // If the standalone is true, ignore the Schedulers for AlarmMessageLogger and AlarmCmdLogger + // otherwise run the Alarm Logger service as is. + if(standalone == true) + { + logger.info("We are in the Standalone Alarm Logger Service."); + } + else + { + // Start a new stream consumer for each topic + topicNames.forEach(topic -> { + try + { + Scheduler.execute(new AlarmMessageLogger(topic)); + Scheduler.execute(new AlarmCmdLogger(topic)); + } + catch (Exception ex) + { + logger.log(Level.SEVERE, "Creation of alarm logging service for '" + topic + "' failed", ex); + } + }); + } // Wait in command shell until closed if(use_shell) @@ -291,7 +311,9 @@ else if(cmd.equals("-thread_pool_size")){ Thread.currentThread().join(); } - close(); + if(standalone == false){ + close(); + } System.exit(0); } From b5f2e66cb8a7570a7affef59a8b57bb9195ef733 Mon Sep 17 00:00:00 2001 From: "Lee, Jeong Han" Date: Mon, 11 Nov 2024 12:11:48 -0800 Subject: [PATCH 2/4] add standalone option to the application.properties --- .../alarm-logger/src/main/resources/application.properties | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/alarm-logger/src/main/resources/application.properties b/services/alarm-logger/src/main/resources/application.properties index 6993a94bc7..c95a000dfa 100644 --- a/services/alarm-logger/src/main/resources/application.properties +++ b/services/alarm-logger/src/main/resources/application.properties @@ -51,6 +51,9 @@ date_span_units=M # Size of the thread pool for message and command loggers. Two threads per topic/configuration are required thread_pool_size=4 +# Standalone - Alarm Logger Service +standalone=false + ############################## REST Logging ############################### # DEBUG level will log all requests and responses to and from the REST end points logging.level.org.springframework.web.filter.CommonsRequestLoggingFilter=INFO From 944523592496bb2f97be87096df1ac829b7b5219 Mon Sep 17 00:00:00 2001 From: "Lee, Jeong Han" Date: Mon, 11 Nov 2024 14:29:50 -0800 Subject: [PATCH 3/4] fixed a typo for get property function name --- .../java/org/phoebus/alarm/logging/AlarmLoggingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/alarm-logger/src/main/java/org/phoebus/alarm/logging/AlarmLoggingService.java b/services/alarm-logger/src/main/java/org/phoebus/alarm/logging/AlarmLoggingService.java index bcc161acd4..a10f8ad8c0 100644 --- a/services/alarm-logger/src/main/java/org/phoebus/alarm/logging/AlarmLoggingService.java +++ b/services/alarm-logger/src/main/java/org/phoebus/alarm/logging/AlarmLoggingService.java @@ -274,7 +274,7 @@ else if(cmd.equals("-thread_pool_size")){ final List topicNames = Arrays.asList(properties.getProperty("alarm_topics").split(",")); logger.info("Starting logger for '..State': " + topicNames); - final boolean standalone = Boolean.valueOf(properties.gerProperty("standalone")); + final boolean standalone = Boolean.valueOf(properties.getProperty("standalone")); // If the standalone is true, ignore the Schedulers for AlarmMessageLogger and AlarmCmdLogger // otherwise run the Alarm Logger service as is. From 17d7564b2ab9982d1de5d7c8d4c8f8336cc07984 Mon Sep 17 00:00:00 2001 From: "Lee, Jeong Han" Date: Mon, 11 Nov 2024 14:49:00 -0800 Subject: [PATCH 4/4] update README for alarm logging service --- services/alarm-logger/README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/services/alarm-logger/README.md b/services/alarm-logger/README.md index dccd801092..d9a8b205e4 100644 --- a/services/alarm-logger/README.md +++ b/services/alarm-logger/README.md @@ -1,6 +1,7 @@ -# Alarm Logging +# Alarm Logging Service -Logging alarm state and other messages to an elastic back end. +The alarm logging service (aka alarm-logger) records all alarm messages to create an archive of all alarm state changes and the associated actions. +This is an elasticsearch back end. ## Dependencies ## 1. Elasticsearch version 8.x OS specific release can be found here: @@ -48,6 +49,11 @@ mvn spring-boot:run Run with `-help` to see command line options, including those used to create daily, weekly or monthly indices. +#### Standalone mode + +With the `-standalone true` option on the command line or in `application.properties`, you can run the alarm logging service independently of an alarm server. +It may be useful to troubleshoot the system independently from production alarm services using the alarm log service backup for the long alarm log history. + #### Configuration The alarm logger can be configured via command line switches when running the jar, see option `-help` for details,