public Charset getCharset(Config config, String path, Charset defaults) { String charsetName = getString(config, path, defaults == null ? null : defaults.name()); Charset charset = charsetName == null ? null : Charset.forName(charsetName); return charset; }
public LogCommand(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.format = getConfigs().getString(config, "format"); List<String> argList = getConfigs().getStringList(config, "args", Collections.<String>emptyList()); this.expressions = new FieldExpression[argList.size()]; for (int i = 0; i < argList.size(); i++) { this.expressions[i] = new FieldExpression(argList.get(i), getConfig()); } validateArguments(); }
public Charset getCharset(Config config, String path, Charset defaults) { String charsetName = getString(config, path, defaults == null ? null : defaults.name()); Charset charset = charsetName == null ? null : Charset.forName(charsetName); return charset; }
public ReadJsonTestTweets(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.isLengthDelimited = getConfigs().getBoolean(config, "isLengthDelimited", true); this.idPrefix = getConfigs().getString(config, "idPrefix", null); if ("random".equals(idPrefix)) { idPrefix = String.valueOf(new Random().nextInt()); } else if (idPrefix == null) { idPrefix = ""; } validateArguments(); }
public ReadBlob(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.outputFieldName = getConfigs().getString(config, "outputField", Fields.ATTACHMENT_BODY); validateArguments(); }
public ExtractAvroTree(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.outputFieldPrefix = getConfigs().getString(config, "outputFieldPrefix", ""); validateArguments(); }
public SanitizeUnknownSolrFields(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); Config solrLocatorConfig = getConfigs().getConfig(config, "solrLocator"); SolrLocator locator = new SolrLocator(solrLocatorConfig, context); LOG.debug("solrLocator: {}", locator); this.schema = locator.getIndexSchema(); Preconditions.checkNotNull(schema); LOG.trace("Solr schema: \n{}", Joiner.on("\n").join(new TreeMap(schema.getFields()).values())); String str = getConfigs().getString(config, "renameToPrefix", "").trim(); this.renameToPrefix = str.length() > 0 ? str : null; validateArguments(); }
public GeoIP(CommandBuilder builder, Config config, Command parent, Command child, final MorphlineContext context) { super(builder, config, parent, child, context); this.inputFieldName = getConfigs().getString(config, "inputField"); this.databaseFile = new File(getConfigs().getString(config, "database", "GeoLite2-City.mmdb")); try { this.databaseReader = new Reader(databaseFile); } catch (IOException e) { throw new MorphlineCompilationException("Cannot read Maxmind database: " + databaseFile, config, e); } validateArguments(); }
public ExtractURIComponents(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.inputFieldName = getConfigs().getString(config, "inputField"); this.outputFieldPrefix = getConfigs().getString(config, "outputFieldPrefix", ""); this.failOnInvalidURI = getConfigs().getBoolean(config, "failOnInvalidURI", false); validateArguments(); }
public ToByteArray(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.fieldName = getConfigs().getString(config, "field"); this.charset = getConfigs().getCharset(config, "charset", Charsets.UTF_8); validateArguments(); }
public AddCurrentTime(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.fieldName = getConfigs().getString(config, FIELD_NAME, Fields.TIMESTAMP); this.preserveExisting = getConfigs().getBoolean(config, PRESERVE_EXISTING_NAME, true); validateArguments(); }
public ReadLine(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.charset = getConfigs().getCharset(config, "charset", null); this.ignoreFirstLine = getConfigs().getBoolean(config, "ignoreFirstLine", false); String cprefix = getConfigs().getString(config, "commentPrefix", ""); if (cprefix.length() > 1) { throw new MorphlineCompilationException("commentPrefix must be at most one character long: " + cprefix, config); } this.commentPrefix = (cprefix.length() > 0 ? cprefix : null); validateArguments(); }
public ToString(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.fieldName = getConfigs().getString(config, "field"); this.trim = getConfigs().getBoolean(config, "trim", false); validateArguments(); }
public ReadClob(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.outputFieldName = getConfigs().getString(config, "outputField", Fields.MESSAGE); this.charset = getConfigs().getCharset(config, "charset", null); validateArguments(); }
public ToString(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.fieldName = getConfigs().getString(config, "field"); this.trim = getConfigs().getBoolean(config, "trim", false); validateArguments(); }
public ToByteArray(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.fieldName = getConfigs().getString(config, "field"); this.charset = getConfigs().getCharset(config, "charset", Charsets.UTF_8); validateArguments(); }
@Test public void testValidateArgumentsWithoutQuotes() throws Exception { Config config = ConfigFactory.parseString("{ foo : bar, see : you.there.soon }"); Configs configs = new Configs(); assertEquals("bar", configs.getString(config, "foo")); assertEquals("you.there.soon", configs.getString(config, "see")); configs.validateArguments(config); }
@Test public void testValidateArgumentsWithQuotes() throws Exception { Config config = ConfigFactory.parseString("{ foo : bar, \"see\" : \"you.there.soon.~!@#$%^&*()_+=-\" }"); Configs configs = new Configs(); assertEquals("bar", configs.getString(config, "foo")); assertEquals("you.there.soon.~!@#$%^&*()_+=-", configs.getString(config, "see")); configs.validateArguments(config); }
public GenerateSequenceNumber(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.fieldName = getConfigs().getString(config, "field"); this.preserveExisting = getConfigs().getBoolean(config, "preserveExisting", true); validateArguments(); }
public CopyTestCommand(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); this.name = getConfigs().getString(config, "name"); this.count = getConfigs().getInt(config, "count", 2); getCounter("counter1"); getHistogram("histogram1"); getMeter("meter1"); getTimer("timer1"); }