Inform REEF of a cleanly exited process.

@param processId
432910
private void onCleanExit(final String processId) {
    this.onResourceStatus(
        ResourceStatusEventImpl.newBuilder()
            .setIdentifier(processId)
            .setState(State.DONE)
            .setExitCode(0)
            .build()
    );
  }
513247
void release(final String containerId) {
    LOG.log(Level.FINE, "Release container: {0}", containerId);
    final Container container = this.containers.removeAndGet(containerId);
    this.resourceManager.releaseAssignedContainer(container.getId());
    updateRuntimeStatus();
  }
12682
public static final void assertProcessEnded(final String processInstanceId) {
        Validate.notNull(processInstanceId);

        apiCallback.debug(LogMessage.PROCESS_5, processInstanceId);
        try {
            getProcessInstanceAssertable().processIsEnded(processInstanceId);
        } catch (final AssertionError ae) {
            apiCallback.fail(ae, LogMessage.ERROR_PROCESS_2, processInstanceId);
        }
    }
46985
def save_exit_status(pid)
        logger.debug "Spawning thread to monitor process ID #{pid}"
        @success = nil
        Thread.start do
          logger.debug "Thread started, waiting for PID #{pid}"
          status = Process.waitpid2(pid).last.exitstatus
          logger.debug "Process exited with status #{status}"
          @success = (status == 0)
        end
      end
1221204
def clean_process_tree(*signal_handler_args):
    """"""
    parent = psutil.Process()
    procs = parent.children(recursive=True)
    if procs:
        print(f"[ZProc] Cleaning up {parent.name()!r} ({os.getpid()})...")

    for p in procs:
        with suppress(psutil.NoSuchProcess):
            p.terminate()
    _, alive = psutil.wait_procs(procs, timeout=0.5)  # 0.5 seems to work
    for p in alive:
        with suppress(psutil.NoSuchProcess):
            p.kill()

    try:
        signum = signal_handler_args[0]
    except IndexError:
        pass
    else:
        os._exit(signum)
469943
def _TerminateProcessByPid(self, pid):
    
    self._RaiseIfNotRegistered(pid)

    process = self._processes_per_pid[pid]

    self._TerminateProcess(process)
    self._StopMonitoringProcess(process)
1031315
function pidFind(pid) {
  if (!_.isFinite(pid)) return false;
  try {
    if (runningAsRoot()) {
      return process.kill(pid, 0);
    } else {
      return !!ps(pid);
    }
  } catch (e) {
    return false;
  }
}
33201
private void syncStage(final Long processId) {
        // 1. 根据pipelineId + processId构造对应的path
        String path = null;
        try {
            path = StagePathUtils.getProcess(getPipelineId(), processId);
            // 2. 监听当前的process列表的变化
            IZkConnection connection = zookeeper.getConnection();
            // zkclient包装的是一个持久化的zk，分布式lock只需要一次性的watcher，需要调用原始的zk链接进行操作
            ZooKeeper orginZk = ((ZooKeeperx) connection).getZookeeper();
            List<String> currentStages = orginZk.getChildren(path, new AsyncWatcher() {

                public void asyncProcess(WatchedEvent event) {
                    MDC.put(ArbitrateConstants.splitPipelineLogFileKey, String.valueOf(getPipelineId()));
                    if (isStop()) {
                        return;
                    }

                    if (event.getType() == EventType.NodeDeleted) {
                        processTermined(processId); // 触发下节点删除
                        return;
                    }

                    // 出现session expired/connection losscase下，会触发所有的watcher响应，同时老的watcher会继续保留，所以会导致出现多次watcher响应
                    boolean dataChanged = event.getType() == EventType.NodeDataChanged
                                          || event.getType() == EventType.NodeDeleted
                                          || event.getType() == EventType.NodeCreated
                                          || event.getType() == EventType.NodeChildrenChanged;
                    if (dataChanged) {
                        // boolean reply = initStage(processId);
                        // if (reply == false) {// 出现过load后就不需要再监听变化，剩下的就是节点的删除操作
                        syncStage(processId);
                        // }
                    }
                }
            });

            Collections.sort(currentStages, new StageComparator());
            List<String> lastStages = this.currentStages.get(processId);
            if (lastStages == null || !lastStages.equals(currentStages)) {
                initProcessStage(processId); // 存在差异，立马触发一下
            }

        } catch (NoNodeException e) {
            processTermined(processId); // 触发下节点删除
        } catch (KeeperException e) {
            syncStage(processId);
        } catch (InterruptedException e) {
            // ignore
        }
    }
