use of alluxio.master.SingleMasterInquireClient 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