private String[] buildArgs(WorkerJvm workerJvm, WorkerType type) {
    List<String> args = new LinkedList<String>();

    int workerIndex = workerJvmSettings.getWorkerIndex();
    int workerPort = agent.getPort() + workerIndex;

    addNumaCtlSettings(args);
    addProfilerSettings(workerJvm, args);

    args.add("-classpath");
    args.add(getClasspath());
    args.addAll(getJvmOptions());
    args.add("-XX:OnOutOfMemoryError=\"touch worker.oome\"");
    args.add("-Dhazelcast.logging.type=log4j");
    args.add("-Dlog4j.configuration=file:" + log4jFile.getAbsolutePath());

    args.add("-DSIMULATOR_HOME=" + getSimulatorHome());
    args.add("-DworkerId=" + workerJvm.getId());
    args.add("-DworkerType=" + type);
    args.add("-DpublicAddress=" + agent.getPublicAddress());
    args.add("-DagentIndex=" + agent.getAddressIndex());
    args.add("-DworkerIndex=" + workerIndex);
    args.add("-DworkerPort=" + workerPort);
    args.add("-DautoCreateHzInstance=" + workerJvmSettings.isAutoCreateHzInstance());
    args.add(
        "-DworkerPerformanceMonitorIntervalSeconds="
            + workerJvmSettings.getWorkerPerformanceMonitorIntervalSeconds());
    args.add("-DhzConfigFile=" + hzConfigFile.getAbsolutePath());

    // add class name to start correct worker type
    args.add(type.getClassName());

    return args.toArray(new String[args.size()]);
  }
  private WorkerJvm startWorkerJvm() throws IOException {
    int workerIndex = workerJvmSettings.getWorkerIndex();
    WorkerType type = workerJvmSettings.getWorkerType();

    SimulatorAddress workerAddress =
        new SimulatorAddress(AddressLevel.WORKER, agent.getAddressIndex(), workerIndex, 0);
    String workerId =
        "worker-" + agent.getPublicAddress() + '-' + workerIndex + '-' + type.toLowerCase();
    File workerHome = new File(testSuiteDir, workerId);
    ensureExistingDirectory(workerHome);

    WorkerJvm workerJvm = new WorkerJvm(workerAddress, workerId, workerHome);

    generateWorkerStartScript(type, workerJvm);

    ProcessBuilder processBuilder =
        new ProcessBuilder(new String[] {"bash", "worker.sh"})
            .directory(workerHome)
            .redirectErrorStream(true);

    Map<String, String> environment = processBuilder.environment();
    String javaHome = getJavaHome();
    String path = javaHome + File.pathSeparator + "bin:" + environment.get("PATH");
    environment.put("PATH", path);
    environment.put("JAVA_HOME", javaHome);

    Process process = processBuilder.start();
    workerJvm.setProcess(process);
    copyResourcesToWorkerId(workerId);
    workerJvmManager.add(workerAddress, workerJvm);

    return workerJvm;
  }