/** * Compose a "host:port" string from the address. */ public static String getHostPortString(InetSocketAddress addr) { return getHostPortString(addr.getHostName(), addr.getPort()); }
public static String normalizeInetSocketAddress(InetSocketAddress addr) { return getHostPortString(addr.getAddress().getHostAddress(), addr.getPort()); }
public static String getTajoMasterHttpAddr(Configuration config) { try { TajoConf conf = TUtil.checkTypeAndGet(config, TajoConf.class); return NetUtils.getHostPortString(conf.getSocketAddrVar( ConfVars.TAJO_MASTER_INFO_ADDRESS, ConfVars.TAJO_MASTER_UMBILICAL_RPC_ADDRESS)); } catch (Exception e) { e.printStackTrace(); return e.getMessage(); } }
private int initWebServer() { InetSocketAddress address = systemConf.getSocketAddrVar(ConfVars.WORKER_INFO_ADDRESS); try { webServer = StaticHttpServer.getInstance(this, "worker", address.getHostName(), address.getPort(), true, null, systemConf, null); webServer.start(); systemConf.setVar(TajoConf.ConfVars.WORKER_INFO_ADDRESS, NetUtils.getHostPortString( NetUtils.getConnectAddress(new InetSocketAddress(address.getHostName(), webServer.getPort())))); LOG.info("Worker info server started:" + webServer.getPort()); } catch (IOException e) { LOG.error(e.getMessage(), e); } return webServer.getPort(); }
return; } else if (hostName != null && port != null) { tajoConf.setVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS, NetUtils.getHostPortString(hostName, port));
return; } else if (hostName != null && port != null) { tajoConf.setVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS, NetUtils.getHostPortString(hostName, port));
@Override public void serviceInit(Configuration conf) throws Exception { TajoConf tajoConf = TUtil.checkTypeAndGet(conf, TajoConf.class); try { // Setup RPC server InetSocketAddress initIsa = tajoConf.getSocketAddrVar(TajoConf.ConfVars.WORKER_PEER_RPC_ADDRESS); if (initIsa.getAddress() == null) { throw new IllegalArgumentException("Failed resolve of " + initIsa); } int workerNum = tajoConf.getIntVar(TajoConf.ConfVars.WORKER_RPC_SERVER_WORKER_THREAD_NUM); this.rpcServer = new AsyncRpcServer(TajoWorkerProtocol.class, this, initIsa, workerNum); this.rpcServer.start(); this.bindAddr = NetUtils.getConnectAddress(rpcServer.getListenAddress()); } catch (Exception e) { LOG.error(e.getMessage(), e); } // Get the master address LOG.info("TajoWorkerManagerService is bind to " + bindAddr); tajoConf.setVar(TajoConf.ConfVars.WORKER_PEER_RPC_ADDRESS, NetUtils.getHostPortString(bindAddr)); super.serviceInit(tajoConf); }
System.exit(-1); } else if (hostName != null && port != null) { conf.setVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS, NetUtils.getHostPortString(hostName, port)); client = new TajoClientImpl(ServiceTrackerFactory.get(conf)); } else {
@Override public void serviceInit(Configuration conf) throws Exception { TajoConf tajoConf = TUtil.checkTypeAndGet(conf, TajoConf.class); this.serviceHandler = new TajoWorkerClientProtocolServiceHandler(); // init RPC Server in constructor cause Heartbeat Thread use bindAddr try { InetSocketAddress initIsa = tajoConf.getSocketAddrVar(TajoConf.ConfVars.WORKER_CLIENT_RPC_ADDRESS); if (initIsa.getAddress() == null) { throw new IllegalArgumentException("Failed resolve of " + initIsa); } int workerNum = tajoConf.getIntVar(TajoConf.ConfVars.WORKER_SERVICE_RPC_SERVER_WORKER_THREAD_NUM); this.rpcServer = new BlockingRpcServer(QueryMasterClientProtocol.class, serviceHandler, initIsa, workerNum); this.rpcServer.start(); this.bindAddr = NetUtils.getConnectAddress(rpcServer.getListenAddress()); } catch (Exception e) { LOG.error(e.getMessage(), e); } // Get the master address LOG.info(TajoWorkerClientService.class.getSimpleName() + " is bind to " + bindAddr); tajoConf.setVar(TajoConf.ConfVars.WORKER_CLIENT_RPC_ADDRESS, NetUtils.getHostPortString(bindAddr)); super.serviceInit(tajoConf); }
return; } else if (hostName != null && port != null) { tajoConf.setVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS, NetUtils.getHostPortString(hostName, port)); tajoClient = new TajoClientImpl(ServiceTrackerFactory.get(tajoConf)); } else if (hostName == null && port == null) {
@Override public void serviceStart() throws Exception { // start the rpc server InetSocketAddress initIsa = conf.getSocketAddrVar(ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS); int workerNum = conf.getIntVar(ConfVars.MASTER_SERVICE_RPC_SERVER_WORKER_THREAD_NUM); server = new BlockingRpcServer(TajoMasterClientProtocol.class, clientHandler, initIsa, workerNum); server.start(); bindAddress = NetUtils.getConnectAddress(server.getListenAddress()); this.conf.setVar(ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS, NetUtils.getHostPortString(bindAddress)); super.serviceStart(); LOG.info("Instantiated TajoMasterClientService at " + this.bindAddress); }
throw new RuntimeException("cannot find valid Tajo server address"); } else if (hostName != null && port != null) { conf.setVar(ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS, NetUtils.getHostPortString(hostName, port)); client = new TajoClientImpl(ServiceTrackerFactory.get(conf), baseDatabase, actualConnParams); } else if (hostName == null && port == null) {
@Override public void serviceStart() throws Exception { InetSocketAddress initIsa = conf.getSocketAddrVar(ConfVars.CATALOG_ADDRESS); int workerNum = conf.getIntVar(ConfVars.CATALOG_RPC_SERVER_WORKER_THREAD_NUM); try { this.rpcServer = new BlockingRpcServer(CatalogProtocol.class, handler, initIsa, workerNum); this.rpcServer.start(); this.bindAddress = NetUtils.getConnectAddress(this.rpcServer.getListenAddress()); conf.setVar(ConfVars.CATALOG_ADDRESS, NetUtils.getHostPortString(bindAddress)); } catch (Exception e) { LOG.error("CatalogServer startup failed", e); throw new TajoInternalError(e); } LOG.info("Catalog Server startup (" + bindAddress + ")"); super.serviceStart(); }
@Override public void serviceInit(Configuration conf) throws Exception { TajoConf tajoConf = TUtil.checkTypeAndGet(conf, TajoConf.class); // Setup RPC server InetSocketAddress initIsa = tajoConf.getSocketAddrVar(TajoConf.ConfVars.WORKER_QM_RPC_ADDRESS); if (initIsa.getAddress() == null) { throw new IllegalArgumentException("Failed resolve of " + initIsa); } int workerNum = tajoConf.getIntVar(TajoConf.ConfVars.QUERY_MASTER_RPC_SERVER_WORKER_THREAD_NUM); this.rpcServer = new AsyncRpcServer(QueryMasterProtocol.class, this, initIsa, workerNum); this.rpcServer.start(); this.bindAddr = NetUtils.getConnectAddress(rpcServer.getListenAddress()); this.queryMaster = new QueryMaster(workerContext); addService(queryMaster); // Get the master address LOG.info("QueryMasterManagerService is bind to " + bindAddr); tajoConf.setVar(TajoConf.ConfVars.WORKER_QM_RPC_ADDRESS, NetUtils.getHostPortString(bindAddr)); super.serviceInit(tajoConf); }
@Override public void serviceInit(Configuration conf) throws Exception { TajoConf systemConf = TUtil.checkTypeAndGet(conf, TajoConf.class); activeInterval = systemConf.getIntVar(TajoConf.ConfVars.WORKER_HEARTBEAT_ACTIVE_INTERVAL); InetSocketAddress initIsa = systemConf.getSocketAddrVar(TajoConf.ConfVars.RESOURCE_TRACKER_RPC_ADDRESS); int workerNum = systemConf.getIntVar(TajoConf.ConfVars.MASTER_RPC_SERVER_WORKER_THREAD_NUM); server = new AsyncRpcServer(TajoResourceTrackerProtocol.class, this, initIsa, workerNum); server.start(); bindAddress = NetUtils.getConnectAddress(server.getListenAddress()); // Set actual bind address to the systemConf systemConf.setVar(TajoConf.ConfVars.RESOURCE_TRACKER_RPC_ADDRESS, NetUtils.getHostPortString(bindAddress)); LOG.info("TajoResourceTracker starts up (" + this.bindAddress + ")"); super.serviceInit(conf); }
@Override public void serviceStart() throws Exception { LOG.info("TajoMaster is starting up"); startJvmPauseMonitor(); // check base tablespace and databases checkBaseTBSpaceAndDatabase(); super.serviceStart(); initSystemMetrics(); // Setting the system global configs systemConf.setVar(ConfVars.CATALOG_ADDRESS, NetUtils.getHostPortString(catalogServer.getBindAddress())); try { writeSystemConf(); } catch (IOException e) { LOG.error(e.getMessage(), e); } initWebServer(); haService = ServiceTrackerFactory.get(systemConf); haService.register(); historyWriter = new HistoryWriter(getMasterName(), true); historyWriter.init(getConfig()); addIfService(historyWriter); historyWriter.start(); historyReader = new HistoryReader(getMasterName(), context.getConf()); }
this.conf.setVar(ConfVars.TAJO_MASTER_UMBILICAL_RPC_ADDRESS, NetUtils.getHostPortString(tajoMasterAddress)); this.conf.setVar(ConfVars.RESOURCE_TRACKER_RPC_ADDRESS, c.getVar(ConfVars.RESOURCE_TRACKER_RPC_ADDRESS)); this.conf.setVar(ConfVars.CATALOG_ADDRESS, c.getVar(ConfVars.CATALOG_ADDRESS)); this.conf.setVar(ConfVars.REST_SERVICE_ADDRESS, NetUtils.getHostPortString(tajoRestAddress));