use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.
the class DefaultBlockWorker method createBlockReader.
@Override
public BlockReader createBlockReader(BlockReadRequest request) throws BlockDoesNotExistException, IOException {
long sessionId = request.getSessionId();
long blockId = request.getId();
RetryPolicy retryPolicy = new TimeoutRetry(UFS_BLOCK_OPEN_TIMEOUT_MS, Constants.SECOND_MS);
while (retryPolicy.attempt()) {
BlockReader reader = createLocalBlockReader(sessionId, blockId, request.getStart());
if (reader != null) {
Metrics.WORKER_ACTIVE_CLIENTS.inc();
return reader;
}
boolean checkUfs = request.isPersisted() || (request.getOpenUfsBlockOptions() != null && request.getOpenUfsBlockOptions().hasBlockInUfsTier() && request.getOpenUfsBlockOptions().getBlockInUfsTier());
if (!checkUfs) {
throw new BlockDoesNotExistException(ExceptionMessage.NO_BLOCK_ID_FOUND, blockId);
}
// When the block does not exist in Alluxio but exists in UFS, try to open the UFS block.
try {
Metrics.WORKER_ACTIVE_CLIENTS.inc();
return createUfsBlockReader(request.getSessionId(), request.getId(), request.getStart(), request.isPositionShort(), request.getOpenUfsBlockOptions());
} catch (Exception e) {
throw new UnavailableException(String.format("Failed to read block ID=%s from tiered storage and UFS tier: %s", request.getId(), e.toString()));
}
}
throw new UnavailableException(ExceptionMessage.UFS_BLOCK_ACCESS_TOKEN_UNAVAILABLE.getMessage(request.getId(), request.getOpenUfsBlockOptions().getUfsPath()));
}
use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.
the class MultiProcessCluster method waitForAllNodesRegistered.
/**
* Waits for all nodes to be registered.
*
* @param timeoutMs maximum amount of time to wait, in milliseconds
*/
public synchronized void waitForAllNodesRegistered(int timeoutMs) throws TimeoutException, InterruptedException {
MetaMasterClient metaMasterClient = getMetaMasterClient();
int nodeCount = mNumMasters + mNumWorkers;
CommonUtils.waitFor("all nodes registered", () -> {
try {
MasterInfo masterInfo = metaMasterClient.getMasterInfo(Collections.emptySet());
int liveNodeNum = masterInfo.getMasterAddressesList().size() + masterInfo.getWorkerAddressesList().size();
if (liveNodeNum == nodeCount) {
return true;
} else {
LOG.info("Master addresses: {}. Worker addresses: {}", masterInfo.getMasterAddressesList(), masterInfo.getWorkerAddressesList());
return false;
}
} catch (UnavailableException e) {
return false;
} catch (Exception e) {
throw new RuntimeException(e);
}
}, WaitForOptions.defaults().setInterval(200).setTimeoutMs(timeoutMs));
}
use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.
the class ServiceSocketBindIntegrationTest method connectDifferentAddress.
@Test
public void connectDifferentAddress() throws Exception {
startCluster(NetworkAddressUtils.getLocalHostName(100));
// Connect to Master RPC service on loopback, while Master is listening on local hostname.
InetSocketAddress masterRpcAddr = new InetSocketAddress("127.0.0.1", mLocalAlluxioCluster.getLocalAlluxioMaster().getRpcLocalPort());
mBlockMasterClient = BlockMasterClient.Factory.create(MasterClientContext.newBuilder(ClientContext.create(ServerConfiguration.global())).setMasterInquireClient(new SingleMasterInquireClient(masterRpcAddr)).build());
try {
mBlockMasterClient.connect();
Assert.fail("Client should not have successfully connected to master RPC service.");
} catch (UnavailableException e) {
// This is expected, since Master RPC service is NOT listening on loopback.
}
// Connect to Worker RPC service on loopback, while Worker is listening on local hostname.
try {
mBlockMasterClient.connect();
Assert.fail("Client should not have successfully connected to Worker RPC service.");
} catch (Exception e) {
// This is expected, since Work RPC service is NOT listening on loopback.
}
// connect Worker data service on loopback, while Worker is listening on local hostname.
InetSocketAddress workerDataAddr = new InetSocketAddress("127.0.0.1", mLocalAlluxioCluster.getWorkerProcess().getDataLocalPort());
try {
mWorkerDataService = SocketChannel.open(workerDataAddr);
Assert.assertTrue(mWorkerDataService.isConnected());
Assert.fail("Client should not have successfully connected to Worker RPC service.");
} catch (IOException e) {
// This is expected, since Worker data service is NOT listening on loopback.
}
// connect Master Web service on loopback, while Master is listening on local hostname.
try {
mMasterWebService = (HttpURLConnection) new URL("http://127.0.0.1:" + mLocalAlluxioCluster.getLocalAlluxioMaster().getMasterProcess().getWebAddress().getPort() + "/home").openConnection();
Assert.assertEquals(200, mMasterWebService.getResponseCode());
Assert.fail("Client should not have successfully connected to Master Web service.");
} catch (IOException e) {
// This is expected, since Master Web service is NOT listening on loopback.
} finally {
Assert.assertNotNull(mMasterWebService);
mMasterWebService.disconnect();
}
// connect Worker Web service on loopback, while Worker is listening on local hostname.
try {
mWorkerWebService = (HttpURLConnection) new URL("http://127.0.0.1:" + mLocalAlluxioCluster.getWorkerProcess().getWebLocalPort() + "/home").openConnection();
Assert.assertEquals(200, mWorkerWebService.getResponseCode());
Assert.fail("Client should not have successfully connected to Worker Web service.");
} catch (IOException e) {
// This is expected, since Worker Web service is NOT listening on loopback.
} finally {
mWorkerWebService.disconnect();
}
}
Aggregations