use of alluxio.client.block.BlockMasterClient in project alluxio by Alluxio.
the class FileSystemContext method getWorkerAddresses.
/**
* @return if there are any local workers, the returned list will ONLY contain the local workers,
* otherwise a list of all remote workers will be returned
* @throws IOException if an error occurs communicating with the master
*/
private List<WorkerNetAddress> getWorkerAddresses() throws IOException {
List<WorkerInfo> infos;
BlockMasterClient blockMasterClient = mBlockMasterClientPool.acquire();
try {
infos = blockMasterClient.getWorkerInfoList();
} catch (AlluxioException e) {
throw new IOException(e);
} finally {
mBlockMasterClientPool.release(blockMasterClient);
}
if (infos.isEmpty()) {
throw new IOException(ExceptionMessage.NO_WORKER_AVAILABLE.getMessage());
}
// Convert the worker infos into net addresses, if there are local addresses, only keep those
List<WorkerNetAddress> workerNetAddresses = new ArrayList<>();
List<WorkerNetAddress> localWorkerNetAddresses = new ArrayList<>();
String localHostname = NetworkAddressUtils.getClientHostName();
for (WorkerInfo info : infos) {
WorkerNetAddress netAddress = info.getAddress();
if (netAddress.getHost().equals(localHostname)) {
localWorkerNetAddresses.add(netAddress);
}
workerNetAddresses.add(netAddress);
}
return localWorkerNetAddresses.isEmpty() ? workerNetAddresses : localWorkerNetAddresses;
}
use of alluxio.client.block.BlockMasterClient in project alluxio by Alluxio.
the class AlluxioFrameworkIntegrationTest method testMesosDeploy.
private void testMesosDeploy(Map<PropertyKey, String> properties) throws Exception {
StringBuilder alluxioJavaOpts = new StringBuilder(System.getProperty("ALLUXIO_JAVA_OPTS", ""));
for (Entry<PropertyKey, String> entry : properties.entrySet()) {
alluxioJavaOpts.append(String.format(" -D%s=%s", entry.getKey().toString(), entry.getValue()));
}
Map<String, String> env = ImmutableMap.of("ALLUXIO_JAVA_OPTS", alluxioJavaOpts.toString());
try {
startAlluxioFramework(env);
LOG.info("Launched Alluxio cluster, waiting for worker to register with master");
String masterHostName = NetworkAddressUtils.getLocalHostName();
int masterPort = Configuration.getInt(PropertyKey.MASTER_RPC_PORT);
InetSocketAddress masterAddress = new InetSocketAddress(masterHostName, masterPort);
try (final BlockMasterClient client = BlockMasterClient.Factory.create(masterAddress)) {
CommonUtils.waitFor("Alluxio worker to register with master", new Function<Void, Boolean>() {
@Override
public Boolean apply(Void input) {
try {
try {
return !client.getWorkerInfoList().isEmpty();
} catch (ConnectionFailedException e) {
// block master isn't up yet, keep waiting
return false;
}
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
}, WaitForOptions.defaults().setTimeout(15 * Constants.MINUTE_MS));
}
LOG.info("Worker registered");
basicAlluxioTests();
} finally {
stopAlluxioFramework();
}
}
Aggregations