src/main/java/org/apache/hadoop/hdfs/server/namenode/analytics/NameNodeAnalyticsHttpServer.java
public void start() throws IOException {
    final int nnaPort = nnaConf.getPort();

    String sslKeystorePath = nnaConf.getSslKeystorePath();
    String sslKeystorePassword = nnaConf.getSslKeystorePassword();
    if (sslKeystorePath == null && sslKeystorePassword == null) {
      LOG.info("Running web server in HTTP mode.");
      httpAddress = new InetSocketAddress(bindAddress.getAddress(), nnaPort);
    } else if (sslKeystorePath != null && sslKeystorePassword != null) {
      LOG.info("Running web server in HTTPS mode.");
      httpsAddress = new InetSocketAddress(bindAddress.getAddress(), nnaPort);
    } else {
      throw new IllegalStateException(
          "Illegal SSL configuration. Check config/application.properties file.");
    }

    if (conf == null) {
      conf = new Configuration();
      conf.set(DFSConfigKeys.DFS_HTTP_POLICY_KEY, "HTTP_ONLY");
    }

    HttpServer2.Builder builder =
        httpServerTemplateForNnAnalytics(
            conf,
            httpAddress,
            httpsAddress,
            "nna",
            DFSConfigKeys.DFS_NAMENODE_KERBEROS_INTERNAL_SPNEGO_PRINCIPAL_KEY,
            DFSConfigKeys.DFS_NAMENODE_KEYTAB_FILE_KEY);
    builder.keyPassword(sslKeystorePassword).keyStore(sslKeystorePath, sslKeystorePassword, "jks");

    httpServer = builder.build();

    // Main load of NNA classes and API into NNA Http Server.
    httpServer.getWebAppContext().setWar(nnaConf.getWebBaseDir());
    httpServer.getWebAppContext().setAttribute(NNA_NN_LOADER, nnLoader);
    httpServer.getWebAppContext().setAttribute(NNA_SECURITY_CONTEXT, secContext);
    httpServer.getWebAppContext().setAttribute(NNA_USAGE_METRICS, usageMetrics);
    httpServer.getWebAppContext().setAttribute(NNA_HSQL_DRIVER, hsqlDriver);
    httpServer.getWebAppContext().setAttribute(NNA_RUNNING_QUERIES, runningQueries);
    httpServer.getWebAppContext().setAttribute(NNA_RUNNING_OPERATIONS, runningOperations);
    httpServer.getWebAppContext().setAttribute(NNA_INTERNAL_SERVICE, internalService);
    httpServer.getWebAppContext().setAttribute(NNA_OPERATION_SERVICE, operationService);
    httpServer.getWebAppContext().setAttribute(NNA_QUERY_LOCK, queryLock);
    httpServer.getWebAppContext().setAttribute(NNA_SAVING_NAMESPACE, savingNamespace);
    httpServer.getWebAppContext().setAttribute(NNA_CANCEL_REQUEST, cancelRequest);
    httpServer.getWebAppContext().setAttribute(NNA_APP_CONF, nnaConf);
    httpServer.getWebAppContext().setAttribute(NNA_HADOOP_CONF, conf);

    // NNA Rest API hosted at /* and web-pages served from /* as well.
    httpServer.addJerseyResourcePackage(
        NamenodeAnalyticsMethods.class.getPackage().getName(), "/*");

    httpServer.start();

    LOG.info("NNA is up and servicing at port: " + nnaPort);
  }
/**
   * @see DFSUtil#getHttpPolicy(org.apache.hadoop.conf.Configuration) for information related to the
   *     different configuration options and Http Policy is decided.
   */
@see DFSUtil#getHttpPolicy(org.apache.hadoop.conf.Configuration) for information related to the
different configuration options and Http Policy is decided.
@see DFSUtil#getHttpPolicy ( org . apache . hadoop . conf . Configuration ) for information related to the different configuration options and Http Policy is decided .
public void start() throws IOException {
    final int nnaPort = nnaConf.getPort();
    String sslKeystorePath = nnaConf.getSslKeystorePath();
    String sslKeystorePassword = nnaConf.getSslKeystorePassword();
    if (sslKeystorePath == null && sslKeystorePassword == null) {
      LOG.info("Running web server in HTTP mode.");
      httpAddress = new InetSocketAddress(bindAddress.getAddress(), nnaPort);
    } else if (sslKeystorePath != null && sslKeystorePassword != null) {
      LOG.info("Running web server in HTTPS mode.");
      httpsAddress = new InetSocketAddress(bindAddress.getAddress(), nnaPort);
    } else {
      throw new IllegalStateException(
          "Illegal SSL configuration. Check config/application.properties file.");
    }
    if (conf == null) {
      conf = new Configuration();
      conf.set(DFSConfigKeys.DFS_HTTP_POLICY_KEY, "HTTP_ONLY");
    }
    HttpServer2.Builder builder =
        httpServerTemplateForNnAnalytics(
            conf,
            httpAddress,
            httpsAddress,
            "nna",
            DFSConfigKeys.DFS_NAMENODE_KERBEROS_INTERNAL_SPNEGO_PRINCIPAL_KEY,
            DFSConfigKeys.DFS_NAMENODE_KEYTAB_FILE_KEY);
    builder.keyPassword(sslKeystorePassword).keyStore(sslKeystorePath, sslKeystorePassword, "jks");
    httpServer = builder.build();
    httpServer.getWebAppContext().setWar(nnaConf.getWebBaseDir());
    httpServer.getWebAppContext().setAttribute(NNA_NN_LOADER, nnLoader);
    httpServer.getWebAppContext().setAttribute(NNA_SECURITY_CONTEXT, secContext);
    httpServer.getWebAppContext().setAttribute(NNA_USAGE_METRICS, usageMetrics);
    httpServer.getWebAppContext().setAttribute(NNA_HSQL_DRIVER, hsqlDriver);
    httpServer.getWebAppContext().setAttribute(NNA_RUNNING_QUERIES, runningQueries);
    httpServer.getWebAppContext().setAttribute(NNA_RUNNING_OPERATIONS, runningOperations);
    httpServer.getWebAppContext().setAttribute(NNA_INTERNAL_SERVICE, internalService);
    httpServer.getWebAppContext().setAttribute(NNA_OPERATION_SERVICE, operationService);
    httpServer.getWebAppContext().setAttribute(NNA_QUERY_LOCK, queryLock);
    httpServer.getWebAppContext().setAttribute(NNA_SAVING_NAMESPACE, savingNamespace);
    httpServer.getWebAppContext().setAttribute(NNA_CANCEL_REQUEST, cancelRequest);
    httpServer.getWebAppContext().setAttribute(NNA_APP_CONF, nnaConf);
    httpServer.getWebAppContext().setAttribute(NNA_HADOOP_CONF, conf);
    httpServer.addJerseyResourcePackage(
        NamenodeAnalyticsMethods.class.getPackage().getName(), "/*");
    httpServer.start();
    LOG.info("NNA is up and servicing at port: " + nnaPort);
  }
