in xtable-utilities/src/main/java/org/apache/xtable/utilities/RunSync.java [240:284]
public static void main(String[] args) throws IOException {
CommandLineParser parser = new DefaultParser();
CommandLine cmd;
try {
cmd = parser.parse(OPTIONS, args);
} catch (ParseException e) {
new HelpFormatter().printHelp("xtable.jar", OPTIONS, true);
return;
}
if (cmd.hasOption(HELP_OPTION)) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("RunSync", OPTIONS);
return;
}
if (cmd.hasOption(CONTINUOUS_MODE)) {
ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
long intervalInSeconds = Long.parseLong(cmd.getOptionValue(CONTINUOUS_MODE_INTERVAL, "5"));
executorService.scheduleAtFixedRate(
() -> {
try {
runSync(cmd);
} catch (IOException ex) {
log.error("Sync operation failed", ex);
}
},
0,
intervalInSeconds,
TimeUnit.SECONDS);
while (!Thread.currentThread().isInterrupted()) {
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
log.debug("Received interrupt signal");
Thread.currentThread().interrupt();
break;
}
}
executorService.shutdownNow();
} else {
runSync(cmd);
}
}