Add option to keep test component alive

Unless started with `--no-keepalive`, the locally-running solver will
listen to messages from utility-evaluator and solver instead of
terminating after initial deployment.

Change-Id: Iacb1dd10c0212d8075903389d4cd60b6ec079047
This commit is contained in:
Rudi Schlatte 2024-04-22 10:44:42 +02:00
parent 6e9d2d771f
commit 46f7c07c8f

View File

@ -41,6 +41,12 @@ public class LocalExecution implements Callable<Integer> {
negatable = true) negatable = true)
private boolean deploy; private boolean deploy;
@Option(names = { "--keepalive"},
description = "Stay alive and process messages from other components after initial deployment (default true).",
defaultValue = "true", fallbackValue = "true",
negatable = true)
private boolean keepalive;
@Override public Integer call() { @Override public Integer call() {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
CountDownLatch exn_synchronizer = new CountDownLatch(1); CountDownLatch exn_synchronizer = new CountDownLatch(1);
@ -77,6 +83,13 @@ public class LocalExecution implements Callable<Integer> {
} }
} }
if (connector != null) { if (connector != null) {
if (keepalive) {
try {
exn_synchronizer.await();
} catch (InterruptedException e) {
// ignore
}
}
connector.stop(); connector.stop();
} }
return 0; return 0;