Skip to content

Commit 7ce4a9d

Browse files
authored
Merge pull request #3186 from jeonghanlee/alarm-logger-standalone
Support the Standalone Alarm Logging service
2 parents 30cc0f5 + 17d7564 commit 7ce4a9d

File tree

3 files changed

+46
-15
lines changed

3 files changed

+46
-15
lines changed

services/alarm-logger/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# Alarm Logging
1+
# Alarm Logging Service
22

3-
Logging alarm state and other messages to an elastic back end.
3+
The alarm logging service (aka alarm-logger) records all alarm messages to create an archive of all alarm state changes and the associated actions.
4+
This is an elasticsearch back end.
45

56
## Dependencies ##
67
1. Elasticsearch version 8.x OS specific release can be found here:
@@ -48,6 +49,11 @@ mvn spring-boot:run
4849
Run with `-help` to see command line options,
4950
including those used to create daily, weekly or monthly indices.
5051

52+
#### Standalone mode
53+
54+
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.
55+
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.
56+
5157
#### Configuration
5258

5359
The alarm logger can be configured via command line switches when running the jar, see option `-help` for details,

services/alarm-logger/src/main/java/org/phoebus/alarm/logging/AlarmLoggingService.java

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ private static void help()
6262
System.out.println("-properties /opt/alarm_logger.properties - Properties file to be used (instead of command line arguments)");
6363
System.out.println("-date_span_units M - Date units for the time based index to span.");
6464
System.out.println("-date_span_value 1 - Date value for the time based index to span.");
65+
System.out.println("-standalone false - Standalone Alarm Logger Service without Alarm (Kafka) Server");
6566
System.out.println("-logging logging.properties - Load log settings");
6667
System.out.println();
6768
}
@@ -210,6 +211,14 @@ else if (cmd.equals("-date_span_value"))
210211
properties.put("date_span_value",iter.next());
211212
iter.remove();
212213
}
214+
else if (cmd.equals("-standalone"))
215+
{
216+
if (!iter.hasNext())
217+
throw new Exception("Missing -standalone false or true");
218+
iter.remove();
219+
properties.put("standalone",iter.next());
220+
iter.remove();
221+
}
213222
else if (cmd.equals("-logging"))
214223
{
215224
if (! iter.hasNext())
@@ -265,18 +274,29 @@ else if(cmd.equals("-thread_pool_size")){
265274
final List<String> topicNames = Arrays.asList(properties.getProperty("alarm_topics").split(","));
266275
logger.info("Starting logger for '..State': " + topicNames);
267276

268-
// Start a new stream consumer for each topic
269-
topicNames.forEach(topic -> {
270-
try
271-
{
272-
Scheduler.execute(new AlarmMessageLogger(topic));
273-
Scheduler.execute(new AlarmCmdLogger(topic));
274-
}
275-
catch (Exception ex)
276-
{
277-
logger.log(Level.SEVERE, "Creation of alarm logging service for '" + topic + "' failed", ex);
278-
}
279-
});
277+
final boolean standalone = Boolean.valueOf(properties.getProperty("standalone"));
278+
279+
// If the standalone is true, ignore the Schedulers for AlarmMessageLogger and AlarmCmdLogger
280+
// otherwise run the Alarm Logger service as is.
281+
if(standalone == true)
282+
{
283+
logger.info("We are in the Standalone Alarm Logger Service.");
284+
}
285+
else
286+
{
287+
// Start a new stream consumer for each topic
288+
topicNames.forEach(topic -> {
289+
try
290+
{
291+
Scheduler.execute(new AlarmMessageLogger(topic));
292+
Scheduler.execute(new AlarmCmdLogger(topic));
293+
}
294+
catch (Exception ex)
295+
{
296+
logger.log(Level.SEVERE, "Creation of alarm logging service for '" + topic + "' failed", ex);
297+
}
298+
});
299+
}
280300

281301
// Wait in command shell until closed
282302
if(use_shell)
@@ -291,7 +311,9 @@ else if(cmd.equals("-thread_pool_size")){
291311
Thread.currentThread().join();
292312
}
293313

294-
close();
314+
if(standalone == false){
315+
close();
316+
}
295317
System.exit(0);
296318
}
297319

services/alarm-logger/src/main/resources/application.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ date_span_units=M
5151
# Size of the thread pool for message and command loggers. Two threads per topic/configuration are required
5252
thread_pool_size=4
5353

54+
# Standalone - Alarm Logger Service
55+
standalone=false
56+
5457
############################## REST Logging ###############################
5558
# DEBUG level will log all requests and responses to and from the REST end points
5659
logging.level.org.springframework.web.filter.CommonsRequestLoggingFilter=INFO

0 commit comments

Comments
 (0)