处理指定的processId变化，返回结果true代表需要继续监听,false代表不需要监视
19682
private boolean initProcessStage(Long processId, List<String> currentStages) {
        Collections.sort(currentStages, new StageComparator());
        if (logger.isDebugEnabled()) {
            logger.debug("pipeline[{}] processId[{}] with stage{}", new Object[] { getPipelineId(), processId,
                    currentStages });
        }

        this.currentStages.put(processId, currentStages);// 更新下stage数据
        stageChanged(processId, currentStages);// 通知stage变化
        // 2.1 判断是否存在了loaded节点，此节点为最后一个节点
        if (currentStages.contains(ArbitrateConstants.NODE_TRANSFORMED)) {
            return true;// 不需要监听了
        } else {
            return false;// 其他的状态需要监听
        }
    }
384592
public Long getProcessId(String procname) throws Exception {
        Process proc = ProcessCache.getProcess(procname, 0);
        if (proc == null)
            throw new DataAccessException(0, "Cannot find process with name "
                    + procname + ", version 0");

        return proc.getId();
    }
401598
private boolean validateProcessInstance(ProcessInstance processInst) {
        Integer status = processInst.getStatusCode();
        if (WorkStatus.STATUS_CANCELLED.equals(status)) {
            logger.info("ProcessInstance has been cancelled. ProcessInstanceId = " + processInst.getId());
            return false;
        } else if (WorkStatus.STATUS_COMPLETED.equals(status)) {
            logger.info("ProcessInstance has been completed. ProcessInstanceId = " + processInst.getId());
            return false;
        } else return true;
    }
152994
function defaultClientIDHandler(args, context, info) {
  return get(args, [ 'clientID' ]) ||
    get(context, [ 'clientID' ]) ||
    get(info, [ 'rootValue', 'clientID' ]);
}
276135
public static String process_pid() {
        String name = ManagementFactory.getRuntimeMXBean().getName();
        String[] split = name.split("@");
        if (split.length != 2) {
            throw new RuntimeException("Got unexpected process name: " + name);
        }

        return split[0];
    }
981674
def _check_pid(self, allow_reset=False):
        """"""
        if not self.pid == current_process().pid:
            if allow_reset:
                self.reset()
            else:
                raise RuntimeError("Forbidden operation in multiple processes")
98130
def write_pid(pidfile):
    
    pid = str(os.getpid())
    try:
        with open(pidfile, mode='w') as _file:
            print("writing processID {p} to pidfile".format(p=pid))
            _file.write(pid)
    except OSError as exc:
        sys.exit("failed to write pidfile:{e}".format(e=exc))
807599
function() {
		var pid = process.pid;
		
		return Q.fcall(function() {
			if (process.platform === 'win32') {
				process._debugProcess(pid);
			}
			else {
				process.kill(pid, 'SIGUSR1');
			}
		});
	}
271038
def isPIDValid(self, pid):
        
        ## Slightly copied wholesale from http://stackoverflow.com/questions/568271/how-to-check-if-there-exists-a-process-with-a-given-pid
        ## Thanks to http://stackoverflow.com/users/1777162/ntrrgc and http://stackoverflow.com/users/234270/speedplane
        class ExitCodeProcess(ctypes.Structure):
            _fields_ = [('hProcess', ctypes.c_void_p),
                        ('lpExitCode', ctypes.POINTER(ctypes.c_ulong))]
        SYNCHRONIZE = 0x100000
        PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
        process = self._kernel32.OpenProcess(SYNCHRONIZE|PROCESS_QUERY_LIMITED_INFORMATION, 0, pid)
        if not process:
            return False
        ec = ExitCodeProcess()
        out = self._kernel32.GetExitCodeProcess(process, ctypes.byref(ec))
        if not out:
            err = self._kernel32.GetLastError()
            if self._kernel32.GetLastError() == 5:
                # Access is denied.
                logging.warning("Access is denied to get pid info.")
            self._kernel32.CloseHandle(process)
            return False
        elif bool(ec.lpExitCode):
            # There is an exit code, it quit
            self._kernel32.CloseHandle(process)
            return False
        # No exit code, it's running.
        self._kernel32.CloseHandle(process)
        return True
911186
def running(processid):
    
    try:
        # From kill(2)
        #   If sig is 0 (the null signal), error checking is performed but no
        #   signal is actually sent. The null signal can be used to check the
        #   validity of pid
        os.kill(processid, 0)
    except OverflowError as exc:
        print("checking validity of pid ({p}) failed with: {e}"
              .format(p=processid, e=exc))
        sys.exit(1)
    except OSError:
        return False
    else:
        return True
557090
def pid
      return nil unless is_window?
      process_id = 0.chr * 4
      GetWindowThreadProcessId(handle, process_id)
      process_id = process_id.unpack('L').first
    end
