@Override public void setupBlobPermissions(File path, String user) throws IOException { String logPrefix = "setup blob permissions for " + path; SupervisorUtils.processLauncherAndWait(_conf, user, Arrays.asList("blob", path.toString()), null, logPrefix); }
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); }
public static void setupWorkerArtifactsDir(Map<String, Object> conf, String user, String dir) throws IOException { if (Utils.getBoolean(conf.get(Config.SUPERVISOR_RUN_WORKER_AS_USER), false)) { String logPrefix = "Worker Artifacts Setup for " + dir; List<String> commands = new ArrayList<>(); commands.add("artifacts-dir"); commands.add(dir); processLauncherAndWait(conf, user, commands, null, logPrefix); } }
public static void setupStormCodeDir(Map<String, Object> conf, String user, String dir) throws IOException { if (Utils.getBoolean(conf.get(Config.SUPERVISOR_RUN_WORKER_AS_USER), false)) { String logPrefix = "Storm Code Dir Setup for " + dir; List<String> commands = new ArrayList<>(); commands.add("code-dir"); commands.add(dir); processLauncherAndWait(conf, user, commands, null, logPrefix); } }
public static void rmrAsUser(Map<String, Object> conf, String id, String path) throws IOException { String user = Utils.getFileOwner(path); String logPreFix = "rmr " + id; List<String> commands = new ArrayList<>(); commands.add("rmr"); commands.add(path); SupervisorUtils.processLauncherAndWait(conf, user, commands, null, logPreFix); if (Utils.checkFileExists(path)) { throw new RuntimeException(path + " was not deleted."); } }
@Override public void deleteIfExists(File path, String user, String logPrefix) throws IOException { String absolutePath = path.getAbsolutePath(); LOG.info("Deleting path {}", absolutePath); if (user == null) { user = Files.getOwner(path.toPath()).getName(); } List<String> commands = new ArrayList<>(); commands.add("rmr"); commands.add(absolutePath); SupervisorUtils.processLauncherAndWait(_conf, user, commands, null, logPrefix); if (Utils.checkFileExists(absolutePath)) { // It's possible that permissions were not set properly on the directory, and // the user who is *supposed* to own the dir does not. In this case, try the // delete as the supervisor user. Utils.forceDelete(absolutePath); if (Utils.checkFileExists(absolutePath)) { throw new RuntimeException(path + " was not deleted."); } } }
@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; }