Commit 81fb0a04 authored by Costin Grigoras's avatar Costin Grigoras
Browse files

Call sitesonar at start time, allow it to run for 5 minutes max

parent ceb84ac9
package alien.site;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import alien.config.ConfigUtils;
import alien.monitoring.Monitor;
import alien.monitoring.MonitorFactory;
import utils.ProcessWithTimeout;
/**
* @author sweisz
......@@ -52,6 +56,8 @@ public class JobRunner extends JobAgent {
final int maxRetries = Integer.parseInt(System.getenv().getOrDefault("MAX_RETRIES", "5"));
collectSystemInformation();
while (timestamp < ttlEnd) {
synchronized (JobAgent.requestSync) {
try {
......@@ -62,7 +68,8 @@ public class JobRunner extends JobAgent {
monitor.sendParameter("state", "Waiting for JA to get a job");
monitor.sendParameter("statenumeric", Long.valueOf(1));
i++;
} else {
}
else {
monitor.sendParameter("state", "All slots busy");
monitor.sendParameter("statenumeric", Long.valueOf(3));
logger.log(Level.INFO, "No new thread");
......@@ -70,7 +77,8 @@ public class JobRunner extends JobAgent {
JobAgent.requestSync.wait(5 * 60 * 1000);
} catch (final InterruptedException e) {
}
catch (final InterruptedException e) {
logger.log(Level.WARNING, "JobRunner interrupted", e);
}
......@@ -93,6 +101,28 @@ public class JobRunner extends JobAgent {
System.out.println("JobRunner Exiting");
}
private static final String SITESONAR = "/cvmfs/alice.cern.ch/sitesonar/sitesonar.sh";
private static void collectSystemInformation() {
final File f = new File(SITESONAR);
if (f.exists() && f.canExecute()) {
final ProcessBuilder pBuilder = new ProcessBuilder(SITESONAR);
try {
final Process p = pBuilder.start();
if (p != null) {
final ProcessWithTimeout ptimeout = new ProcessWithTimeout(p, pBuilder);
ptimeout.waitFor(5, TimeUnit.MINUTES);
}
}
catch (@SuppressWarnings("unused") final IOException | InterruptedException e) {
// ignore
}
}
}
public static void main(final String[] args) {
ConfigUtils.setApplicationName("JobRunner");
ConfigUtils.switchToForkProcessLaunching();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment