Ejemplo n.º 1
0
 /** Helper function to parse the configuration to decide which kind of config store to start */
 public static ConfigStore createConfigStore(FlumeConfiguration cfg) {
   ConfigStore cfgStore;
   if (cfg.getMasterStore().equals(ZK_CFG_STORE)) {
     cfgStore = new ZooKeeperConfigStore();
   } else if (cfg.getMasterStore().equals(MEMORY_CFG_STORE)) {
     if (cfg.getMasterIsDistributed()) {
       throw new IllegalStateException(
           "Can't use non-zookeeper store with " + "distributed Master");
     }
     cfgStore = new MemoryBackedConfigStore();
   } else {
     throw new IllegalArgumentException("Unsupported config store: " + cfg.getMasterStore());
   }
   return cfgStore;
 }
Ejemplo n.º 2
0
  /** Shutdown all the various servers. */
  public void shutdown() {
    try {
      if (http != null) {
        try {
          http.stop();
        } catch (Exception e) {
          LOG.error("Error stopping FlumeMaster", e);
        }
        http = null;
      }

      cmdman.stop();

      ackman.stop();

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

      if (controlServer != null) {
        controlServer.stop();
        controlServer = null;
      }
      /*
       * Close the reportserver which started.
       */
      if (cfg.getReportServerRPC() == cfg.RPC_TYPE_AVRO) {
        if (avroReportServer != null) {
          avroReportServer.stop();
          avroReportServer = null;
        }
      } else {
        if (thriftReportServer != null) {
          thriftReportServer.stop();
          thriftReportServer = null;
        }
      }
      specman.stop();

      reaper.interrupt();

      FlumeConfiguration cfg = FlumeConfiguration.get();
      if (cfg.getMasterStore().equals(ZK_CFG_STORE)) {
        ZooKeeperService.get().shutdown();
      }

    } catch (IOException e) {
      LOG.error("Exception when shutting down master!", e);
    } catch (Exception e) {
      LOG.error("Exception when shutting down master!", e);
    }
  }
Ejemplo n.º 3
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();
  }