/** * Clean up the container partly preparing for restart. By default delete all of the temp directories we are going to get a new * worker_id anyways. POST CONDITION: the workerId will be set to null * * @throws IOException on any error */ public void cleanUpForRestart() throws IOException { LOG.info("Cleaning up {}:{}", _supervisorId, _workerId); Set<Long> pids = getAllPids(); String user = getWorkerUser(); for (Long pid : pids) { File path = new File(ConfigUtils.workerPidPath(_conf, _workerId, pid)); _ops.deleteIfExists(path, user, _workerId); } //clean up for resource isolation if enabled if (_resourceIsolationManager != null) { _resourceIsolationManager.releaseResourcesForWorker(_workerId); } //Always make sure to clean up everything else before worker directory //is removed since that is what is going to trigger the retry for cleanup _ops.deleteIfExists(new File(ConfigUtils.workerHeartbeatsRoot(_conf, _workerId)), user, _workerId); _ops.deleteIfExists(new File(ConfigUtils.workerPidsRoot(_conf, _workerId)), user, _workerId); _ops.deleteIfExists(new File(ConfigUtils.workerTmpRoot(_conf, _workerId)), user, _workerId); _ops.deleteIfExists(new File(ConfigUtils.workerRoot(_conf, _workerId)), user, _workerId); deleteSavedWorkerUser(); _workerId = null; }
/** * Setup the container to run. By default this creates the needed directories/links in the local file system PREREQUISITE: All needed * blobs and topology, jars/configs have been downloaded and placed in the appropriate locations * * @throws IOException on any error */ protected void setup() throws IOException { _type.assertFull(); if (!_ops.doRequiredTopoFilesExist(_conf, _topologyId)) { LOG.info("Missing topology storm code, so can't launch worker with assignment {} for this supervisor {} on port {} with id {}", _assignment, _supervisorId, _port, _workerId); throw new IllegalStateException("Not all needed files are here!!!!"); } LOG.info("Setting up {}:{}", _supervisorId, _workerId); _ops.forceMkdir(new File(ConfigUtils.workerPidsRoot(_conf, _workerId))); _ops.forceMkdir(new File(ConfigUtils.workerTmpRoot(_conf, _workerId))); _ops.forceMkdir(new File(ConfigUtils.workerHeartbeatsRoot(_conf, _workerId))); File workerArtifacts = new File(ConfigUtils.workerArtifactsRoot(_conf, _topologyId, _port)); if (!_ops.fileExists(workerArtifacts)) { _ops.forceMkdir(workerArtifacts); _ops.setupWorkerArtifactsDir(_assignment.get_owner(), workerArtifacts); } String user = getWorkerUser(); writeLogMetadata(user); saveWorkerUser(user); createArtifactsLink(); createBlobstoreLinks(); }
@Override public boolean areAllProcessesDead() throws IOException { Set<Long> pids = getAllPids(); String user = getWorkerUser(); boolean allDead = true; for (Long pid: pids) { if (!isProcessAlive(pid, user)) { LOG.debug("{}: PID {} is dead", _workerId, pid); } else { allDead = false; break; } } return allDead; }
/** * Clean up the container partly preparing for restart. * By default delete all of the temp directories we are going * to get a new worker_id anyways. * POST CONDITION: the workerId will be set to null * @throws IOException on any error */ public void cleanUpForRestart() throws IOException { LOG.info("Cleaning up {}:{}", _supervisorId, _workerId); Set<Long> pids = getAllPids(); String user = getWorkerUser(); for (Long pid : pids) { File path = new File(ConfigUtils.workerPidPath(_conf, _workerId, pid)); _ops.deleteIfExists(path, user, _workerId); } //Always make sure to clean up everything else before worker directory //is removed since that is what is going to trigger the retry for cleanup _ops.deleteIfExists(new File(ConfigUtils.workerHeartbeatsRoot(_conf, _workerId)), user, _workerId); _ops.deleteIfExists(new File(ConfigUtils.workerPidsRoot(_conf, _workerId)), user, _workerId); _ops.deleteIfExists(new File(ConfigUtils.workerTmpRoot(_conf, _workerId)), user, _workerId); _ops.deleteIfExists(new File(ConfigUtils.workerRoot(_conf, _workerId)), user, _workerId); deleteSavedWorkerUser(); _workerId = null; }
String user = getWorkerUser(); writeLogMetadata(user); saveWorkerUser(user);