Package org.apache.hadoop.http

Examples of org.apache.hadoop.http.HttpServer$StackServlet


    LOG.info("Starting web server as: "+ SecurityUtil.getServerPrincipal(conf
        .get(DFS_JOURNALNODE_INTERNAL_SPNEGO_USER_NAME_KEY),
        bindAddr.getHostName()));

    int tmpInfoPort = bindAddr.getPort();
    httpServer = new HttpServer("journal", bindAddr.getHostName(),
        tmpInfoPort, tmpInfoPort == 0, conf, new AccessControlList(conf
            .get(DFS_ADMIN, " "))) {
      {
        if (UserGroupInformation.isSecurityEnabled()) {
          initSpnego(conf, DFS_JOURNALNODE_INTERNAL_SPNEGO_USER_NAME_KEY,
View Full Code Here


    // create a servlet to serve full-file content
    InetSocketAddress infoSocAddr = DataNode.getInfoAddr(conf);
    String infoHost = infoSocAddr.getHostName();
    int tmpInfoPort = infoSocAddr.getPort();
    this.infoServer = (secureResources == null)
       ? new HttpServer("datanode", infoHost, tmpInfoPort, tmpInfoPort == 0,
           conf, new AccessControlList(conf.get(DFS_ADMIN, " ")))
       : new HttpServer("datanode", infoHost, tmpInfoPort, tmpInfoPort == 0,
           conf, new AccessControlList(conf.get(DFS_ADMIN, " ")),
           secureResources.getListener());

    LOG.info("Opened info server at " + infoHost + ":" + tmpInfoPort);
    if (conf.getBoolean(DFS_HTTPS_ENABLE_KEY, false)) {
View Full Code Here

 
  public void start() throws IOException {
    final String infoHost = bindAddress.getHostName();
    int infoPort = bindAddress.getPort();

    httpServer = new HttpServer("hdfs", infoHost, infoPort,
                                infoPort == 0, conf,
                                new AccessControlList(conf.get(DFS_ADMIN, " "))) {
      {
        // Add SPNEGO support to NameNode
        if (UserGroupInformation.isSecurityEnabled()) {
View Full Code Here

  }

  @Test
  public void testNotificationOnLastRetryNormalShutdown() throws Exception {
    HttpServer server = startHttpServer();
    // Act like it is the second attempt. Default max attempts is 2
    MRApp app = spy(new MRAppWithCustomContainerAllocator(
        2, 2, true, this.getClass().getName(), true, 2, true));
    doNothing().when(app).sysexit();
    Configuration conf = new Configuration();
    conf.set(JobContext.MR_JOB_END_NOTIFICATION_URL,
        JobEndServlet.baseUrl + "jobend?jobid=$jobId&status=$jobStatus");
    JobImpl job = (JobImpl)app.submit(conf);
    app.waitForInternalState(job, JobStateInternal.SUCCEEDED);
    // Unregistration succeeds: successfullyUnregistered is set
    app.shutDownJob();
    Assert.assertEquals(true, app.isLastAMRetry());
    Assert.assertEquals(1, JobEndServlet.calledTimes);
    Assert.assertEquals("jobid=" + job.getID() + "&status=SUCCEEDED",
        JobEndServlet.requestUri.getQuery());
    Assert.assertEquals(JobState.SUCCEEDED.toString(),
      JobEndServlet.foundJobState);
    server.stop();
  }
View Full Code Here

  }

  @Test
  public void testAbsentNotificationOnNotLastRetryUnregistrationFailure()
      throws Exception {
    HttpServer server = startHttpServer();
    MRApp app = spy(new MRAppWithCustomContainerAllocator(2, 2, false,
        this.getClass().getName(), true, 1, false));
    doNothing().when(app).sysexit();
    Configuration conf = new Configuration();
    conf.set(JobContext.MR_JOB_END_NOTIFICATION_URL,
        JobEndServlet.baseUrl + "jobend?jobid=$jobId&status=$jobStatus");
    JobImpl job = (JobImpl)app.submit(conf);
    app.waitForState(job, JobState.RUNNING);
    app.getContext().getEventHandler()
      .handle(new JobEvent(app.getJobId(), JobEventType.JOB_AM_REBOOT));
    app.waitForInternalState(job, JobStateInternal.REBOOT);
    // Now shutdown.
    // Unregistration fails: isLastAMRetry is recalculated, this is not
    app.shutDownJob();
    // Not the last AM attempt. So user should that the job is still running.
    app.waitForState(job, JobState.RUNNING);
    Assert.assertEquals(false, app.isLastAMRetry());
    Assert.assertEquals(0, JobEndServlet.calledTimes);
    Assert.assertEquals(null, JobEndServlet.requestUri);
    Assert.assertEquals(null, JobEndServlet.foundJobState);
    server.stop();
  }
View Full Code Here

  }

  @Test
  public void testNotificationOnLastRetryUnregistrationFailure()
      throws Exception {
    HttpServer server = startHttpServer();
    MRApp app = spy(new MRAppWithCustomContainerAllocator(2, 2, false,
        this.getClass().getName(), true, 2, false));
    doNothing().when(app).sysexit();
    Configuration conf = new Configuration();
    conf.set(JobContext.MR_JOB_END_NOTIFICATION_URL,
        JobEndServlet.baseUrl + "jobend?jobid=$jobId&status=$jobStatus");
    JobImpl job = (JobImpl)app.submit(conf);
    app.waitForState(job, JobState.RUNNING);
    app.getContext().getEventHandler()
      .handle(new JobEvent(app.getJobId(), JobEventType.JOB_AM_REBOOT));
    app.waitForInternalState(job, JobStateInternal.REBOOT);
    // Now shutdown. User should see FAILED state.
    // Unregistration fails: isLastAMRetry is recalculated, this is
    app.shutDownJob();
    Assert.assertEquals(true, app.isLastAMRetry());
    Assert.assertEquals(1, JobEndServlet.calledTimes);
    Assert.assertEquals("jobid=" + job.getID() + "&status=FAILED",
        JobEndServlet.requestUri.getQuery());
    Assert.assertEquals(JobState.FAILED.toString(),
      JobEndServlet.foundJobState);
    server.stop();
  }
View Full Code Here

  }

  private static HttpServer startHttpServer() throws Exception {
    new File(System.getProperty(
        "build.webapps", "build/webapps") + "/test").mkdirs();
    HttpServer server = new HttpServer("test", "0.0.0.0", 0, true);
    server.addServlet("jobend", "/jobend", JobEndServlet.class);
    server.start();

    JobEndServlet.calledTimes = 0;
    JobEndServlet.requestUri = null;
    JobEndServlet.baseUrl = "http://localhost:" + server.getPort() + "/";
    JobEndServlet.foundJobState = null;
    return server;
  }
View Full Code Here

          } else {
            LOG.error("dev mode does NOT work with ephemeral port!");
            System.exit(1);
          }
        }
        HttpServer server =
            new HttpServer(name, bindAddress, port, findPort, conf,
                new AdminACLsManager(conf).getAdminAcl(), null,
                pathList.toArray(new String[0])) {

              {
                if (UserGroupInformation.isSecurityEnabled()) {
                  boolean initSpnego = true;
                  if (spnegoPrincipalKey == null
                      || conf.get(spnegoPrincipalKey, "").isEmpty()) {
                    LOG.warn("Principal for spnego filter is not set");
                    initSpnego = false;
                  }
                  if (spnegoKeytabKey == null
                      || conf.get(spnegoKeytabKey, "").isEmpty()) {
                    LOG.warn("Keytab for spnego filter is not set");
                    initSpnego = false;
                  }
                  if (initSpnego) {
                    LOG.info("Initializing spnego filter with principal key : "
                        + spnegoPrincipalKey + " keytab key : "
                        + spnegoKeytabKey);
                    initSpnego(conf, spnegoPrincipalKey, spnegoKeytabKey);
                  }
                }
              }
            };
        for(ServletStruct struct: servlets) {
          server.addServlet(struct.name, struct.spec, struct.clazz);
        }
        for(Map.Entry<String, Object> entry : attributes.entrySet()) {
          server.setAttribute(entry.getKey(), entry.getValue());
        }
        server.defineFilter(server.getWebAppContext(), "guice",
          GuiceFilter.class.getName(), null, new String[] { "/*" });

        webapp.setConf(conf);
        webapp.setHttpServer(server);
        server.start();
        LOG.info("Web app /"+ name +" started at "+ server.getPort());
      } catch (ClassNotFoundException e) {
        throw new WebAppException("Error starting http server", e);
      } catch (IOException e) {
        throw new WebAppException("Error starting http server", e);
      }
View Full Code Here

  }
 
  @Override
  protected void serviceStart() throws Exception {
    try {
      proxyServer = new HttpServer("proxy", bindAddress, port,
          port == 0, getConfig(), acl);
      proxyServer.addServlet(ProxyUriUtils.PROXY_SERVLET_NAME,
          ProxyUriUtils.PROXY_PATH_SPEC, WebAppProxyServlet.class);
      proxyServer.setAttribute(FETCHER_ATTRIBUTE, fetcher);
      proxyServer.setAttribute(IS_SECURITY_ENABLED_ATTRIBUTE, isSecurityEnabled);
View Full Code Here

  }
 
  @Override
  public void start() {
    try {
      proxyServer = new HttpServer("proxy", bindAddress, port,
          port == 0, getConfig(), acl);
      proxyServer.addServlet(ProxyUriUtils.PROXY_SERVLET_NAME,
          ProxyUriUtils.PROXY_PATH_SPEC, WebAppProxyServlet.class);
      proxyServer.setAttribute(FETCHER_ATTRIBUTE, fetcher);
      proxyServer.setAttribute(IS_SECURITY_ENABLED_ATTRIBUTE, isSecurityEnabled);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.http.HttpServer$StackServlet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.