Return host worker by id

@param  string      $id     Worker id
@param  string      $host   Hostname
@param  Logger      $logger Logger
@return array|false
183635
public static function hostWorker($id, $host = null, Logger $logger = null)
    {
        $workers = self::hostWorkers($host);

        foreach ($workers as $worker) {
            if ((string)$id == (string)$worker and posix_kill($worker->getPid(), 0)) {
                return $worker;
            }
        }

        return false;
    }
86402
public function getManager($id, $checkUrl = null)
    {
        if (!isset($this->managers[$id])) {
            $this->managers[$id] = parent::getManager($id, $checkUrl);

            return $this->managers[$id];
        }

        $server = $this->managers[$id]->getServer();
        if ($server->getCheckUrl() === null) {
            if (empty($checkUrl)) {
                $checkUrl = $this
                    ->container
                    ->get('router')
                    ->generate('claro_security_login_check', [], UrlGeneratorInterface::ABSOLUTE_URL);
            }
            $server->setCheckUrl($checkUrl);
            $server->setIndexUrl(
                $this
                    ->container
                    ->get('router')
                    ->generate('claro_index', [], UrlGeneratorInterface::ABSOLUTE_URL));
        }

        return $this->managers[$id];
    }
65116
public B accessLogger(String loggerName) {
        requireNonNull(loggerName, "loggerName");
        return accessLogger(host -> LoggerFactory.getLogger(loggerName));
    }
999402
@Override
  public List<TaskStatusEvent> getJobHistory(final JobId jobId, final String host)
      throws JobDoesNotExistException {
    final Job descriptor = getJob(jobId);
    if (descriptor == null) {
      throw new JobDoesNotExistException(jobId);
    }
    final ZooKeeperClient client = provider.get("getJobHistory");
    final List<String> hosts;

    try {
      hosts = (!isNullOrEmpty(host)) ? singletonList(host) :
              client.getChildren(Paths.historyJobHosts(jobId));
    } catch (NoNodeException e) {
      return emptyList();
    } catch (KeeperException e) {
      throw new RuntimeException(e);
    }

    final List<TaskStatusEvent> jsEvents = Lists.newArrayList();

    for (final String h : hosts) {
      final List<String> events;
      try {
        events = client.getChildren(Paths.historyJobHostEvents(jobId, h));
      } catch (NoNodeException e) {
        continue;
      } catch (KeeperException e) {
        throw new RuntimeException(e);
      }

      for (final String event : events) {
        try {
          final byte[] data = client.getData(Paths.historyJobHostEventsTimestamp(
              jobId, h, Long.valueOf(event)));
          final TaskStatus status = Json.read(data, TaskStatus.class);
          jsEvents.add(new TaskStatusEvent(status, Long.valueOf(event), h));
        } catch (NoNodeException e) { // ignore, it went away before we read it
        } catch (KeeperException | IOException e) {
          throw new RuntimeException(e);
        }
      }
    }

    return Ordering.from(EVENT_COMPARATOR).sortedCopy(jsEvents);
  }
892079
public function worker($serverId, $siteId, $workerId)
    {
        return new Worker(
            $this->get("servers/$serverId/sites/$siteId/workers/$workerId")['worker']
            + ['server_id' => $serverId, 'site_id' => $siteId], $this
        );
    }
230349
public static function allWorkers(Logger $logger = null)
    {
        if (!($ids = Redis::instance()->smembers(self::redisKey()))) {
            return array();
        }

        $workers = array();
        foreach ($ids as $id) {
            if (($worker = self::fromId($id, $logger)) !== false) {
                $workers[] = $worker;
            }
        }

        return $workers;
    }
543966
protected static function getLoggerId(\Plop\LoggerInterface $logger)
    {
        $func   = $logger->getMethod();
        $cls    = $logger->getClass();
        $ns     = $logger->getNamespace();
        return "$func:$cls:$ns";
    }
87042
public function getByID($id)
    {
        $site = $this->entityManager->getRepository('Concrete\Core\Entity\Site\Site')
            ->find($id);
        $factory = new Factory($this->config);
        if (is_object($site)) {
            return $factory->createEntity($site);
        }
    }
115975
public function byId($id, $fields = null)
    {
        if (is_null($fields)) {
            $fields = self::$defaultFields;
        }

        return $this->get("employees/{$id}/", ['fields' => implode(',', $fields)]);
    }
212840
def get_ansible_by_id(self, ansible_id):
        """"""

        for elem in self.ansible_hosts:
            if elem.id == ansible_id:
                return elem
        return None
1037993
public function parseId($id, $host, $config = []) {
		if (empty($id) || empty($host)) {
			return null;
		}

		// local files?
		if ($host === 'local') {
			$res = $this->embedLocal($id);
			if (!$res) {
				$stub = [];
				$Object = $this->object($stub, $config);
				return $Object;
			}
			//TODO
			return null;
		}

		// all other hosts
		$host = $this->getHost($host);
		if (!$host) {
			return null;
		}
		$stub = $host;
		$config += $this->config;

		$stub['id'] = $id;
		$stub['reverse'] = true;
		$Object = $this->object($stub, $config);

		return $Object;
	}
635369
protected function isCachedById(int $id, int $siteId = null)
    {
        // Resolve siteId
        $siteId = SiteHelper::resolveSiteId($siteId);

        if (!isset($this->cacheById[$siteId])) {
            $this->cacheById[$siteId] = [];
        }

        return array_key_exists($id, $this->cacheById[$siteId]);
    }
706988
public function isWorker($worker_id = null)
    {
        if ($worker_id == null) {
            $worker_id = $this->workerId;
        }
        return $worker_id < $this->worker_num ? true : false;
    }
561278
public function getCampaign($id, $args = array(), $returnRaw = false)
    {
        $args['id'] = $id;

        return $this->getResult('getCampaign', $args, false, $returnRaw);
    }
619747
public function setLogger(LoggerInterface $logger)
    {
        $this->logger = $logger;

        if ($this->serviceStream instanceof LoggerAwareInterface) {
            $this->serviceStream->setLogger($this->getLogger());
        }

        if ($this->workerHandlerStream instanceof LoggerAwareInterface) {
            $this->workerHandlerStream->setLogger($this->getLogger());
        }

        return $this;
    }
1234019
public static function parse(string $host): HostInterface
    {
        if (!self::myParse($host, $hostname, $ipAddress, $error)) {
            throw new HostInvalidArgumentException($error);
        }

        return new self($hostname, $ipAddress);
    }
236839
private function get(String $id)
	{
		if (!$id) {
			$id = ConnectionManager::DEFAULT_CONNECTION_ID;
		}

		if (count($this->loadedConnections) < 1) {
			return false;
		}

		if (isset($this->loadedConnections[$id])) {
			$this->configuredConnectionId = $id;
			$this->platformConnector = [$id => $this->loadedConnections[$id]];
			$connector = new PlatformResolver($this);
			return $connector->resolvePlatform(new EventManager());
		}
	}