Exemple #1
0
    public WorkerNode build() {
      if (jsonMapper == null) {
        jsonMapper = new DefaultObjectMapper();
      }

      if (lifecycle == null) {
        lifecycle = new Lifecycle();
      }

      if (props == null) {
        props = Initialization.loadProperties();
      }

      if (configFactory == null) {
        configFactory = Config.createFactory(props);
      }

      return new WorkerNode(jsonMapper, lifecycle, props, configFactory);
    }
Exemple #2
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");
              }
            }
          });
    }
  }
Exemple #3
0
 public void initializeCuratorFramework() throws IOException {
   final CuratorConfig curatorConfig = configFactory.build(CuratorConfig.class);
   curatorFramework = Initialization.makeCuratorFrameworkClient(curatorConfig, lifecycle);
 }