Skip to content

Commit

Permalink
Merge pull request #2597 from lcaouen/AlarmServerExportStabilization
Browse files Browse the repository at this point in the history
 services-alarm-server : increase STABILIZATION_SECS when exporting #2596
  • Loading branch information
kasemir authored Mar 17, 2023
2 parents 5a03004 + 7bb48ba commit 5d57d5f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@
public class AlarmConfigTool
{
/** Time the model must be stable for. Unit is seconds. Default is 4 seconds. */
private static final long STABILIZATION_SECS = 4;
private long STABILIZATION_SECS = 4;

// Export an alarm system model to an xml file.
public void exportModel(String filename, String server, String config, String kafka_properties_file) throws Exception
public void exportModel(String filename, String server, String config, String kafka_properties_file, long wait) throws Exception
{
final XmlModelWriter xmlWriter;

if (wait > STABILIZATION_SECS) STABILIZATION_SECS = wait;

// Write to stdout or to file.
if (filename.equals("stdout"))
xmlWriter = new XmlModelWriter(System.out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ public static void main(final String[] original_args) throws Exception
String settings_arg = "-settings";
String noshell_arg = "-noshell";
String export_arg = "-export";
String export_wait_arg = "-export_wait";
String import_arg = "-import";
String logging_arg = "-logging";
String kafka_props_arg = "-kafka_properties";
Expand All @@ -580,6 +581,7 @@ public static void main(final String[] original_args) throws Exception
config_arg,
settings_arg,
export_arg,
export_wait_arg,
import_arg,
logging_arg,
kafka_props_arg);
Expand All @@ -596,6 +598,7 @@ public static void main(final String[] original_args) throws Exception
Map<String, String> args_to_prefs = Map.ofEntries(
Map.entry(config_arg, "config_names"),
Map.entry(server_arg, "server"),
Map.entry(export_wait_arg, "export_wait"),
Map.entry(kafka_props_arg, "kafka_properties")
);

Expand Down Expand Up @@ -658,8 +661,11 @@ else if (Set.of(userPrefs.keys()).contains(prefKey)){
}
if (parsed_args.containsKey(export_arg)){
final String filename = parsed_args.get(export_arg);
final String waitArg = parsed_args.get(export_wait_arg);
final long wait = (waitArg != null && !waitArg.equals("")) ? Long.parseLong(waitArg) : 0;
logger.info("Exporting model to " + filename);
new AlarmConfigTool().exportModel(filename, server, config, kafka_properties);
logger.info("wait " + wait);
new AlarmConfigTool().exportModel(filename, server, config, kafka_properties, wait);
}
if (parsed_args.containsKey(import_arg)){
final String filename = parsed_args.get(import_arg);
Expand Down

0 comments on commit 5d57d5f

Please sign in to comment.