Commit bcb0d64b authored by Costin Grigoras's avatar Costin Grigoras
Browse files

Avoid a double allocation of the same array content

parent c0afb68d
......@@ -271,7 +271,7 @@ public class ARC extends BatchQueue {
final String proxy_info_cmd = "voms-proxy-info -acsubject -actimeleft 2>&1";
ExitStatus exitStatus = executeCommand(proxy_info_cmd);
final ArrayList<String> proxy_info_output = getStdOut(exitStatus);
final List<String> proxy_info_output = getStdOut(exitStatus);
String dn_str = "";
String time_left_str = "";
......@@ -310,7 +310,7 @@ public class ARC extends BatchQueue {
logger.info("Checking proxy renewal service");
final String proxy_renewal_cmd = String.format("%s start 2>&1", proxy_renewal_svc);
ArrayList<String> proxy_renewal_output = null;
List<String> proxy_renewal_output = null;
try {
exitStatus = executeCommand(proxy_renewal_cmd);
......@@ -431,7 +431,7 @@ public class ARC extends BatchQueue {
}
ExitStatus exitStatus = executeCommand(submit_cmd.toString());
final ArrayList<String> output = getStdOut(exitStatus);
final List<String> output = getStdOut(exitStatus);
if (logger.isLoggable(Level.INFO)) {
for (final String line : output) {
......@@ -663,11 +663,11 @@ public class ARC extends BatchQueue {
final String f = prefix + suffix;
final String cmd = String.format("test ! -e %s || mv %s %s.%d", f, f, f, Integer.valueOf(cDay));
ExitStatus exitStatus = executeCommand(cmd);
final ArrayList<String> output = getStdOut(exitStatus);
final List<String> output = getStdOut(exitStatus);
for (final String line : output) {
logger.info(line);
}
if (logger.isLoggable(Level.INFO))
for (final String line : output)
logger.info(line);
}
}
......
......@@ -3,6 +3,7 @@ package alien.site.batchqueue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -127,12 +128,12 @@ public abstract class BatchQueue {
}
static ArrayList<String> getStdOut(ExitStatus exitStatus) {
return new ArrayList<String>(Arrays.asList(exitStatus.getStdOut().split("\n")).stream().map(String::trim).collect(Collectors.toList()));
static List<String> getStdOut(ExitStatus exitStatus) {
return Arrays.asList(exitStatus.getStdOut().split("\n")).stream().map(String::trim).collect(Collectors.toList());
}
static ArrayList<String> getStdErr(ExitStatus exitStatus) {
return new ArrayList<String>(Arrays.asList(exitStatus.getStdOut().split("\n")).stream().map(String::trim).collect(Collectors.toList()));
static List<String> getStdErr(ExitStatus exitStatus) {
return Arrays.asList(exitStatus.getStdOut().split("\n")).stream().map(String::trim).collect(Collectors.toList());
}
/**
......
......@@ -10,6 +10,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicInteger;
......@@ -262,7 +263,7 @@ public class HTCONDOR extends BatchQueue {
final String proxy_info_cmd = "voms-proxy-info -acsubject -actimeleft 2>&1";
ExitStatus exitStatus = executeCommand(proxy_info_cmd);
final ArrayList<String> proxy_info_output = getStdOut(exitStatus);
final List<String> proxy_info_output = getStdOut(exitStatus);
String dn_str = "";
String time_left_str = "";
......@@ -301,7 +302,7 @@ public class HTCONDOR extends BatchQueue {
logger.info("Checking proxy renewal service");
final String proxy_renewal_cmd = String.format("%s start 2>&1", proxy_renewal_svc);
ArrayList<String> proxy_renewal_output = null;
List<String> proxy_renewal_output = null;
try {
exitStatus = executeCommand(proxy_renewal_cmd);
......@@ -360,8 +361,7 @@ public class HTCONDOR extends BatchQueue {
err_cmd = String.format("error = %s.err\n", file_base_name);
}
String per_hold_grid = (local_pool != null) ? "" :
"(JobStatus == 1 && GridJobStatus =?= undefined && CurrentTime - EnteredCurrentStatus > 1800) || ";
String per_hold_grid = (local_pool != null) ? "" : "(JobStatus == 1 && GridJobStatus =?= undefined && CurrentTime - EnteredCurrentStatus > 1800) || ";
String submit_jdl = "cmd = " + script + "\n" +
out_cmd +
......@@ -471,7 +471,7 @@ public class HTCONDOR extends BatchQueue {
final String submit_cmd = submitCmd + " " + submitArgs + " " + submit_file;
final ExitStatus exitStatus = executeCommand(submit_cmd);
final ArrayList<String> output = getStdOut(exitStatus);
final List<String> output = getStdOut(exitStatus);
for (final String line : output) {
final String trimmed_line = line.trim();
......@@ -533,7 +533,7 @@ public class HTCONDOR extends BatchQueue {
//
tot_running = 0;
tot_waiting = 444444; // the traditional safe default...
tot_waiting = 444444; // the traditional safe default...
// in case the CE list has changed
running.clear();
......@@ -567,7 +567,7 @@ public class HTCONDOR extends BatchQueue {
return false;
}
final ArrayList<String> job_list = getStdOut(exitStatus);
final List<String> job_list = getStdOut(exitStatus);
if (exitStatus.getExecutorFinishStatus() != ExecutorFinishStatus.NORMAL) {
logger.warning(String.format("[LCG] Abnormal exit status for command: %s", cmd));
......@@ -575,9 +575,9 @@ public class HTCONDOR extends BatchQueue {
int i = 1;
for (final String line : job_list) {
logger.warning(String.format("[LCG] Line %2d: %s", i, line));
logger.warning(String.format("[LCG] Line %2d: %s", Integer.valueOf(i), line));
if (i++ > 10) {
logger.warning(String.format("[LCG] [...]"));
logger.warning("[LCG] [...]");
break;
}
}
......@@ -585,7 +585,7 @@ public class HTCONDOR extends BatchQueue {
return false;
}
tot_waiting = 0; // start calculating the real number...
tot_waiting = 0; // start calculating the real number...
for (final String line : job_list) {
final Matcher m = pJobNumbers.matcher(line);
......
......@@ -9,7 +9,6 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -20,9 +19,8 @@ import java.util.logging.Logger;
import alien.site.Functions;
import lazyj.Utils;
import lia.util.process.ExternalProcess.ExitStatus;
import lia.util.process.ExternalProcess.ExecutorFinishStatus;
import lia.util.process.ExternalProcess.ExitStatus;
/**
*
......@@ -247,7 +245,7 @@ public class SLURM extends BatchQueue {
final String cmd = "cat " + this.temp_file.getAbsolutePath() + " | " + this.submitCmd + " " + this.submitArgs;
final ExitStatus exitStatus = executeCommand(cmd);
final ArrayList<String> output = getStdOut(exitStatus);
final List<String> output = getStdOut(exitStatus);
for (final String line : output) {
final String trimmed_line = line.trim();
this.logger.info(trimmed_line);
......@@ -261,7 +259,7 @@ public class SLURM extends BatchQueue {
public int getNumberActive() {
final String status = "R,S,CG";
final ExitStatus exitStatus = executeCommand(statusCmd + " -t " + status + " " + statusArgs);
final ArrayList<String> output_list = getStdOut(exitStatus);
final List<String> output_list = getStdOut(exitStatus);
if (exitStatus.getExecutorFinishStatus() != ExecutorFinishStatus.NORMAL)
return -1;
......@@ -276,7 +274,7 @@ public class SLURM extends BatchQueue {
public int getNumberQueued() {
final String status = "PD,CF";
final ExitStatus exitStatus = executeCommand(statusCmd + " -t " + status + " " + statusArgs);
final ArrayList<String> output_list = getStdOut(exitStatus);
final List<String> output_list = getStdOut(exitStatus);
if (exitStatus.getExecutorFinishStatus() != ExecutorFinishStatus.NORMAL)
return -1;
......@@ -287,7 +285,7 @@ public class SLURM extends BatchQueue {
@Override
public int kill() {
final ExitStatus exitStatus;
ArrayList<String> kill_cmd_output = null;
List<String> kill_cmd_output = null;
try {
exitStatus = executeCommand(this.killCmd);
kill_cmd_output = getStdOut(exitStatus);
......
Markdown is supported
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