예제 #1
0
  private void initializeMergerConfig() {
    if (coordinatorConfig == null) {
      coordinatorConfig = configFactory.build(IndexerCoordinatorConfig.class);
    }

    if (workerConfig == null) {
      workerConfig = configFactory.build(WorkerConfig.class);
    }
  }
  @Override
  public DBConfig get() {

    Properties props = new Properties();
    try {
      FileReader reader = new FileReader("Database.properties");
      props.load(reader);
    } catch (IOException io) {
    }
    ConfigurationObjectFactory c = new ConfigurationObjectFactory(props);
    return c.build(DBConfig.class);
  }
예제 #3
0
  public void init() throws Exception {
    initializeEmitter();
    initializeMonitors();
    initializeMergerConfig();
    initializeTaskToolbox();
    initializeJacksonInjections();
    initializeJacksonSubtypes();
    initializeCuratorFramework();
    initializeCuratorCoordinator();
    initializeTaskMonitor();
    initializeServer();

    final ScheduledExecutorFactory scheduledExecutorFactory =
        ScheduledExecutors.createFactory(lifecycle);
    final ScheduledExecutorService globalScheduledExec =
        scheduledExecutorFactory.create(1, "Global--%d");
    final MonitorScheduler monitorScheduler =
        new MonitorScheduler(
            configFactory.build(MonitorSchedulerConfig.class),
            globalScheduledExec,
            emitter,
            monitors);
    lifecycle.addManagedInstance(monitorScheduler);

    final Context root = new Context(server, "/", Context.SESSIONS);

    root.addServlet(new ServletHolder(new StatusServlet()), "/status");
    root.addServlet(new ServletHolder(new DefaultServlet()), "/mmx/*");
    root.addFilter(GuiceFilter.class, "/mmx/indexer/worker/v1/*", 0);
  }
예제 #4
0
 public void initializeCuratorCoordinator() {
   if (workerCuratorCoordinator == null) {
     workerCuratorCoordinator =
         new WorkerCuratorCoordinator(
             jsonMapper,
             configFactory.build(IndexerZkConfig.class),
             curatorFramework,
             new Worker(workerConfig));
     lifecycle.addManagedInstance(workerCuratorCoordinator);
   }
 }
예제 #5
0
 public void initializeTaskToolbox() throws S3ServiceException {
   if (taskToolbox == null) {
     final RestS3Service s3Client =
         new RestS3Service(
             new AWSCredentials(
                 PropUtils.getProperty(props, "com.metamx.aws.accessKey"),
                 PropUtils.getProperty(props, "com.metamx.aws.secretKey")));
     final SegmentPusher segmentPusher =
         new S3SegmentPusher(
             s3Client, configFactory.build(S3SegmentPusherConfig.class), jsonMapper);
     taskToolbox =
         new TaskToolbox(coordinatorConfig, emitter, s3Client, segmentPusher, jsonMapper);
   }
 }
예제 #6
0
  private void initializeServer() {
    if (server == null) {
      server = Initialization.makeJettyServer(configFactory.build(ServerConfig.class));

      lifecycle.addHandler(
          new Lifecycle.Handler() {
            @Override
            public void start() throws Exception {
              log.info("Starting Jetty");
              server.start();
            }

            @Override
            public void stop() {
              log.info("Stopping Jetty");
              try {
                server.stop();
              } catch (Exception e) {
                log.error(e, "Exception thrown while stopping Jetty");
              }
            }
          });
    }
  }
예제 #7
0
 public void initializeCuratorFramework() throws IOException {
   final CuratorConfig curatorConfig = configFactory.build(CuratorConfig.class);
   curatorFramework = Initialization.makeCuratorFrameworkClient(curatorConfig, lifecycle);
 }