public static MasterClientService.Client getConnection(ClientContext context) { checkArgument(context != null, "context is null"); List<String> locations = context.getMasterLocations(); if (locations.size() == 0) { log.debug("No masters..."); return null; } HostAndPort master = HostAndPort.fromString(locations.get(0)); if (master.getPort() == 0) return null; try { // Master requests can take a long time: don't ever time out return ThriftUtil.getClientNoTimeout(new MasterClientService.Client.Factory(), master, context); } catch (TTransportException tte) { Throwable cause = tte.getCause(); if (cause != null && cause instanceof UnknownHostException) { // do not expect to recover from this throw new RuntimeException(tte); } log.debug("Failed to connect to master=" + master + ", will retry... ", tte); return null; } }
return ThriftUtil.getClientNoTimeout(new ReplicationCoordinator.Client.Factory(), coordinatorAddr, context); } catch (TTransportException tte) {
public static MasterClientService.Client getConnection(ClientContext context) { checkArgument(context != null, "context is null"); List<String> locations = context.getInstance().getMasterLocations(); if (locations.size() == 0) { log.debug("No masters..."); return null; } HostAndPort master = HostAndPort.fromString(locations.get(0)); if (0 == master.getPort()) return null; try { // Master requests can take a long time: don't ever time out MasterClientService.Client client = ThriftUtil .getClientNoTimeout(new MasterClientService.Client.Factory(), master, context); return client; } catch (TTransportException tte) { Throwable cause = tte.getCause(); if (null != cause && cause instanceof UnknownHostException) { // do not expect to recover from this throw new RuntimeException(tte); } log.debug("Failed to connect to master=" + master + ", will retry... ", tte); return null; } }
ReplicationCoordinator.Client client = ThriftUtil.getClientNoTimeout( new ReplicationCoordinator.Client.Factory(), coordinatorAddr, context); return client;