protected void deleteSavedWorkerUser() throws IOException { LOG.info("REMOVE worker-user {}", _workerId); _ops.deleteIfExists(new File(ConfigUtils.workerUserFile(_conf, _workerId))); }
protected void saveWorkerUser(String user) throws IOException { _type.assertFull(); LOG.info("SET worker-user {} {}", _workerId, user); _ops.dump(new File(ConfigUtils.workerUserFile(_conf, _workerId)), user); }
/** * @return the user that some operations should be done as. * * @throws IOException on any error */ protected String getWorkerUser() throws IOException { LOG.info("GET worker-user for {}", _workerId); File file = new File(ConfigUtils.workerUserFile(_conf, _workerId)); if (_ops.fileExists(file)) { return _ops.slurpString(file).trim(); } else if (_assignment != null && _assignment.is_set_owner()) { return _assignment.get_owner(); } if (ConfigUtils.isLocalMode(_conf)) { return System.getProperty("user.name"); } else { File f = new File(ConfigUtils.workerArtifactsRoot(_conf)); if (f.exists()) { return Files.getOwner(f.toPath()).getName(); } throw new IllegalStateException("Could not recover the user for " + _workerId); } }
protected void deleteSavedWorkerUser() throws IOException { LOG.info("REMOVE worker-user {}", _workerId); _ops.deleteIfExists(new File(ConfigUtils.workerUserFile(_conf, _workerId))); }
protected void saveWorkerUser(String user) throws IOException { _type.assertFull(); LOG.info("SET worker-user {} {}", _workerId, user); _ops.dump(new File(ConfigUtils.workerUserFile(_conf, _workerId)), user); }
/** * @return the user that some operations should be done as. * @throws IOException on any error */ protected String getWorkerUser() throws IOException { LOG.info("GET worker-user for {}", _workerId); File file = new File(ConfigUtils.workerUserFile(_conf, _workerId)); if (_ops.fileExists(file)) { return _ops.slurpString(file).trim(); } else if (_assignment != null && _assignment.is_set_owner()) { return _assignment.get_owner(); } if (ConfigUtils.isLocalMode(_conf)) { return System.getProperty("user.name"); } else { File f = new File(ConfigUtils.workerArtifactsRoot(_conf)); if (f.exists()) { return Files.getOwner(f.toPath()).getName(); } throw new IllegalStateException("Could not recover the user for " + _workerId); } }