Exemple #1
0
  /** This also implements the Apache Commons Daemon interface's start */
  public synchronized void start() {
    FlumeConfiguration conf = FlumeConfiguration.get();

    // the simple report interface
    simpleReportManager.add(vmInfo);
    simpleReportManager.add(sysInfo);
    simpleReportManager.add(
        new Reportable() {

          @Override
          public String getName() {
            return FlumeNode.this.getName();
          }

          @Override
          public ReportEvent getMetrics() {
            return FlumeNode.this.getReport();
          }

          @Override
          public Map<String, Reportable> getSubMetrics() {
            return ReportUtil.noChildren();
          }
        });

    // the full report interface
    ReportManager.get().add(vmInfo);
    ReportManager.get().add(sysInfo);
    ReportManager.get().add(this);

    if (startHttp) {
      int nodePort = conf.getNodeStatusPort();
      String bindAddress = "0.0.0.0";
      ContextCreator cc =
          new ContextCreator() {
            @Override
            public void addContexts(ContextHandlerCollection handlers) {
              handlers.addHandler(InternalHttpServer.createLogAppContext());
              handlers.addHandler(InternalHttpServer.createStackSevletContext());
              String webAppRoot = FlumeConfiguration.get().getNodeWebappRoot();
              InternalHttpServer.addHandlersFromPaths(handlers, new File(webAppRoot));
            }
          };
      http = InternalHttpServer.startFindPortHttpServer(cc, bindAddress, nodePort);
    }

    if (reportPusher != null) {
      reportPusher.start();
    }

    if (liveMan != null) {
      liveMan.start();
    }

    if (chokeMan != null) {
      // JVM exits if only daemons threads remain.
      chokeMan.setDaemon(true);
      chokeMan.start();
    }
  }
Exemple #2
0
  /** This also implements the Apache Commons Daemon interface's stop */
  public synchronized void stop() {
    if (this.http != null) {
      try {
        http.stop();
      } catch (Exception e) {
        LOG.error("Stopping http server failed: " + e);
      }
    }

    if (reportPusher != null) {
      reportPusher.stop();
    }

    if (liveMan != null) {
      liveMan.stop();
    }

    if (chokeMan != null) {
      chokeMan.halt();
    }
  }