Exemplo n.º 1
0
  @Override
  public void configure(Context context) {
    if (morphlineContext == null) {
      FaultTolerance faultTolerance =
          new FaultTolerance(
              context.getBoolean(FaultTolerance.IS_PRODUCTION_MODE, false),
              context.getBoolean(FaultTolerance.IS_IGNORING_RECOVERABLE_EXCEPTIONS, false),
              context.getString(FaultTolerance.RECOVERABLE_EXCEPTION_CLASSES));

      morphlineContext =
          new MorphlineContext.Builder()
              .setExceptionHandler(faultTolerance)
              .setMetricRegistry(new MetricRegistry())
              .build();
    }

    String morphlineFile = context.getString(MORPHLINE_FILE_PARAM);
    String morphlineId = context.getString(MORPHLINE_ID_PARAM);
    if (morphlineFile == null || morphlineFile.trim().length() == 0) {
      throw new MorphlineCompilationException("Missing parameter: " + MORPHLINE_FILE_PARAM, null);
    }
    Config override =
        ConfigFactory.parseMap(context.getSubProperties(MORPHLINE_VARIABLE_PARAM + "."));
    morphline =
        new Compiler()
            .compile(new File(morphlineFile), morphlineId, morphlineContext, finalChild, override);
    morphlineFileAndId = morphlineFile + "@" + morphlineId;
  }
 @Override
 public void doConfigure(Context context) {
   final String regex = context.getString(CONFIG_REGULAR_EXPRESSION, REGEX_DEFAULT);
   final boolean regexIgnoreCase = context.getBoolean(IGNORE_CASE_CONFIG, IGNORE_CASE_DEFAULT);
   inputPattern =
       Pattern.compile(regex, Pattern.DOTALL + (regexIgnoreCase ? Pattern.CASE_INSENSITIVE : 0));
 }
Exemplo n.º 3
0
  @Override
  public synchronized void configure(Context context) {
    spoolDirectory = context.getString(SPOOL_DIRECTORY);
    Preconditions.checkState(
        spoolDirectory != null, "Configuration must specify a spooling directory");

    completedSuffix = context.getString(SPOOLED_FILE_SUFFIX, DEFAULT_SPOOLED_FILE_SUFFIX);
    deletePolicy = context.getString(DELETE_POLICY, DEFAULT_DELETE_POLICY);
    fileHeader = context.getBoolean(FILENAME_HEADER, DEFAULT_FILE_HEADER);
    fileHeaderKey = context.getString(FILENAME_HEADER_KEY, DEFAULT_FILENAME_HEADER_KEY);
    basenameHeader = context.getBoolean(BASENAME_HEADER, DEFAULT_BASENAME_HEADER);
    basenameHeaderKey = context.getString(BASENAME_HEADER_KEY, DEFAULT_BASENAME_HEADER_KEY);
    batchSize = context.getInteger(BATCH_SIZE, DEFAULT_BATCH_SIZE);
    inputCharset = context.getString(INPUT_CHARSET, DEFAULT_INPUT_CHARSET);
    decodeErrorPolicy =
        DecodeErrorPolicy.valueOf(
            context
                .getString(DECODE_ERROR_POLICY, DEFAULT_DECODE_ERROR_POLICY)
                .toUpperCase(Locale.ENGLISH));

    ignorePattern = context.getString(IGNORE_PAT, DEFAULT_IGNORE_PAT);
    trackerDirPath = context.getString(TRACKER_DIR, DEFAULT_TRACKER_DIR);

    deserializerType = context.getString(DESERIALIZER, "ZipDeserializer");
    deserializerContext = new Context(context.getSubProperties(DESERIALIZER + "."));

    consumeOrder =
        ConsumeOrder.valueOf(
            context
                .getString(CONSUME_ORDER, DEFAULT_CONSUME_ORDER.toString())
                .toUpperCase(Locale.ENGLISH));

    // "Hack" to support backwards compatibility with previous generation of
    // spooling directory source, which did not support deserializers
    Integer bufferMaxLineLength = context.getInteger(BUFFER_MAX_LINE_LENGTH);
    if (bufferMaxLineLength != null
        && deserializerType != null
        && deserializerType.equalsIgnoreCase(DEFAULT_DESERIALIZER)) {
      deserializerContext.put(LineDeserializer.MAXLINE_KEY, bufferMaxLineLength.toString());
    }

    maxBackoff = context.getInteger(MAX_BACKOFF, DEFAULT_MAX_BACKOFF);
    if (sourceCounter == null) {
      sourceCounter = new SourceCounter(getName());
    }
  }
Exemplo n.º 4
0
 @Override
 public void configure(Context context) throws FlumeException {
   preserveExisting = context.getBoolean(PRESERVE, PRESERVE_DEFAULT);
   key = context.getString(KEY, KEY_DEFAULT);
   file = context.getString(FILE);
   period = context.getInteger(PERIOD, new Integer(PERIOD_DEFAULT));
   if (file != null) {
     value = readHeader(file);
   } else {
     logger.error("CSVHeaderInterceptor - file not specified");
     throw new FlumeException("CSVHeaderInterceptor - file not specified");
   }
 }
Exemplo n.º 5
0
  @Override
  public void configure(Context context) {
    setName(NAME_PREFIX + counter.getAndIncrement());

    host = context.getString(HOST, DEFAULT_HOST);
    port = context.getInteger(PORT, DEFAULT_PORT);
    username = context.getString(USERNAME);
    password = context.getString(PASSWORD);
    model = CollectionModel.valueOf(context.getString(MODEL, CollectionModel.single.name()));
    dbName = context.getString(DB_NAME, DEFAULT_DB);
    collectionName = context.getString(COLLECTION, DEFAULT_COLLECTION);
    batchSize = context.getInteger(BATCH_SIZE, DEFAULT_BATCH);
    autoWrap = context.getBoolean(AUTO_WRAP, DEFAULT_AUTO_WRAP);
    wrapField = context.getString(WRAP_FIELD, DEFAULT_WRAP_FIELD);

    logger.info(
        "MongoSink {} context { host:{}, port:{}, username:{}, password:{}, model:{}, dbName:{}, collectionName:{}, batch: {} }",
        new Object[] {
          getName(), host, port, username, password, model, dbName, collectionName, batchSize
        });
  }