Java Code Examples for org.apache.hadoop.hdfs.server.namenode.StreamFile

The following examples show how to use org.apache.hadoop.hdfs.server.namenode.StreamFile. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: RDFS   Source File: DataNode.java    License: Apache License 2.0 5 votes vote down vote up
private void startInfoServer(Configuration conf) throws IOException {
  String infoAddr = 
    NetUtils.getServerAddress(conf, 
                            "dfs.datanode.info.bindAddress", 
                            "dfs.datanode.info.port",
                            "dfs.datanode.http.address");
  InetSocketAddress infoSocAddr = NetUtils.createSocketAddr(infoAddr);
  String infoHost = infoSocAddr.getHostName();
  int tmpInfoPort = infoSocAddr.getPort();
  this.infoServer = new HttpServer("datanode", infoHost, tmpInfoPort,
      tmpInfoPort == 0, conf);
  if (conf.getBoolean("dfs.https.enable", false)) {
    boolean needClientAuth = conf.getBoolean("dfs.https.need.client.auth", false);
    InetSocketAddress secInfoSocAddr = NetUtils.createSocketAddr(conf.get(
        "dfs.datanode.https.address", infoHost + ":" + 0));
    Configuration sslConf = new Configuration(false);
    sslConf.addResource(conf.get("dfs.https.server.keystore.resource",
        "ssl-server.xml"));
    this.infoServer.addSslListener(secInfoSocAddr, sslConf, needClientAuth);
    // assume same ssl port for all datanodes
    InetSocketAddress datanodeSslPort = NetUtils.createSocketAddr(conf.get(
        "dfs.datanode.https.address", infoHost + ":" + 50475));
    this.infoServer.setAttribute("datanode.https.port", datanodeSslPort
        .getPort());
  }
  this.infoServer.addInternalServlet(null, "/streamFile/*", StreamFile.class);
  this.infoServer.addInternalServlet(null, "/getFileChecksum/*",
      FileChecksumServlets.GetServlet.class);
  this.infoServer.setAttribute("datanode", this);
  this.infoServer.addServlet(null, "/blockScannerReport", 
                             DataBlockScannerSet.Servlet.class);

  this.infoServer.setAttribute(ReconfigurationServlet.CONF_SERVLET_RECONFIGURABLE_PREFIX +
  CONF_SERVLET_PATH, DataNode.this);
  this.infoServer.addServlet("dnConf", CONF_SERVLET_PATH, ReconfigurationServlet.class);
  this.infoServer.start();
}