diff --git a/src/main/java/org/yardstickframework/BenchmarkConfiguration.java b/src/main/java/org/yardstickframework/BenchmarkConfiguration.java index e0e4a15..3416897 100644 --- a/src/main/java/org/yardstickframework/BenchmarkConfiguration.java +++ b/src/main/java/org/yardstickframework/BenchmarkConfiguration.java @@ -17,6 +17,7 @@ import com.beust.jcommander.Parameter; import java.io.PrintStream; import java.io.Serializable; +import java.nio.file.Paths; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -32,7 +33,7 @@ public class BenchmarkConfiguration implements Serializable { /** */ @Parameter(names = {"-cfg", "--config"}, description = "Framework configuration file path") - private String propsFileName = "config/benchmark.properties"; + private String propsFileName = Paths.get("config", "benchmark.properties").toString(); /** For internal use. Should not be used in configs. */ @Parameter(names = {"--logsFolder"}, description = "Logs directory") diff --git a/src/main/java/org/yardstickframework/BenchmarkUtils.java b/src/main/java/org/yardstickframework/BenchmarkUtils.java index 2f316fc..312dac1 100644 --- a/src/main/java/org/yardstickframework/BenchmarkUtils.java +++ b/src/main/java/org/yardstickframework/BenchmarkUtils.java @@ -22,6 +22,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; +import java.nio.file.Paths; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -44,13 +45,16 @@ public class BenchmarkUtils { public static final String WEIGHT_DELIMITER = ":"; /** Indicates whether current OS is Windows. */ - private static boolean isWin; + private static final boolean isWin; + + private static final String javaExecutable; /** * Initializes statics. */ static { isWin = System.getProperty("os.name").toLowerCase().contains("win"); + javaExecutable = isWin ? "java.exe" : "java"; } /** @@ -73,6 +77,30 @@ public static JCommander jcommander(String[] a, Object args, String programName) return jCommander; } + /** + * Get OS specific path to java + * + * @return system JAVA_HOME/bin/java + */ + public static String getJava() { + String javaHome = System.getProperty("java.home"); + + return getJava(javaHome); + } + + /** + * Get OS specific path to java with defined JAVA_HOME + * + * @return system JAVA_HOME/bin/java + */ + public static String getJava(String javaHome) { + // safely remove " from JAVA_HOME path + javaHome = javaHome.replace("\"", ""); + + return Paths.get(javaHome, "bin", javaExecutable).toString(); + } + + /** * Prints usage string to output. * diff --git a/src/main/java/org/yardstickframework/runners/CommandHandler.java b/src/main/java/org/yardstickframework/runners/CommandHandler.java index efb90ee..74e8d2f 100644 --- a/src/main/java/org/yardstickframework/runners/CommandHandler.java +++ b/src/main/java/org/yardstickframework/runners/CommandHandler.java @@ -19,6 +19,7 @@ import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -32,6 +33,8 @@ import org.yardstickframework.runners.context.RunContext; import org.yardstickframework.runners.context.RunMode; +import static org.yardstickframework.BenchmarkUtils.getJava; + /** * Command handler. */ @@ -491,9 +494,7 @@ public CommandExecutionResult runLocalJava(String args) { while (args.contains(" ")) args = args.replace(" ", " "); - String javaHome = System.getProperty("java.home"); - - String cmd = String.format("%s/bin/java %s", javaHome, args); + String cmd = String.format("%s %s", getJava(), args); String[] cmdArr = cmd.split(" "); @@ -558,10 +559,7 @@ public CommandExecutionResult runDockerCmd(String host, String cmd) throws IOExc String fullCmd = String.format("docker %s", cmd); if (isLocal(host)) { - if(fullCmd.endsWith("'echo $JAVA_HOME'") || fullCmd.contains(">")) - return runLocCmd(fullCmd); - else - return runRmtCmd(fullCmd); + return fullCmd.endsWith("'echo $JAVA_HOME'") || fullCmd.contains(">") ? runLocCmd(fullCmd) : runRmtCmd(fullCmd); } else { fullCmd = String.format("%s docker %s", getFullSSHPref(host), cmd); @@ -575,7 +573,7 @@ public CommandExecutionResult runDockerCmd(String host, String cmd) throws IOExc * @return {@code true} if host address is "localhost" or "127.0.0.1" or {@code false} otherwise. */ private boolean isLocal(String host) { - return host.equalsIgnoreCase("localhost") || host.equals("127.0.0.1"); + return "localhost".equalsIgnoreCase(host) || "127.0.0.1".equals(host); } /** @@ -641,7 +639,7 @@ public boolean checkConn(String host) { return res != null && res.exitCode() == 0 && !res.outputList().isEmpty() - && res.outputList().get(0).equals("check"); + && "check".equals(res.outputList().get(0)); } /** @@ -651,9 +649,9 @@ public boolean checkConn(String host) { */ public boolean checkJava(String host, String javaHome) { if (isLocal(host)) - return new File(javaHome + "/bin/java").exists(); + return new File(getJava(javaHome)).exists(); - String checkCmd = String.format("%s test -f %s/bin/java", getFullSSHPref(host), javaHome); + String checkCmd = String.format("%s test -f %s", getFullSSHPref(host), getJava(javaHome)); CommandExecutionResult res = null; diff --git a/src/main/java/org/yardstickframework/runners/Runner.java b/src/main/java/org/yardstickframework/runners/Runner.java index c32e9cb..61709d6 100644 --- a/src/main/java/org/yardstickframework/runners/Runner.java +++ b/src/main/java/org/yardstickframework/runners/Runner.java @@ -16,6 +16,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Set; import java.util.List; @@ -274,11 +275,17 @@ protected Logger log() { * */ private void createCharts() { - String mainResDir = String.format("%s/output/result-%s", runCtx.localeWorkDirectory(), runCtx.mainDateTime()); + String mainResDir = Paths.get(runCtx.localeWorkDirectory(), + " output", + String.format("result-%s", runCtx.mainDateTime()) + ).toString(); log().info(String.format("Creating charts for result directory '%s'.", mainResDir)); - String cp = String.format("%s/libs/*", runCtx.localeWorkDirectory()); + String cp = String.format("%s%s%s", + Paths.get(runCtx.localeWorkDirectory(), "libs").toString(), + File.separator, + "*"); String mainCls = "org.yardstickframework.report.jfreechart.JFreeChartGraphPlotter"; diff --git a/src/main/java/org/yardstickframework/runners/context/RunContext.java b/src/main/java/org/yardstickframework/runners/context/RunContext.java index ec88ac0..f5bbb6c 100644 --- a/src/main/java/org/yardstickframework/runners/context/RunContext.java +++ b/src/main/java/org/yardstickframework/runners/context/RunContext.java @@ -14,6 +14,7 @@ package org.yardstickframework.runners.context; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.Set; @@ -267,7 +268,7 @@ public String description(String src) { */ public String resolveRemotePath(String srcPath) { if (!srcPath.startsWith(remWorkDir)) - return String.format("%s/%s", remWorkDir, srcPath); + return Paths.get(remWorkDir, srcPath).toString(); return srcPath; } diff --git a/src/main/java/org/yardstickframework/runners/context/RunContextInitializer.java b/src/main/java/org/yardstickframework/runners/context/RunContextInitializer.java index 4014fa1..c1c9a6a 100644 --- a/src/main/java/org/yardstickframework/runners/context/RunContextInitializer.java +++ b/src/main/java/org/yardstickframework/runners/context/RunContextInitializer.java @@ -24,6 +24,7 @@ import java.net.SocketException; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; @@ -40,6 +41,8 @@ import org.yardstickframework.BenchmarkConfiguration; import org.yardstickframework.BenchmarkUtils; +import static org.yardstickframework.BenchmarkUtils.getJava; + /** * Initializes run context. */ @@ -138,7 +141,7 @@ private boolean handleArgs(String[] args) { LOG.debug(String.format("Locale work directory is '%s'.", ctx.localeWorkDirectory())); if (ctx.config().propertyFile() == null) { - String dfltPropPath = String.format("%s/config/benchmark.properties", ctx.localeWorkDirectory()); + String dfltPropPath = Paths.get(ctx.localeWorkDirectory(), "config", "benchmark.properties").toString(); LOG.info(String.format("Using as a default property file '%s'.", dfltPropPath)); @@ -438,8 +441,9 @@ private void setJavaHome() { String locJavaHome = System.getProperty("java.home"); - if (ctx.properties().getProperty("JAVA_HOME") != null && new File(String.format("%s/bin/java", remJavaHome)).exists()) - locJavaHome = String.format("%s/bin/java", remJavaHome); + // TODO: 3/14/2019 locaJavaHome may be direct link to JAVA_HOME/bin/java + if (ctx.properties().getProperty("JAVA_HOME") != null && new File(getJava(remJavaHome)).exists()) + locJavaHome = getJava(remJavaHome); ctx.localeJavaHome(locJavaHome); @@ -559,8 +563,7 @@ private List hostsToList(String commaSepList) { String[] ips = commaSepList.split(","); - for (String ip : ips) - res.add(ip); + Collections.addAll(res, ips); return res; } @@ -572,7 +575,11 @@ private void setDockerContext() { String dockerCtxPropPath; if (ctx.properties().getProperty("DOCKER_CONTEXT_PATH") == null) { - dockerCtxPropPath = String.format("%s/config/docker/docker-context-default.yaml", ctx.localeWorkDirectory()); + dockerCtxPropPath = Paths.get(ctx.localeWorkDirectory(), + "config", + "docker", + "docker-context-default.yaml" + ).toString(); LOG.info("'DOCKER_CONTEXT_PATH' is not defined in property file. Will " + "use default docker context configuration:"); @@ -609,7 +616,7 @@ private String resolvePath(String srcPath) { String fullPath = null; if(!srcPath.startsWith(ctx.localeWorkDirectory())) - fullPath = String.format("%s/%s", ctx.localeWorkDirectory(), srcPath); + fullPath = Paths.get(ctx.localeWorkDirectory(), srcPath).toString(); if (new File(fullPath).exists()) return fullPath; @@ -643,7 +650,7 @@ private boolean checkPropertyFile() throws IOException { if (!line.contains("=") || line.startsWith("#") || prevLine.contains("\\")) continue; - int idx0 = line.indexOf("="); + int idx0 = line.indexOf('='); String propName = line.substring(0, idx0); @@ -665,10 +672,11 @@ private boolean checkPropertyFile() throws IOException { * */ private void configLog() { - String logPropPath = String.format("%s/config/log4j.properties", ctx.localeWorkDirectory()); + String logPropPath = Paths.get(ctx.localeWorkDirectory(), "config", "log4j.properties").toString(); - String logPath = Paths.get(ctx.localeWorkDirectory(), "output", String.format("logs-%s/%s-run.log", - ctx.mainDateTime(), ctx.mainDateTime())).toString(); + String logPath = Paths.get(ctx.localeWorkDirectory(), "output", + String.format("logs-%s", ctx.mainDateTime()), + String.format("%s-run.log", ctx.mainDateTime())).toString(); if (new File(logPropPath).exists()){ Properties logProps = new Properties(); diff --git a/src/main/java/org/yardstickframework/runners/starters/InDockerNodeStarter.java b/src/main/java/org/yardstickframework/runners/starters/InDockerNodeStarter.java index 665f5a2..f5d7d1e 100644 --- a/src/main/java/org/yardstickframework/runners/starters/InDockerNodeStarter.java +++ b/src/main/java/org/yardstickframework/runners/starters/InDockerNodeStarter.java @@ -21,6 +21,8 @@ import org.yardstickframework.runners.context.DockerInfo; import org.yardstickframework.runners.context.RunContext; +import static org.yardstickframework.BenchmarkUtils.getJava; + /** * Starts nodes in docker containers. */ @@ -47,7 +49,7 @@ public InDockerNodeStarter(RunContext runCtx) { try { String mkdirCmd = String.format("exec %s mkdir -p %s", contName, nodeLogDir); - String startNodeCmd = String.format("%s/bin/java %s", javaHome, javaParams); + String startNodeCmd = String.format("%s %s", getJava(javaHome), javaParams); String cmd = String.format("exec --workdir %s %s nohup %s > %s 2>& 1 &", runCtx.remoteWorkDirectory(), contName, startNodeCmd, nodeInfo.logPath()); diff --git a/src/main/java/org/yardstickframework/runners/starters/PlainNodeStarter.java b/src/main/java/org/yardstickframework/runners/starters/PlainNodeStarter.java index f9e22b8..4be86b6 100644 --- a/src/main/java/org/yardstickframework/runners/starters/PlainNodeStarter.java +++ b/src/main/java/org/yardstickframework/runners/starters/PlainNodeStarter.java @@ -22,6 +22,8 @@ import org.yardstickframework.runners.context.NodeInfo; import org.yardstickframework.runners.context.RunContext; +import static org.yardstickframework.BenchmarkUtils.getJava; + /** * Starts nodes. */ @@ -45,12 +47,10 @@ public PlainNodeStarter(RunContext runCtx) { String javaHome = runCtx.getHostJava(host); - CommandExecutionResult res = null; - try { - String withJavaHome = String.format("%s/bin/java %s", javaHome, param); + String withJavaHome = String.format("%s %s", getJava(javaHome), param); - res = runCtx.handler().startNode(host, withJavaHome, nodeInfo.logPath()); + CommandExecutionResult res = runCtx.handler().startNode(host, withJavaHome, nodeInfo.logPath()); nodeInfo.commandExecutionResult(res); } diff --git a/src/main/java/org/yardstickframework/runners/workers/host/CheckJavaWorker.java b/src/main/java/org/yardstickframework/runners/workers/host/CheckJavaWorker.java index 58f30bd..5f0129e 100644 --- a/src/main/java/org/yardstickframework/runners/workers/host/CheckJavaWorker.java +++ b/src/main/java/org/yardstickframework/runners/workers/host/CheckJavaWorker.java @@ -21,6 +21,8 @@ import org.yardstickframework.runners.workers.WorkResult; import org.yardstickframework.runners.context.RunContext; +import static org.yardstickframework.BenchmarkUtils.getJava; + /** * Checks java on remote hosts and set host map. */ @@ -59,8 +61,7 @@ public CheckJavaWorker(RunContext runCtx, Set hostSet) { if (runCtx.remoteJavaHome() != null) { if (!runCtx.handler().checkJava(host, runCtx.remoteJavaHome())) { - log().info(String.format("Failed to find %s/bin/java on the host %s.", - runCtx.remoteJavaHome(), host)); + log().info(String.format("Failed to find %s on the host %s.", getJava(runCtx.remoteJavaHome()), host)); res.exit(true); } diff --git a/src/main/java/org/yardstickframework/runners/workers/host/CleanRemDirWorker.java b/src/main/java/org/yardstickframework/runners/workers/host/CleanRemDirWorker.java index 811d823..7a426ad 100644 --- a/src/main/java/org/yardstickframework/runners/workers/host/CleanRemDirWorker.java +++ b/src/main/java/org/yardstickframework/runners/workers/host/CleanRemDirWorker.java @@ -15,6 +15,7 @@ package org.yardstickframework.runners.workers.host; import java.io.IOException; +import java.nio.file.Paths; import java.util.Set; import org.yardstickframework.runners.workers.CheckWorkResult; import org.yardstickframework.runners.workers.WorkResult; @@ -53,8 +54,9 @@ private WorkResult clean(String host) { try { for (String name : toClean) { - String cleanCmd = String.format("rm -rf %s/%s", - runCtx.remoteWorkDirectory(), name); + String pathToClean = Paths.get(runCtx.remoteWorkDirectory(), name).toString(); + + String cleanCmd = String.format("rm -rf %s", pathToClean); runCtx.handler().runCmd(host, cleanCmd); } diff --git a/src/main/java/org/yardstickframework/runners/workers/host/CollectWorker.java b/src/main/java/org/yardstickframework/runners/workers/host/CollectWorker.java index d66acdf..36b99ec 100644 --- a/src/main/java/org/yardstickframework/runners/workers/host/CollectWorker.java +++ b/src/main/java/org/yardstickframework/runners/workers/host/CollectWorker.java @@ -16,6 +16,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Paths; import java.util.Set; import org.yardstickframework.runners.CommandHandler; import org.yardstickframework.runners.workers.CheckWorkResult; @@ -33,7 +34,7 @@ public class CollectWorker extends HostWorker { public CollectWorker(RunContext runCtx, Set hostSet) { super(runCtx, hostSet); - outDir = new File(String.format("%s/output", runCtx.localeWorkDirectory())); + outDir = Paths.get(runCtx.localeWorkDirectory(), "output").toFile(); } /** {@inheritDoc} */ @@ -49,14 +50,14 @@ public CollectWorker(RunContext runCtx, Set hostSet) { if (isLocal(host) && runCtx.dirsEquals()) return res; - String nodeOutDir = String.format("%s/output", runCtx.remoteWorkDirectory()); + String nodeOutDir = Paths.get(runCtx.remoteWorkDirectory(), "output").toString(); log().info(String.format("Collecting data from the host '%s'.", host)); String pathLoc = outDir.getAbsolutePath(); try { - String pathRem = String.format("%s/*", nodeOutDir); + String pathRem = String.format("%s%s%s", nodeOutDir, File.separator, "*"); runCtx.handler().download(host, pathLoc, pathRem); } diff --git a/src/main/java/org/yardstickframework/runners/workers/host/DeployWorker.java b/src/main/java/org/yardstickframework/runners/workers/host/DeployWorker.java index 896ab6c..27271bd 100644 --- a/src/main/java/org/yardstickframework/runners/workers/host/DeployWorker.java +++ b/src/main/java/org/yardstickframework/runners/workers/host/DeployWorker.java @@ -63,7 +63,7 @@ public DeployWorker(RunContext runCtx, Set hostSet) { if (runCtx.handler().checkRemFile(host, fullPath)) runCtx.handler().runMkdirCmd(host, fullPath); - String locPath = String.format("%s/%s", runCtx.localeWorkDirectory(), name); + String locPath = Paths.get(runCtx.localeWorkDirectory(), name).toString(); runCtx.handler().upload(host, locPath, runCtx.remoteWorkDirectory()); } diff --git a/src/main/java/org/yardstickframework/runners/workers/host/KillWorker.java b/src/main/java/org/yardstickframework/runners/workers/host/KillWorker.java index c32f17c..a3284e2 100644 --- a/src/main/java/org/yardstickframework/runners/workers/host/KillWorker.java +++ b/src/main/java/org/yardstickframework/runners/workers/host/KillWorker.java @@ -31,7 +31,6 @@ public KillWorker(RunContext runCtx, Set hostSet) { /** {@inheritDoc} */ @Override public WorkResult doWork(String host, int cnt) { - try { String killServCmd = "pkill -9 -f Dyardstick.server"; diff --git a/src/main/java/org/yardstickframework/runners/workers/node/DockerCollectWorker.java b/src/main/java/org/yardstickframework/runners/workers/node/DockerCollectWorker.java index a5edc90..319bab7 100644 --- a/src/main/java/org/yardstickframework/runners/workers/node/DockerCollectWorker.java +++ b/src/main/java/org/yardstickframework/runners/workers/node/DockerCollectWorker.java @@ -15,6 +15,7 @@ package org.yardstickframework.runners.workers.node; import java.io.IOException; +import java.nio.file.Paths; import java.util.List; import org.yardstickframework.runners.context.NodeInfo; import org.yardstickframework.runners.context.NodeType; @@ -41,9 +42,9 @@ public DockerCollectWorker(RunContext runCtx, List nodeList) { String contName = String.format("%s_%s", contNamePref, id); - String nodeOutDir = String.format("%s/output", runCtx.remoteWorkDirectory()); + String nodeOutDir = Paths.get(runCtx.remoteWorkDirectory(), "output").toString(); - String cpCmd = String.format("cp %s:%s/output %s", contName, runCtx.remoteWorkDirectory(), runCtx.remoteWorkDirectory()); + String cpCmd = String.format("cp %s:%s %s", contName, nodeOutDir, runCtx.remoteWorkDirectory()); log().info(String.format("Collecting data from the container '%s' on the host '%s'.", contName, host)); diff --git a/src/main/java/org/yardstickframework/runners/workers/node/RestartNodeWorker.java b/src/main/java/org/yardstickframework/runners/workers/node/RestartNodeWorker.java index dacda14..9911fbb 100644 --- a/src/main/java/org/yardstickframework/runners/workers/node/RestartNodeWorker.java +++ b/src/main/java/org/yardstickframework/runners/workers/node/RestartNodeWorker.java @@ -15,6 +15,7 @@ package org.yardstickframework.runners.workers.node; import java.io.IOException; +import java.nio.file.Paths; import java.util.Collections; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -43,9 +44,9 @@ public RestartNodeWorker(RunContext runCtx, List nodeList, String cfgF startTime = System.currentTimeMillis(); - servLogDirFullName = String.format("%s/log_servers_restarted", baseLogDirFullName); + servLogDirFullName = Paths.get(baseLogDirFullName, "log_servers_restarted").toString(); - drvrLogDirFullName = String.format("%s/log_drivers_restarted", baseLogDirFullName); + drvrLogDirFullName = Paths.get(baseLogDirFullName, "log_drivers_restarted").toString(); } /** {@inheritDoc} */ diff --git a/src/main/java/org/yardstickframework/runners/workers/node/StartNodeWorker.java b/src/main/java/org/yardstickframework/runners/workers/node/StartNodeWorker.java index 7d05bf8..b191aa2 100644 --- a/src/main/java/org/yardstickframework/runners/workers/node/StartNodeWorker.java +++ b/src/main/java/org/yardstickframework/runners/workers/node/StartNodeWorker.java @@ -14,55 +14,78 @@ package org.yardstickframework.runners.workers.node; -import com.beust.jcommander.ParameterException; +import java.io.File; import java.io.IOException; +import java.nio.file.Paths; import java.util.List; import org.yardstickframework.BenchmarkConfiguration; import org.yardstickframework.BenchmarkUtils; import org.yardstickframework.runners.context.NodeInfo; -import org.yardstickframework.runners.starters.NodeStarter; import org.yardstickframework.runners.context.NodeType; -import org.yardstickframework.runners.context.RunMode; import org.yardstickframework.runners.context.RunContext; +import org.yardstickframework.runners.context.RunMode; +import org.yardstickframework.runners.starters.NodeStarter; /** * Starts node. */ public class StartNodeWorker extends NodeWorker { - /** */ + /** + * + */ private String dateTime; - /** */ + /** + * + */ private String logDirName; - /** */ + /** + * + */ protected String baseLogDirFullName; - /** */ + /** + * + */ private String cfgFullStr; - /** */ + /** + * + */ protected String servLogDirFullName; - /** */ + /** + * + */ private String servMainCls = "org.yardstickframework.BenchmarkServerStartUp"; - /** */ + /** + * + */ protected String drvrLogDirFullName; - /** */ + /** + * + */ private String drvrMainCls = "org.yardstickframework.BenchmarkDriverStartUp"; - /** */ + /** + * + */ private String warmup; - /** */ + /** + * + */ private String duration; /** Initial duration. */ protected Long initDuration; - /** */ + /** + * + */ private BenchmarkConfiguration cfg; /** @@ -89,11 +112,11 @@ public StartNodeWorker(RunContext runCtx, List nodeList, String cfgFul logDirName = String.format("logs-%s", dateTime); - baseLogDirFullName = String.format("%s/output/%s", runCtx.remoteWorkDirectory(), logDirName); + baseLogDirFullName = Paths.get(runCtx.remoteWorkDirectory(), "output", logDirName).toString(); - servLogDirFullName = String.format("%s/log_servers", baseLogDirFullName); + servLogDirFullName = Paths.get(baseLogDirFullName, "log_servers").toString(); - drvrLogDirFullName = String.format("%s/log_drivers", baseLogDirFullName); + drvrLogDirFullName = Paths.get(baseLogDirFullName, "log_drivers").toString(); warmup = runCtx.warmup(); @@ -161,15 +184,14 @@ NodeInfo startNode(NodeInfo nodeInfo) throws InterruptedException { nodeInfo.parameterString(paramStr); - String logFileName = String.format("%s/%s-%s-id%s-%s-%s.log", - logDirFullName, + String logFileName = String.format("%s-%s-id%s-%s-%s.log", nodeStartTime, nodeInfo.nodeType().toString().toLowerCase(), id, host, descript); - nodeInfo.logPath(logFileName); + nodeInfo.logPath(Paths.get(logDirFullName, logFileName).toString()); NodeStarter starter = runCtx.nodeStarter(nodeInfo); @@ -187,10 +209,13 @@ private String getParamStr(NodeInfo nodeInfo) { NodeType type = nodeInfo.nodeType(); - String drvrResDir = String.format("%s/output/result-%s", runCtx.remoteWorkDirectory(), runCtx.mainDateTime()); + String drvrResDir = Paths.get(runCtx.remoteWorkDirectory(), + "output", + String.format("result-%s", runCtx.mainDateTime()) + ).toString(); String outputFolderParam = getNodeListSize() > 1 ? - String.format("--outputFolder %s/%s-%s", drvrResDir, id, host) : + String.format("--outputFolder %s", Paths.get(drvrResDir, String.format("%s-%s", id, host))) : String.format("--outputFolder %s", drvrResDir); String jvmOptsStr = runCtx.properties().getProperty("JVM_OPTS") != null ? @@ -205,14 +230,17 @@ private String getParamStr(NodeInfo nodeInfo) { String concJvmOpts = jvmOptsStr + " " + nodeJvmOptsStr; - concJvmOpts = concJvmOpts.replace("GC_LOG_PATH", String.format("%s/gc-%s-%s-id%s-%s-%s.log", - logDirFullName(nodeInfo), - nodeInfo.nodeStartTime(), - nodeInfo.typeLow(), - id, - host, - nodeInfo.description())); - + concJvmOpts = concJvmOpts.replace("GC_LOG_PATH", + Paths.get(logDirFullName(nodeInfo), String.format("gc-%s-%s-id%s-%s-%s.log", + nodeInfo.nodeStartTime(), + nodeInfo.typeLow(), + id, + host, + nodeInfo.description()) + ).toString() + ); + + // TODO: 3/14/2019 ? String fullJvmOpts = concJvmOpts.replace("\"", ""); String propPath = runCtx.propertyPath().replace(runCtx.localeWorkDirectory(), runCtx.remoteWorkDirectory()); @@ -221,13 +249,18 @@ private String getParamStr(NodeInfo nodeInfo) { String servName = runCtx.serverName() != null ? runCtx.serverName() : cfg.serverName(); - return String.format("%s -Dyardstick.%s%s -cp :%s/libs/* %s -id %s %s %s --serverName %s --warmup %s " + + String cp = String.format("%s%s%s", + Paths.get(runCtx.remoteWorkDirectory(), "libs").toString(), + File.separator, + "*"); + + return String.format("%s -Dyardstick.%s%s -cp :%s %s -id %s %s %s --serverName %s --warmup %s " + "--duration %s --threads %s --config %s --logsFolder %s --remoteuser %s --currentFolder %s " + "--scriptsFolder %s/bin", fullJvmOpts, nodeInfo.typeLow(), id, - runCtx.remoteWorkDirectory(), + cp, mainClass(type), id, outputFolderParam, @@ -244,7 +277,7 @@ private String getParamStr(NodeInfo nodeInfo) { } /** - * @param type Node type. + * @param nodeInfo Node type. * @return Path to log directory. */ private String logDirFullName(NodeInfo nodeInfo) {