public static File getConfigurationFile(String filename) { File file = new File(filename).getAbsoluteFile(); if (file.exists()) { return file; } else { return newFile(getSimulatorHome(), "conf", filename).getAbsoluteFile(); } } }
private void runLocal() { logger.info(format("Stopping Agent %s", ip)); bash.execute(format("%s/bin/.kill-from-pid-file agent.pid", getSimulatorHome())); }
private void runLocal() { logger.info(format("Starting Agent on %s", ip)); execute(format("nohup %s/bin/agent %s%s > agent.out 2> agent.err < /dev/null &", getSimulatorHome(), mandatoryParameters, optionalParameters)); execute(format("%s/bin/.await-file-exists agent.pid", getSimulatorHome())); }
public static String loadLog4jConfig() { return getFileAsTextFromWorkingDirOrBaseDir(getSimulatorHome(), "worker-log4j.xml", "Log4j configuration for Worker"); }
private void cleanLocal() { File workerHome = newFile(getSimulatorHome(), WORKERS_HOME_NAME); LOGGER.info(format("Cleaning local worker directory %s ...", workerHome.getAbsolutePath())); String workerPath = workerHome.getAbsolutePath(); execute(format("rm -fr %s || true", workerPath)); LOGGER.info("Cleaning local worker directory complete!"); }
private void copyResourcesToWorkerHome(String workerId) { File workersHome = new File(getSimulatorHome(), WORKERS_HOME_NAME); String sessionId = agent.getSessionId(); File uploadDirectory = new File(workersHome, sessionId + "/upload/").getAbsoluteFile(); if (!uploadDirectory.exists() || !uploadDirectory.isDirectory()) { LOGGER.debug("Skip copying upload directory to workers since no upload directory was found"); return; } String copyCommand = format("cp -rfv %s/%s/upload/* %s/%s/%s/ || true", workersHome, sessionId, workersHome, sessionId, workerId); execute(copyCommand); LOGGER.info(format("Finished copying '%s' to Worker", workersHome)); }
private void downloadLocal() { LOGGER.info("Retrieving artifacts of local machine"); File workerHome = newFile(getSimulatorHome(), WORKERS_HOME_NAME); String workerPath = workerHome.getAbsolutePath(); if ("*".equals(sessionId)) { execute(format("cp -r %s/* %s || true", workerPath, outputDirectory.getAbsolutePath())); } else { execute(format("cp -r %s/%s/* %s || true", workerPath, sessionId, outputDirectory.getAbsolutePath())); } execute(format("mv ./agent.err %s/ || true", outputDirectory.getAbsolutePath())); execute(format("mv ./agent.out %s/ || true", outputDirectory.getAbsolutePath())); }
public File getSessionDirectory() { String sessionId = this.sessionId; if (sessionId == null) { throw new IllegalStateException("no session active"); } File workersDir = ensureExistingDirectory(getSimulatorHome(), "workers"); return ensureExistingDirectory(workersDir, sessionId); }
public static String loadWorkerScript(WorkerType workerType, String vendor) { List<File> files = new LinkedList<File>(); File confDir = new File(getSimulatorHome(), "conf"); files.add(new File("worker-" + vendor + "-" + workerType.name() + ".sh").getAbsoluteFile()); files.add(new File("worker-" + workerType + ".sh").getAbsoluteFile()); files.add(new File("worker-" + vendor + ".sh").getAbsoluteFile()); files.add(new File("worker.sh").getAbsoluteFile()); files.add(new File(confDir, "worker-" + vendor + "-" + workerType.name() + ".sh").getAbsoluteFile()); files.add(new File(confDir, "worker-" + vendor + ".sh").getAbsoluteFile()); files.add(new File(confDir, "worker.sh").getAbsoluteFile()); for (File file : files) { if (file.exists()) { LOGGER.info("Loading " + vendor + " " + workerType.name() + " worker script: " + file.getAbsolutePath()); return fileAsText(file); } } throw new CommandLineExitException("Failed to load worker script from the following locations:" + files); }
private static void logHeader() { LOGGER.info("Hazelcast Simulator Agent"); LOGGER.info(format("Version: %s, Commit: %s, Build Time: %s", getSimulatorVersion(), getCommitIdAbbrev(), getBuildTime())); LOGGER.info(format("SIMULATOR_HOME: %s%n", getSimulatorHome().getAbsolutePath())); logImportantSystemProperties(); }
public SimulatorProperties() { this.propertiesFile = newFile(getSimulatorHome(), "conf", PROPERTIES_FILE_NAME); LOGGER.info(format("Loading default %s: %s", PROPERTIES_FILE_NAME, propertiesFile.getAbsolutePath())); check(propertiesFile); load(propertiesFile); }
private String getClasspath(File workerHome) { String simulatorHome = getSimulatorHome().getAbsolutePath(); String hzVersionDirectory = directoryForVersionSpec(workerProcessSettings.getVersionSpec()); String testJarVersion = getHazelcastVersionFromJAR(simulatorHome + "/hz-lib/" + hzVersionDirectory + "/*"); LOGGER.info(format("Adding Hazelcast %s and test JARs %s to classpath", hzVersionDirectory, testJarVersion)); String uploadClassPath = ""; File uploadDirectory = new File(workerHome, "upload").getAbsoluteFile(); if (uploadDirectory.exists() && uploadDirectory.isDirectory()) { File[] files = uploadDirectory.listFiles(); if (files != null && files.length > 0) { uploadClassPath = CLASSPATH_SEPARATOR + uploadDirectory.getAbsolutePath() + "/*"; LOGGER.info(format("Adding upload directory %s to classpath", uploadClassPath)); } } // we have to reverse the classpath to monkey patch version specific classes return new File(agent.getSessionDirectory(), "lib/*").getAbsolutePath() + CLASSPATH_SEPARATOR + simulatorHome + "/user-lib/*" + CLASSPATH_SEPARATOR + simulatorHome + "/test-lib/" + testJarVersion + "/*" + CLASSPATH_SEPARATOR + simulatorHome + "/test-lib/common/*" + CLASSPATH_SEPARATOR + simulatorHome + "/hz-lib/" + hzVersionDirectory + "/*" + uploadClassPath + CLASSPATH_SEPARATOR + CLASSPATH; }
public static void main(String[] args) { LOGGER.info("Hazelcast Simulator Provisioner"); LOGGER.info(format("Version: %s, Commit: %s, Build Time: %s", getSimulatorVersion(), getCommitIdAbbrev(), getBuildTime())); LOGGER.info(format("SIMULATOR_HOME: %s", getSimulatorHome())); try { ProvisionerCli cli = new ProvisionerCli(args); cli.run(); } catch (Exception e) { exitWithError(LOGGER, "Could not execute command", e); } } }
public static void main(String[] args) { LOGGER.info("Hazelcast Simulator Coordinator"); LOGGER.info(format("Version: %s, Commit: %s, Build Time: %s", getSimulatorVersion(), getCommitIdAbbrev(), getBuildTime())); LOGGER.info(format("SIMULATOR_HOME: %s", getSimulatorHome().getAbsolutePath())); try { CoordinatorCli cli = new CoordinatorCli(args); cli.run(); } catch (Exception e) { exitWithError(LOGGER, "Failed to run Coordinator", e); } } }
static void logHeader() { echo("Hazelcast Simulator AWS Provisioner"); echo("Version: %s, Commit: %s, Build Time: %s", getSimulatorVersion(), getCommitIdAbbrev(), getBuildTime()); echo("SIMULATOR_HOME: %s", getSimulatorHome().getAbsolutePath()); }
static void logHeader() { echo("Hazelcast Simulator HeatMap"); echo("Version: %s, Commit: %s, Build Time: %s", getSimulatorVersion(), getCommitIdAbbrev(), getBuildTime()); echo("SIMULATOR_HOME: %s", getSimulatorHome().getAbsolutePath()); }
environment.putAll(workerProcessSettings.getEnvironment()); environment.put("CLASSPATH", getClasspath(workerHome)); environment.put("SIMULATOR_HOME", getSimulatorHome().getAbsolutePath()); environment.put("WORKER_ID", workerProcess.getId()); environment.put("WORKER_TYPE", workerProcessSettings.getWorkerType().toString());
static MemberWorker startWorker() throws Exception { echo("Hazelcast Simulator Worker"); echo("Version: %s, Commit: %s, Build Time: %s", getSimulatorVersion(), getCommitIdAbbrev(), getBuildTime()); echo("SIMULATOR_HOME: %s%n", getSimulatorHome().getAbsolutePath());