コード例 #1
0
  @SuppressWarnings("deprecation")
  @Before
  public void setupDependencies() throws Exception {
    if (null != _service_context) {
      return;
    }

    final String temp_dir = System.getProperty("java.io.tmpdir") + File.separator;

    // OK we're going to use guice, it was too painful doing this by hand...
    Config config =
        ConfigFactory.parseReader(
                new InputStreamReader(
                    this.getClass().getResourceAsStream("test_data_bucket_change.properties")))
            .withValue("globals.local_root_dir", ConfigValueFactory.fromAnyRef(temp_dir))
            .withValue("globals.local_cached_jar_dir", ConfigValueFactory.fromAnyRef(temp_dir))
            .withValue("globals.distributed_root_dir", ConfigValueFactory.fromAnyRef(temp_dir))
            .withValue("globals.local_yarn_config_dir", ConfigValueFactory.fromAnyRef(temp_dir));

    Injector app_injector = ModuleUtils.createTestInjector(Arrays.asList(), Optional.of(config));
    app_injector.injectMembers(this);

    _db_actor_context = new ManagementDbActorContext(_service_context, true);

    _actor_context =
        new DataImportActorContext(_service_context, new GeneralInformationService(), null); // TODO
    app_injector.injectMembers(_actor_context);

    // Have to do this in order for the underlying management db to live...
    _service_context.getCoreManagementDbService();
  }
コード例 #2
0
  /**
   * Initializes the storm instance
   *
   * @return a real storm controller if possible, else a no controller
   */
  @SuppressWarnings("unchecked")
  public static IStormController getController() {
    final GlobalPropertiesBean globals =
        Lambdas.get(
            () -> {
              try {
                return BeanTemplateUtils.from(
                    PropertiesUtils.getSubConfig(
                            ModuleUtils.getStaticConfig(), GlobalPropertiesBean.PROPERTIES_ROOT)
                        .orElse(null),
                    GlobalPropertiesBean.class);
              } catch (IOException e) {
                _logger.error(
                    ErrorUtils.getLongForm(
                        "Couldn't set globals property bean in storm harvest tech onInit: {0}", e));
                return null;
              }
            });
    if (null == globals) {
      return new NoStormController();
    }
    _logger.info(
        "Loading storm config from: "
            + globals.local_yarn_config_dir()
            + File.separator
            + "storm.yaml");
    Yaml yaml = new Yaml();
    InputStream input;
    Map<String, Object> object;
    try {
      input =
          new FileInputStream(
              new File(globals.local_yarn_config_dir() + File.separator + "storm.yaml"));
      object = (Map<String, Object>) yaml.load(input);
    } catch (FileNotFoundException e) {
      _logger.error(
          ErrorUtils.getLongForm("Error reading storm.yaml in storm harvest tech onInit: {0}", e));
      object = new HashMap<String, Object>();
    }

    if (object.containsKey(backtype.storm.Config.NIMBUS_HOST)) {
      _logger.info("starting in remote mode v5");
      _logger.info(object.get(backtype.storm.Config.NIMBUS_HOST));
      // run in distributed mode
      IStormController storm_controller =
          StormControllerUtil.getRemoteStormController(
              (String) object.get(backtype.storm.Config.NIMBUS_HOST),
              (int) object.get(backtype.storm.Config.NIMBUS_THRIFT_PORT),
              (String) object.get(backtype.storm.Config.STORM_THRIFT_TRANSPORT_PLUGIN));

      return storm_controller;
    } else {
      return new NoStormController();
    }
  }
コード例 #3
0
    @Override
    protected void configure() {
      final Config config = ModuleUtils.getStaticConfig();
      try {
        final DataImportConfigurationBean bean =
            BeanTemplateUtils.from(
                PropertiesUtils.getSubConfig(config, DataImportConfigurationBean.PROPERTIES_ROOT)
                    .orElse(null),
                DataImportConfigurationBean.class);
        this.bind(DataImportConfigurationBean.class).toInstance(bean);

        this.bind(AnalyticStateTriggerCheckFactory.class).in(Scopes.SINGLETON);
      } catch (Exception e) {
        throw new RuntimeException(
            ErrorUtils.get(
                ErrorUtils.INVALID_CONFIG_ERROR,
                DataImportConfigurationBean.class.toString(),
                config.getConfig(DataImportConfigurationBean.PROPERTIES_ROOT)),
            e);
      }
    }
コード例 #4
0
  /**
   * Entry point
   *
   * @param args - config_file source_key harvest_tech_id
   * @throws Exception
   */
  public static void main(final String[] args) {
    try {
      if (args.length < 1) {
        System.out.println("CLI: config_file");
        System.exit(-1);
      }
      System.out.println("Running with command line: " + Arrays.toString(args));
      final Config config = ConfigFactory.parseFile(new File(args[0]));

      final DataImportManagerModule app =
          ModuleUtils.initializeApplication(
              Arrays.asList(new Module()),
              Optional.of(config),
              Either.left(DataImportManagerModule.class));
      app.start();
    } catch (Throwable e) {
      _logger.error(ErrorUtils.getLongForm("Exception reached main(): {0}", e));
      try {
        e.printStackTrace();
      } catch (Exception e2) { // the exception failed!
      }
      System.exit(-1);
    }
  }