Commit 8880439a authored by Costin Grigoras's avatar Costin Grigoras
Browse files

SpotBugs found some actual issues in the code

parent f5ca0770
......@@ -171,14 +171,14 @@ public class JobAgent implements Runnable {
* Number of remaining CPU cores to advertise
*/
protected static Long RUNNING_CPU;
/**
* Amount of free disk space in the scratch area to advertise
*/
protected static Long RUNNING_DISK;
/**
* Number of CPU cores assigned to this slot
* Number of CPU cores assigned to this slot
*/
protected static Long MAX_CPU;
......@@ -247,25 +247,28 @@ public class JobAgent implements Runnable {
throwable);
}
});
logger.addHandler(handler);
}
catch (IOException ie) {
logger.log(Level.WARNING, "Problem with getting logger: " + ie.toString());
ie.printStackTrace();
}
logger.addHandler(handler);
final String DN = commander.getUser().getUserCert()[0].getSubjectDN().toString();
logger.log(Level.INFO, "We have the following DN :" + DN);
if (siteMap == null) {
siteMap = (new SiteMap()).getSiteParameters(env);
synchronized (env) {
if (siteMap == null) {
siteMap = (new SiteMap()).getSiteParameters(env);
MAX_CPU = Long.valueOf(((Number) siteMap.getOrDefault("CPUCores", Integer.valueOf(1))).longValue());
RUNNING_CPU = MAX_CPU;
RUNNING_DISK = Long.valueOf(((Number) siteMap.getOrDefault("Disk", Integer.valueOf(10 * 1024))).longValue());
origTtl = ((Integer) siteMap.get("TTL")).intValue();
RUNNING_JOBAGENTS = 0;
MAX_CPU = Long.valueOf(((Number) siteMap.getOrDefault("CPUCores", Integer.valueOf(1))).longValue());
RUNNING_CPU = MAX_CPU;
RUNNING_DISK = Long.valueOf(((Number) siteMap.getOrDefault("Disk", Integer.valueOf(10 * 1024))).longValue());
origTtl = ((Integer) siteMap.get("TTL")).intValue();
RUNNING_JOBAGENTS = 0;
}
}
hostName = (String) siteMap.get("Localhost");
......@@ -332,7 +335,7 @@ public class JobAgent implements Runnable {
matchedJob = jobMatch.getMatchJob();
// TODELETE
if (matchedJob.containsKey("Error") || matchedJob == null) {
if (matchedJob == null || matchedJob.containsKey("Error")) {
logger.log(Level.INFO,
"We didn't get anything back. Nothing to run right now.");
RUNNING_JOBAGENTS -= 1;
......
......@@ -795,14 +795,16 @@ public class TaskQueueUtils {
}
// lazy initialization of the ML service collecting job transitions
if (centralMLService == null) {
final Vector<String> targets = new Vector<>();
try {
targets.add(ConfigUtils.getConfig().gets("CS_ApMon", "aliendb4.cern.ch"));
centralMLService = new ApMon(targets);
}
catch (final Exception e) {
logger.log(Level.WARNING, "Could not initialize apmon (" + targets + ")", e);
synchronized (fieldMap) {
if (centralMLService == null) {
final Vector<String> targets = new Vector<>();
try {
targets.add(ConfigUtils.getConfig().gets("CS_ApMon", "aliendb4.cern.ch"));
centralMLService = new ApMon(targets);
}
catch (final Exception e) {
logger.log(Level.WARNING, "Could not initialize apmon (" + targets + ")", e);
}
}
}
......
......@@ -799,7 +799,7 @@ public class JAKeyStore {
new File(tokencertpath).delete();
new File(tokenkeypath).delete();
try ( // Open files for writing
PrintWriter pwritercert = new PrintWriter(new File(tokencertpath));
PrintWriter pwriterkey = new PrintWriter(new File(tokenkeypath))) {
......@@ -824,16 +824,20 @@ public class JAKeyStore {
* @return <code>true</code> if the requested certificate has been successfully loaded
*/
public static boolean isLoaded(final String ksName) {
KeyStore ks = null;
final KeyStore ks;
if (ksName == "user") {
ks = clientCert;
}
else if (ksName == "host") {
ks = hostCert;
}
else if (ksName == "token") {
ks = tokenCert;
switch (ksName) {
case "user":
ks = clientCert;
break;
case "host":
ks = hostCert;
break;
case "token":
ks = tokenCert;
break;
default:
ks = null;
}
return isLoaded(ks);
......
......@@ -171,10 +171,11 @@ public class WebsocketEndpoint extends Endpoint {
sessionCheckingThread.setDaemon(true);
sessionCheckingThread.start();
monitor.addMonitoring("sessions", (names, values) -> {
names.add("active_sessions");
values.add(Double.valueOf(sessionQueue.size()));
});
if (monitor != null)
monitor.addMonitoring("sessions", (names, values) -> {
names.add("active_sessions");
values.add(Double.valueOf(sessionQueue.size()));
});
}
/**
......
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