/** * If 'supervisor.run.worker.as.user' is set, worker will be launched as the user that launched the topology. */ @Override protected String getRunWorkerAsUser() { try { return getWorkerUser(); } catch (Exception ex) { throw new RuntimeException(ex); } } }
private void signal(long pid, int signal) throws IOException { List<String> commands = Arrays.asList("signal", String.valueOf(pid), String.valueOf(signal)); String user = getWorkerUser(); String logPrefix = "kill -" + signal + " " + pid; ClientSupervisorUtils.processLauncherAndWait(_conf, user, commands, null, logPrefix); }
@Override protected void launchWorkerProcess(List<String> command, Map<String, String> env, String logPrefix, ExitCodeCallback processExitCallback, File targetDir) throws IOException { String workerDir = targetDir.getAbsolutePath(); String user = this.getWorkerUser(); List<String> args = Arrays.asList("worker", workerDir, ServerUtils.writeScript(workerDir, command, env)); List<String> commandPrefix = null; if (_resourceIsolationManager != null) { commandPrefix = _resourceIsolationManager.getLaunchCommandPrefix(_workerId); } ClientSupervisorUtils.processLauncher(_conf, user, commandPrefix, args, null, logPrefix, processExitCallback, targetDir); }
@Override protected boolean runProfilingCommand(List<String> command, Map<String, String> env, String logPrefix, File targetDir) throws IOException, InterruptedException { String user = this.getWorkerUser(); String td = targetDir.getAbsolutePath(); LOG.info("Running as user: {} command: {}", user, command); String containerFile = ServerUtils.containerFilePath(td); if (Utils.checkFileExists(containerFile)) { SupervisorUtils.rmrAsUser(_conf, containerFile, containerFile); } String scriptFile = ServerUtils.scriptFilePath(td); if (Utils.checkFileExists(scriptFile)) { SupervisorUtils.rmrAsUser(_conf, scriptFile, scriptFile); } String script = ServerUtils.writeScript(td, command, env); List<String> args = Arrays.asList("profiler", td, script); int ret = ClientSupervisorUtils.processLauncherAndWait(_conf, user, args, env, logPrefix); return ret == 0; }
private void signal(long pid, int signal) throws IOException { List<String> commands = Arrays.asList("signal", String.valueOf(pid), String.valueOf(signal)); String user = getWorkerUser(); String logPrefix = "kill -"+signal+" " + pid; SupervisorUtils.processLauncherAndWait(_conf, user, commands, null, logPrefix); }
@Override protected void launchWorkerProcess(List<String> command, Map<String, String> env, String logPrefix, ExitCodeCallback processExitCallback, File targetDir) throws IOException { String workerDir = targetDir.getAbsolutePath(); String user = this.getWorkerUser(); List<String> args = Arrays.asList("worker", workerDir, Utils.writeScript(workerDir, command, env)); List<String> commandPrefix = null; SupervisorUtils.processLauncher(_conf, user, commandPrefix, args, null, logPrefix, processExitCallback, targetDir); } }
@Override protected boolean runProfilingCommand(List<String> command, Map<String, String> env, String logPrefix, File targetDir) throws IOException, InterruptedException { String user = this.getWorkerUser(); String td = targetDir.getAbsolutePath(); LOG.info("Running as user: {} command: {}", user, command); String containerFile = Utils.containerFilePath(td); if (Utils.checkFileExists(containerFile)) { SupervisorUtils.rmrAsUser(_conf, containerFile, containerFile); } String scriptFile = Utils.scriptFilePath(td); if (Utils.checkFileExists(scriptFile)) { SupervisorUtils.rmrAsUser(_conf, scriptFile, scriptFile); } String script = Utils.writeScript(td, command, env); List<String> args = Arrays.asList("profiler", td, script); int ret = SupervisorUtils.processLauncherAndWait(_conf, user, args, env, logPrefix); return ret == 0; }