public void start ( ) throws IOException { final int nnaPort = nnaConf . getPort ( ) ; String sslKeystorePath = nnaConf . getSslKeystorePath ( ) ; String sslKeystorePassword = nnaConf . getSslKeystorePassword ( ) ; if ( sslKeystorePath == null && sslKeystorePassword == null ) { LOG . info ( "Running web server in HTTP mode." ) ; httpAddress = new InetSocketAddress ( bindAddress . getAddress ( ) , nnaPort ) ; } else if ( sslKeystorePath != null && sslKeystorePassword != null ) { LOG . info ( "Running web server in HTTPS mode." ) ; httpsAddress = new InetSocketAddress ( bindAddress . getAddress ( ) , nnaPort ) ; } else { throw new IllegalStateException ( "Illegal SSL configuration. Check config/application.properties file." ) ; } if ( conf == null ) { conf = new Configuration ( ) ; conf . set ( DFSConfigKeys . DFS_HTTP_POLICY_KEY , "HTTP_ONLY" ) ; } HttpServer2 . Builder builder = httpServerTemplateForNnAnalytics ( conf , httpAddress , httpsAddress , "nna" , DFSConfigKeys . DFS_NAMENODE_KERBEROS_INTERNAL_SPNEGO_PRINCIPAL_KEY , DFSConfigKeys . DFS_NAMENODE_KEYTAB_FILE_KEY ) ; builder . keyPassword ( sslKeystorePassword ) . keyStore ( sslKeystorePath , sslKeystorePassword , "jks" ) ; httpServer = builder . build ( ) ; httpServer . getWebAppContext ( ) . setWar ( nnaConf . getWebBaseDir ( ) ) ; httpServer . getWebAppContext ( ) . setAttribute ( NNA_NN_LOADER , nnLoader ) ; httpServer . getWebAppContext ( ) . setAttribute ( NNA_SECURITY_CONTEXT , secContext ) ; httpServer . getWebAppContext ( ) . setAttribute ( NNA_USAGE_METRICS , usageMetrics ) ; httpServer . getWebAppContext ( ) . setAttribute ( NNA_HSQL_DRIVER , hsqlDriver ) ; httpServer . getWebAppContext ( ) . setAttribute ( NNA_RUNNING_QUERIES , runningQueries ) ; httpServer . getWebAppContext ( ) . setAttribute ( NNA_RUNNING_OPERATIONS , runningOperations ) ; httpServer . getWebAppContext ( ) . setAttribute ( NNA_INTERNAL_SERVICE , internalService ) ; httpServer . getWebAppContext ( ) . setAttribute ( NNA_OPERATION_SERVICE , operationService ) ; httpServer . getWebAppContext ( ) . setAttribute ( NNA_QUERY_LOCK , queryLock ) ; httpServer . getWebAppContext ( ) . setAttribute ( NNA_SAVING_NAMESPACE , savingNamespace ) ; httpServer . getWebAppContext ( ) . setAttribute ( NNA_CANCEL_REQUEST , cancelRequest ) ; httpServer . getWebAppContext ( ) . setAttribute ( NNA_APP_CONF , nnaConf ) ; httpServer . getWebAppContext ( ) . setAttribute ( NNA_HADOOP_CONF , conf ) ; httpServer . addJerseyResourcePackage ( NamenodeAnalyticsMethods . class . getPackage ( ) . getName ( ) , "/*" ) ; httpServer . start ( ) ; LOG . info ( "NNA is up and servicing at port: " + nnaPort ) ; }
@see DFSUtil#getHttpPolicy(org.apache.hadoop.conf.Configuration) for information related to the
     different configuration options and Http Policy is decided.
@see DFSUtil#getHttpPolicy ( org . apache . hadoop . conf . Configuration ) for information related to the different configuration options and Http Policy is decided .
// Main load of NNA classes and API into NNA Http Server. // NNA Rest API hosted at /* and web-pages served from /* as well.