Example usage for org.apache.hadoop.yarn.webapp WebApp getListenerAddress

List of usage examples for org.apache.hadoop.yarn.webapp WebApp getListenerAddress

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.webapp WebApp getListenerAddress.

Prototype

public InetSocketAddress getListenerAddress() 

Source Link

Document

Get the address the http server is bound to

Usage

From source file:com.datatorrent.stram.StreamingAppMasterService.java

License:Apache License

@Override
protected void serviceStart() throws Exception {
    super.serviceStart();
    if (UserGroupInformation.isSecurityEnabled()) {
        delegationTokenManager.startThreads();
    }//from   w  ww . j a  v  a 2s. c o m

    // write the connect address for containers to DFS
    InetSocketAddress connectAddress = NetUtils.getConnectAddress(this.heartbeatListener.getAddress());
    URI connectUri = new URI("stram", null, connectAddress.getHostName(), connectAddress.getPort(), null, null,
            null);
    FSRecoveryHandler recoveryHandler = new FSRecoveryHandler(dag.assertAppPath(), getConfig());
    recoveryHandler.writeConnectUri(connectUri.toString());

    // start web service
    try {
        org.mortbay.log.Log.setLog(null);
    } catch (Throwable throwable) {
        // SPOI-2687. As part of Pivotal Certification, we need to catch ClassNotFoundException as Pivotal was using Jetty 7 where as other distros are using Jetty 6.
        // LOG.error("can't set the log to null: ", throwable);
    }

    try {
        Configuration config = getConfig();
        if (UserGroupInformation.isSecurityEnabled()) {
            config = new Configuration(config);
            config.set("hadoop.http.filter.initializers", StramWSFilterInitializer.class.getCanonicalName());
        }
        WebApp webApp = WebApps.$for("stram", StramAppContext.class, appContext, "ws").with(config)
                .start(new StramWebApp(this.dnmgr));
        LOG.info("Started web service at port: " + webApp.port());
        this.appMasterTrackingUrl = NetUtils.getConnectAddress(webApp.getListenerAddress()).getHostName() + ":"
                + webApp.port();
        LOG.info("Setting tracking URL to: " + appMasterTrackingUrl);
    } catch (Exception e) {
        LOG.error("Webapps failed to start. Ignoring for now:", e);
    }
}