public Sample(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.probability = getConfigs().getDouble(config, "probability", 1.0); if (probability < 0.0) { throw new MorphlineCompilationException("Probability must not be negative: " + probability, config); } if (probability >= 1.0) { this.prng = null; } else { if (config.hasPath("seed")) { long seed = getConfigs().getLong(config, "seed"); this.prng = new Well19937c(seed); // non-secure & fast } else { Random rand = new SecureRandom(); int[] seed = new int[624]; for (int i = 0; i < seed.length; i++) { seed[i] = rand.nextInt(); } this.prng = new Well19937c(seed); // non-secure & fast } } validateArguments(); }
public Sample(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.probability = getConfigs().getDouble(config, "probability", 1.0); if (probability < 0.0) { throw new MorphlineCompilationException("Probability must not be negative: " + probability, config); } if (probability >= 1.0) { this.prng = null; } else { if (config.hasPath("seed")) { long seed = getConfigs().getLong(config, "seed"); this.prng = new Well19937c(seed); // non-secure & fast } else { Random rand = new SecureRandom(); int[] seed = new int[624]; for (int i = 0; i < seed.length; i++) { seed[i] = rand.nextInt(); } this.prng = new Well19937c(seed); // non-secure & fast } } validateArguments(); }
public LoadSolr(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); Config solrLocatorConfig = getConfigs().getConfig(config, SOLR_LOCATOR_PARAM); SolrLocator locator = new SolrLocator(solrLocatorConfig, context); LOG.debug("solrLocator: {}", locator); RetryPolicyFactory retryPolicyFactory = parseRetryPolicyFactory( getConfigs().getConfig(config, "retryPolicy", null)); this.loader = locator.getLoader(retryPolicyFactory, new CodahaleMetricsFacade(context.getMetricRegistry())); Config boostsConfig = getConfigs().getConfig(config, "boosts", ConfigFactory.empty()); for (Map.Entry<String, Object> entry : new Configs().getEntrySet(boostsConfig)) { String fieldName = entry.getKey(); float boost = Float.parseFloat(entry.getValue().toString().trim()); boosts.put(fieldName, boost); } this.rateLimiter = RateLimiter.create(getConfigs().getDouble(config, "maxRecordsPerSecond", Double.MAX_VALUE)); this.isDryRun = context.getTypedSettings().getBoolean(TypedSettings.DRY_RUN_SETTING_NAME, false); validateArguments(); this.elapsedTime = getTimer(Metrics.ELAPSED_TIME); }