1124754
def _CheckStatusAnalysisProcess(self, pid):
    
    # TODO: Refactor this method, simplify and separate concerns (monitoring
    # vs management).
    self._RaiseIfNotRegistered(pid)

    if pid in self._completed_analysis_processes:
      status_indicator = definitions.STATUS_INDICATOR_COMPLETED
      process_status = {
          'processing_status': status_indicator}
      used_memory = 0

    else:
      process = self._processes_per_pid[pid]

      process_status = self._QueryProcessStatus(process)
      if process_status is None:
        process_is_alive = False
      else:
        process_is_alive = True

      process_information = self._process_information_per_pid[pid]
      used_memory = process_information.GetUsedMemory() or 0

      if self._worker_memory_limit and used_memory > self._worker_memory_limit:
        logger.warning((
            'Process: {0:s} (PID: {1:d}) killed because it exceeded the '
            'memory limit: {2:d}.').format(
                process.name, pid, self._worker_memory_limit))
        self._KillProcess(pid)

      if isinstance(process_status, dict):
        self._rpc_errors_per_pid[pid] = 0
        status_indicator = process_status.get('processing_status', None)

        if status_indicator == definitions.STATUS_INDICATOR_COMPLETED:
          self._completed_analysis_processes.add(pid)

      else:
        rpc_errors = self._rpc_errors_per_pid.get(pid, 0) + 1
        self._rpc_errors_per_pid[pid] = rpc_errors

        if rpc_errors > self._MAXIMUM_RPC_ERRORS:
          process_is_alive = False

        if process_is_alive:
          rpc_port = process.rpc_port.value
          logger.warning((
              'Unable to retrieve process: {0:s} (PID: {1:d}) status via '
              'RPC socket: http://localhost:{2:d}').format(
                  process.name, pid, rpc_port))

          processing_status_string = 'RPC error'
          status_indicator = definitions.STATUS_INDICATOR_RUNNING
        else:
          processing_status_string = 'killed'
          status_indicator = definitions.STATUS_INDICATOR_KILLED

        process_status = {
            'processing_status': processing_status_string}

    self._UpdateProcessingStatus(pid, process_status, used_memory)

    if status_indicator in definitions.ERROR_STATUS_INDICATORS:
      logger.error((
          'Process {0:s} (PID: {1:d}) is not functioning correctly. '
          'Status code: {2!s}.').format(
              process.name, pid, status_indicator))

      self._TerminateProcessByPid(pid)
410078
@Override
  public synchronized void recordRemovedEvaluator(final String id) {
    if (this.fileSystem != null && this.changeLogLocation != null) {
      final String entry = REMOVE_FLAG + id + System.lineSeparator();
      this.logContainerChange(entry);
    }
  }
259752
public void markCanBeCompleted(long id) {
    Long opId = id;
    completedOperationIds.offerLast(opId);
    Long start = starTimes.remove(opId);
    if (start != null) {
      stats.markRpcComplete(clock.nanoTime() - start);
    }
  }
1130559
public static void inactivateSubProcess(String spPid) {
		LogRepositoryManager destManager = getManager(LogRepositoryBaseImpl.TRACETYPE) ;
		((LogRepositoryManagerImpl)destManager).inactivateSubProcess(spPid) ;
		destManager = getManager(LogRepositoryBaseImpl.LOGTYPE) ;
		((LogRepositoryManagerImpl)destManager).inactivateSubProcess(spPid) ;
	}
837151
def output_callback(self, line, kill_switch):
        """"""
        self.notifications += line + "\n"

        if "Initialization Sequence Completed" in line:
            self.started = True
        if "ERROR:" in line or "Cannot resolve host address:" in line:
            self.error = True
        if "process exiting" in line:
            self.stopped = True
1371650
public void resetCallbacksForInProgressTasks(String workflowId) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank");
        postForEntityWithUriVariablesOnly("workflow/{workflowId}/resetcallbacks", workflowId);
    }
153312
public function logProcessStartedAt(ProcessId $processId, \DateTimeImmutable $startedAt)
    {
        $data = [
            'started_at' => $startedAt->format(\DateTime::ISO8601),
        ];

        $entry = $this->loadProcessEntryIfExists($processId);

        if (is_null($entry)) {
            $data['status'] = self::STATUS_RUNNING;

            $this->insertNewEntry($processId, $data);
        } else {
            $this->updateEntry($processId, $data);
        }
    }
1237905
def _del_process(self, dwProcessId):
        
        try:
            aProcess = self.__processDict[dwProcessId]
            del self.__processDict[dwProcessId]
        except KeyError:
            aProcess = None
            msg = "Unknown process ID %d" % dwProcessId
            warnings.warn(msg, RuntimeWarning)
        if aProcess:
            aProcess.clear()
753554
public void runDecider(String workflowId) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank");
        stub.decideWorkflow(WorkflowServicePb.DecideWorkflowRequest.newBuilder()
                .setWorkflowId(workflowId)
                .build()
        );
    }