List of usage examples for org.apache.hadoop.net NetUtils createSocketAddr
public static InetSocketAddress createSocketAddr(String target, int defaultPort)
From source file:tajo.worker.Worker.java
License:Apache License
private void prepareServing() throws IOException { defaultFS = FileSystem.get(URI.create(conf.getVar(ConfVars.ENGINE_BASE_DIR)), conf); localFS = FileSystem.getLocal(conf); Path workDirPath = new Path(workDir.toURI()); if (!localFS.exists(workDirPath)) { localFS.mkdirs(workDirPath);/*from w w w.ja v a2s. c o m*/ LOG.info("local temporal dir is created: " + localFS.exists(workDirPath)); LOG.info("local temporal dir (" + workDir + ") is created"); } String hostname = DNS.getDefaultHost(conf.get("nta.master.dns.interface", "default"), conf.get("nta.master.dns.nameserver", "default")); int port = this.conf.getIntVar(ConfVars.LEAFSERVER_PORT); // Creation of a HSA will force a resolve. InetSocketAddress initialIsa = new InetSocketAddress(hostname, port); if (initialIsa.getAddress() == null) { throw new IllegalArgumentException("Failed resolve of " + this.isa); } this.rpcServer = NettyRpc.getProtoParamRpcServer(this, AsyncWorkerProtocol.class, initialIsa); this.rpcServer.start(); // Set our address. this.isa = this.rpcServer.getBindAddress(); this.serverName = this.isa.getHostName() + ":" + this.isa.getPort(); this.zkClient = new ZkClient(this.conf); this.queryLauncher = new QueryLauncher(); this.queryLauncher.start(); this.queryEngine = new TQueryEngine(conf); this.retriever = new AdvancedDataRetriever(); this.dataServer = new HttpDataServer(NetUtils.createSocketAddr(hostname, 0), retriever); this.dataServer.start(); InetSocketAddress dataServerAddr = this.dataServer.getBindAddress(); this.dataServerURL = "http://" + dataServerAddr.getAddress().getHostAddress() + ":" + dataServerAddr.getPort(); LOG.info("dataserver listens on " + dataServerURL); this.workerContext = new WorkerContext(); Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownHook())); }