1338527
public static String getProcess(Long channelId, Long pipelineId, Long processId) {
        // 根据channelId , pipelineId构造path
        return MessageFormat.format(ArbitrateConstants.NODE_PROCESS_FORMAT,
            String.valueOf(channelId),
            String.valueOf(pipelineId),
            getProcessNode(processId));
    }
476828
def decode_cpu_id(self, cpuid):
        """"""
        ret = ()
        for i in cpuid.split(':'):
            ret += (eval('0x' + i),)

        return ret
756693
def get_process_by_id(self, process_id):
        
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url('process_id', process_id, 'str')
        response = self._send(http_method='GET',
                              location_id='93878975-88c5-4e6a-8abb-7ddd77a8a7d8',
                              version='5.1-preview.1',
                              route_values=route_values)
        return self._deserialize('Process', response)
5269
private Long getMinTransformedProcessId(Long loadedProcessId) {
        ProcessMonitor processMonitor = ArbitrateFactory.getInstance(getPipelineId(), ProcessMonitor.class);
        List<Long> processIds = processMonitor.getCurrentProcessIds();
        // 如果需要当前node处理当前process的load时，rpc请求一定会将对应的stage状态发到这机器上，并保存到progress中
        if (!CollectionUtils.isEmpty(processIds) && !CollectionUtils.isEmpty(progress)) {
            // 上一次load成功的在当前的processId中不存在，可能有两种情况:
            // 1. zk还未将数据通知过来，当前current processIds还是为老版本的值
            // 2. processId已经被删除，比如好久没有数据同步了，定时触发时发觉列表一直为空
            // if (loadedProcessId != null && !processIds.contains(loadedProcessId)) {
            // // 强制刷新一次，不过也可能是刷到老版本的值，杭州leader还没同步到美国
            // processIds = processMonitor.getCurrentProcessIds(true);
            // }

            Long result = null;
            // 做的一个优化，如果上一个processId load成功是在本机，直接忽略
            // 因为存在一个问题：比如两个process，都先完成了T模块，然后逐个触发L模块，此时第二个process需要等zookeeper回调watcher时才会被触发
            for (Long processId : processIds) {
                if (loadedProcessId == null || processId > loadedProcessId) {
                    result = processId;
                    break;
                }
            }

            // 如果不存在符合>loadedProcessId的记录，直接假设下一个processId就是上一个id+1
            // 因为processId目前的机制永远只会递增
            if (result == null) {
                result = loadedProcessId + 1;
            }

            if (result != null) {
                StageProgress stage = progress.get(result);
                if (stage != null && stage.getStage().isTransform()) {
                    return result;
                } else {
                    logger.info("rpc compute [{}] but stage [{}]", result, stage == null ? null : stage.getStage());
                    return null;
                }
            }
        }

        return null;
    }
175872
function(psRec,sProcId){
            if(!sProcId){throw new Error("No Proc Id found in data");}
            var iFind,sArgs
            iFind=psRec.CommandLine.indexOf(psRec.Name);
            sArgs = psRec.CommandLine.substring(iFind+psRec.Name.length+1);
            psRecs[sProcId]={
                pid: psRec.ProcessId
               ,ppid: psRec.ParentProcessId
               ,commandPath: psRec.ExecutablePath
               ,command: psRec.Name
               ,args: sArgs
            }
        }
763315
public static boolean isReachable(String processDefinitionId, String sourceElementId, String targetElementId) {

    // Fetch source and target elements
    Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);

    FlowElement sourceFlowElement = process.getFlowElement(sourceElementId, true);
    FlowNode sourceElement = null;
    if (sourceFlowElement instanceof FlowNode) {
      sourceElement = (FlowNode) sourceFlowElement;
    } else if (sourceFlowElement instanceof SequenceFlow) {
      sourceElement = (FlowNode) ((SequenceFlow) sourceFlowElement).getTargetFlowElement();
    }

    FlowElement targetFlowElement = process.getFlowElement(targetElementId, true);
    FlowNode targetElement = null;
    if (targetFlowElement instanceof FlowNode) {
      targetElement = (FlowNode) targetFlowElement;
    } else if (targetFlowElement instanceof SequenceFlow) {
      targetElement = (FlowNode) ((SequenceFlow) targetFlowElement).getTargetFlowElement();
    }

    if (sourceElement == null) {
      throw new ActivitiException("Invalid sourceElementId '" + sourceElementId + "': no element found for this id n process definition '" + processDefinitionId + "'");
    }
    if (targetElement == null) {
      throw new ActivitiException("Invalid targetElementId '" + targetElementId + "': no element found for this id n process definition '" + processDefinitionId + "'");
    }

    Set<String> visitedElements = new HashSet<String>();
    return isReachable(process, sourceElement, targetElement, visitedElements);
  }