/** * @return all the works' info * @throws IOException if the underlying master RPC fails */ public synchronized List<WorkerInfo> getWorkersInfo() throws IOException { return mBlockMasterClient.getWorkerInfoList(); }
/** * Gets the worker address based on its hostname by querying the master. * * @param hostname hostname of the worker to query, empty string denotes any worker * @return NetAddress of hostname, or null if no worker found */ private synchronized NetAddress getWorkerAddress(String hostname) { BlockMasterClient masterClient = acquireMasterClient(); try { List<WorkerInfo> workers = masterClient.getWorkerInfoList(); if (hostname.isEmpty() && !workers.isEmpty()) { // TODO(calvin): Do this in a more defined way. return workers.get(0).getAddress(); } for (WorkerInfo worker : workers) { if (worker.getAddress().getHost().equals(hostname)) { return worker.getAddress(); } } } catch (IOException ioe) { Throwables.propagate(ioe); } finally { releaseMasterClient(masterClient); } return null; }