/** * Return local host name by default. Or local host IP if preferIP * option is set. * @return local host name or IP * @throws UnknownHostException */ public String getLocalHostOrIp() throws UnknownHostException { if (GiraphConstants.PREFER_IP_ADDRESSES.get(this)) { return InetAddress.getLocalHost().getHostAddress(); } return getLocalHostname(); }
/** * Create and start the Thrift server. * * @param conf Giraph conf to set the host and ports for. * @param services Services to start */ public ClientThriftServer(GiraphConfiguration conf, List<?> services) { checkNotNull(conf, "conf is null"); checkNotNull(services, "services is null"); ThriftServiceProcessor processor = new ThriftServiceProcessor(new ThriftCodecManager(), new ArrayList<ThriftEventHandler>(), services); clientThriftServer = new ThriftServer(processor, new ThriftServerConfig()); clientThriftServer.start(); try { CLIENT_THRIFT_SERVER_HOST.set( conf, conf.getLocalHostname()); } catch (UnknownHostException e) { throw new IllegalStateException("Unable to get host information", e); } CLIENT_THRIFT_SERVER_PORT.set(conf, clientThriftServer.getPort()); }