Exemple #1
0
  public void serve() throws IOException {
    if (cfg.getMasterStore().equals(ZK_CFG_STORE)) {
      try {
        ZooKeeperService.getAndInit(cfg);
      } catch (InterruptedException e) {
        throw new IOException("Unexpected interrupt when starting ZooKeeper", e);
      }
    }
    ReportManager.get().add(vmInfo);
    ReportManager.get().add(sysInfo);

    if (doHttp) {
      String webPath = FlumeNode.getWebPath(cfg);
      this.http =
          new StatusHttpServer("flumeconfig", webPath, "0.0.0.0", cfg.getMasterHttpPort(), false);
      http.addServlet(jerseyMasterServlet(), "/master/*");
      http.start();
    }

    controlServer = new MasterClientServer(this, FlumeConfiguration.get());
    configServer = new MasterAdminServer(this, FlumeConfiguration.get());
    /*
     * We instantiate both kinds of report servers below, but no resources are
     * allocated till we call serve() on them.
     */
    avroReportServer = new AvroReportServer(FlumeConfiguration.get().getReportServerPort());
    thriftReportServer = new ThriftReportServer(FlumeConfiguration.get().getReportServerPort());

    ReportManager.get().add(this);
    try {
      controlServer.serve();
      configServer.serve();
      /*
       * Start the Avro/Thrift ReportServer based on the flag set in the
       * configuration file.
       */
      if (cfg.getReportServerRPC() == cfg.RPC_TYPE_AVRO) {
        avroReportServer.serve();
      } else {
        thriftReportServer.serve();
      }
    } catch (TTransportException e1) {
      throw new IOException("Error starting control or config server", e1);
    }
    cmdman.start();
    ackman.start();
    specman.start();

    // TODO (jon) clean shutdown
    reaper =
        new Thread("Lost node reaper") {
          @Override
          public void run() {
            try {
              while (true) {
                Thread.sleep(FlumeConfiguration.get().getConfigHeartbeatPeriod());
                statman.checkup();
              }
            } catch (InterruptedException e) {
              LOG.error("Reaper thread unexpectedly interrupted:" + e.getMessage());
              LOG.debug("Lost node reaper unexpectedly interrupted", e);
            }
          }
        };

    reaper.start();
  }