Checks if there is a job in queue which the worker (identified by id) can handle.

@param string $workerId
@return array Job data or empty array if no suitable job in queue.
2684
protected function getJobFromQueue(string $workerId) : array
    {
        $workerJobCapabilities = $this->workerJobCapabilities[$workerId];
        foreach ($workerJobCapabilities as $jobName) {
            if (!isset($this->jobQueues[$jobName])) {
                continue;
            }
            if (empty($this->jobQueues[$jobName])) {
                continue;
            }
            $jobData = array_shift($this->jobQueues[$jobName]);
            $jobData['job_name'] = $jobName;
            $this->jobsInQueue--;
            return $jobData;
        }
        return [];
    }
380166
public function setId($id)
    {
        if ($this->status != self::STATUS_NEW) {
            throw new \RuntimeException('Cannot set worker id after worker has started working');
        }

        $this->id = $id;
    }
798282
public function onSwooleWorkerStart($serv, $workerId)
    {
        parent::onSwooleWorkerStart($serv, $workerId);
        $this->initAsynPools($workerId);
        //进程锁保证只有一个进程会执行以下的代码,reload也不会执行
        if (!$this->isTaskWorker() && $this->initLock->trylock()) {
            //进程启动后进行开服的初始化
            $this->onOpenServiceInitialization();
            if (Start::$testUnity) {
                $ready = ProcessManager::getInstance()->getRpcCall(CatCacheProcess::class)->isReady();
                if (!$ready) {
                    EventDispatcher::getInstance()->addOnceCoroutine(CatCacheProcess::READY);
                }
                new TestModule(Start::$testUnityDir);
            }
            $this->initLock->lock_read();
        }
        //向SDHelp進程取數據
        if (!$this->isTaskWorker()) {
            $isReload = $this->isReload();
            ConsulHelp::start();
            TimerTask::start();
            if ($this->config->get('catCache.enable', false)) {
                TimerCallBack::init();
                if (!$isReload) {
                    $ready = ProcessManager::getInstance()->getRpcCall(CatCacheProcess::class)->isReady();
                    if (!$ready) {
                        EventDispatcher::getInstance()->addOnceCoroutine(CatCacheProcess::READY);
                    }
                }
                Actor::recovery($workerId);
            }
        }
        //Code coverage
        register_tick_function([$this, 'onPhpTick']);
    }
41252
public synchronized List<alluxio.grpc.JobCommand> pollAllPendingCommands(long workerId) {
    if (!mWorkerIdToPendingCommands.containsKey(workerId)) {
      return Lists.newArrayList();
    }
    List<JobCommand> commands =
        Lists.newArrayList(mWorkerIdToPendingCommands.get(workerId));
    mWorkerIdToPendingCommands.get(workerId).clear();
    return commands;
  }
540414
public function peek($jobId)
	{
		$response = $this->_dispatch(
			new Pheanstalk_Command_PeekCommand($jobId)
		);

		return new Pheanstalk_Job($response['id'], $response['jobdata']);
	}
599926
public static function exists($resqueInst, $workerId)
    {
        $class = get_called_class();
        if (isset($class) && !empty($class) && method_exists($class, 'workerName')) {
            $workerName = call_user_func($class . '::workerName');
            return (bool)$resqueInst->redis->sismember($workerName . 's', $workerId);
        } else {
            throw new ResqueWorkerInvalidException(['method workerName not exist in child class']);
        }
    }
523333
private function getNodeIdFromJobId($jobId)
    {
        $nodePrefix = $this->getNodePrefixFromJobId($jobId);
        if (
            isset($this->nodePrefixes[$nodePrefix]) &&
            array_key_exists($this->nodePrefixes[$nodePrefix], $this->nodes)
        ) {
            return $this->nodePrefixes[$nodePrefix];
        }

        return null;
    }
1262178
public function getOne(int $taskId) : array {
        return $this->sendGet(
            sprintf('/profiles/%s/processes/%s/tasks/%s', $this->userName, $this->processId, $taskId)
        );
    }
600075
public function mfaDelete($id, $employeeId)
    {
        $result = $this->mfaDeleteInternal([
            'id' => $id,
            'employee_id' => $employeeId,
        ]);
        $statusCode = (int)$result[ 'statusCode' ];

        if ($statusCode === 204) {
            return null;
        }

        $this->reportUnexpectedResponse($result, 1506710702);
    }
1152873
public function stopWorker(int $workerId = null): bool
    {
        if ($this->server) {
            return $this->server->stop($workerId);
        }

        return false;
    }
425216
public function getEmployee($employeeId)
    {
        $result = null;
        $this->addHeader();
        try {
            $employee = $this->getSoap()->GetAcsEmployee([
                'id' => $employeeId
            ]);
            if (isset($employee->GetAcsEmployeeResult)) {
                $result = new Employee((array)$employee->GetAcsEmployeeResult);
            }
        } catch (\SoapFault $ex) {
            $result = false;
            $this->logError();
        }
        return $result;
    }
624287
public function getJob($jobId)
    {
        $url = parse_url($this->getBaseUrl());
        return $this->get("https://{$url['host']}/queue/job/{$jobId}")->send()->json();
    }
1037845
public function getUser(string $employeeId)
    {
        $result = $this->getUserInternal([
            'employee_id' => $employeeId,
        ]);
        $statusCode = (int)$result[ 'statusCode' ];
        
        if ($statusCode === 200) {
            return $this->getResultAsArrayWithoutStatusCode($result);
        } elseif ($statusCode === 204) {
            return null;
        }
        
        $this->reportUnexpectedResponse($result, 1490808555);
    }
146923
public static function post(TaskInfo $taskInfo, $workerID = -1)
    {
        return ServerManage::getServer('main')->getSwooleServer()->task($taskInfo, $workerID, [$taskInfo->getTaskHandler(), 'finish']);
    }
134575
public function onWorkerStart($serv, $workerId)
    {
        $this->initAsynPools();
        $this->initRedisProxies();
        //注册
        $this->asynPoolManager = new AsynPoolManager(null, $this);
        $this->asynPoolManager->noEventAdd();
        foreach ($this->asynPools as $pool) {
            if ($pool) {
                $pool->workerInit($workerId);
                $this->asynPoolManager->registerAsyn($pool);
            }
        }

        //redis proxy监测
        getInstance()->sysTimers[] = swoole_timer_tick(5000, function () {
            if (!empty($this->redisProxyManager)) {
                foreach ($this->redisProxyManager as $proxy) {
                    $proxy->check();
                }
            }
        });
    }
120906
protected function changeWorkerState(string $workerId, int $workerState) : bool
    {
        $this->workerStates[$workerId] = $workerState;
        if ($workerState === Worker::WORKER_STATE_IDLE) {
            $this->pushJobs();
        }
        return true;
    }
94106
public function buryJob($id)
    {
        $payload = $this->getPayload($id);

        if ($payload[self::JOB_PAYLOAD_STATE] !== self::STATE_RESERVED) {
            throw new QueueException(' Cannot bury state unsupported!' . $payload[self::JOB_PAYLOAD_STATE]);
        }

        $redisJobNamespace = $this->getRedisJobNamespace();
        $keyBuried = $this->getKeyBuried($payload[self::JOB_PAYLOAD_QUEUE]);
        $keyReserved = $this->getKeyReserved($payload[self::JOB_PAYLOAD_QUEUE]);

        $result = $this->getRedis()->transaction(
            function ($tx) use ($id, $payload, $keyBuried, $keyReserved, $redisJobNamespace) {
                /** @var $tx \Predis\Client */
                $tx->zrem($keyReserved, $id);
                $payload = self::buildPayload($payload[self::JOB_PAYLOAD_QUEUE], self::STATE_BURIED);
                $tx->hset($redisJobNamespace, $id, $payload);
                $tx->zadd($keyBuried, $this->getTime(), $id);
            }
        );

        return !in_array(false, $result);
    }