org.apache.flume.Context.getBoolean()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(12.3k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中org.apache.flume.Context.getBoolean()方法的一些代码示例,展示了Context.getBoolean()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getBoolean()方法的具体详情如下:
包路径:org.apache.flume.Context
类名称:Context
方法名:getBoolean

Context.getBoolean介绍

[英]Gets value mapped to key, returning null if unmapped.

Note that this method returns an object as opposed to a primitive. The configuration key requested may not be mapped to a value and by returning the primitive object wrapper we can return null. If the key does not exist the return value of this method is assigned directly to a primitive, a NullPointerException will be thrown.
[中]

代码示例

代码示例来源:origin: apache/flume

private HeaderAndBodyTextEventSerializer(OutputStream out, Context ctx) {
 this.appendNewline = ctx.getBoolean(APPEND_NEWLINE, APPEND_NEWLINE_DFLT);
 this.out = out;
}

代码示例来源:origin: apache/flume

private BodyTextEventSerializer(OutputStream out, Context ctx) {
 this.appendNewline = ctx.getBoolean(APPEND_NEWLINE, APPEND_NEWLINE_DFLT);
 this.out = out;
}

代码示例来源:origin: apache/flume

/**
 * Gets value mapped to key, returning null if unmapped.
 * <p>
 * Note that this method returns an object as opposed to a
 * primitive. The configuration key requested may not be mapped
 * to a value and by returning the primitive object wrapper we can
 * return null. If the key does not exist the return value of
 * this method is assigned directly to a primitive, a
 * {@link NullPointerException} will be thrown.
 * </p>
 * @param key to be found
 * @return value associated with key or null if unmapped
 */
public Boolean getBoolean(String key) {
 return getBoolean(key, null);
}
/**

代码示例来源:origin: apache/flume

@Override
public void configure(Context context) {
 preserveExisting = context.getBoolean(PRESERVE, PRESERVE_DFLT);
 useIP = context.getBoolean(USE_IP, USE_IP_DFLT);
 header = context.getString(HOST_HEADER, HOST);
}

代码示例来源:origin: apache/flume

@Override
public void configure(Context context) {
 String regexString = context.getString(REGEX, DEFAULT_REGEX);
 regex = Pattern.compile(regexString);
 excludeEvents = context.getBoolean(EXCLUDE_EVENTS,
   DEFAULT_EXCLUDE_EVENTS);
}

代码示例来源:origin: apache/flume

@Override
public void configure(Context context) {
 preserveExisting = context.getBoolean(CONFIG_PRESERVE, DEFAULT_PRESERVE);
 header = context.getString(CONFIG_HEADER_NAME, DEFAULT_HEADER_NAME);
}

代码示例来源:origin: apache/flume

protected UUIDInterceptor(Context context) {
 headerName = context.getString(HEADER_NAME, "id");
 preserveExisting = context.getBoolean(PRESERVE_EXISTING_NAME, true);
 prefix = context.getString(PREFIX_NAME, "");
}

代码示例来源:origin: apache/flume

@Override
public void configure(Context context) {
 preserveExisting = context.getBoolean(Constants.PRESERVE, Constants.PRESERVE_DEFAULT);
 key = context.getString(Constants.KEY, Constants.KEY_DEFAULT);
 value = context.getString(Constants.VALUE, Constants.VALUE_DEFAULT);
}

代码示例来源:origin: apache/flume

@Override
public void configure(Context context) {
 String regex = context.getString(REGEX_CONFIG, REGEX_DEFAULT);
 boolean regexIgnoreCase = context.getBoolean(IGNORE_CASE_CONFIG,
     IGNORE_CASE_DEFAULT);
 depositHeaders = context.getBoolean(DEPOSIT_HEADERS_CONFIG,
   DEPOSIT_HEADERS_DEFAULT);
 inputPattern = Pattern.compile(regex, Pattern.DOTALL
   + (regexIgnoreCase ? Pattern.CASE_INSENSITIVE : 0));
 charset = Charset.forName(context.getString(CHARSET_CONFIG,
   CHARSET_DEFAULT));
 String colNameStr = context.getString(COL_NAME_CONFIG, COLUMN_NAME_DEFAULT);
 String[] columnNames = colNameStr.split(",");
 for (String s : columnNames) {
  colNames.add(s.getBytes(charset));
 }
 //Rowkey is optional, default is -1
 rowKeyIndex = context.getInteger(ROW_KEY_INDEX_CONFIG, -1);
 //if row key is being used, make sure it is specified correct
 if (rowKeyIndex >= 0) {
  if (rowKeyIndex >= columnNames.length) {
   throw new IllegalArgumentException(ROW_KEY_INDEX_CONFIG + " must be " +
     "less than num columns " + columnNames.length);
  }
  if (!ROW_KEY_NAME.equalsIgnoreCase(columnNames[rowKeyIndex])) {
   throw new IllegalArgumentException("Column at " + rowKeyIndex + " must be "
     + ROW_KEY_NAME + " and is " + columnNames[rowKeyIndex]);
  }
 }
}

代码示例来源:origin: apache/flume

@Override
public void configure(Context context) {
 String regex = context.getString(REGEX_CONFIG, REGEX_DEFAULT);
 regexIgnoreCase = context.getBoolean(IGNORE_CASE_CONFIG,
     IGNORE_CASE_DEFAULT);
 depositHeaders = context.getBoolean(DEPOSIT_HEADERS_CONFIG,
   DEPOSIT_HEADERS_DEFAULT);
 inputPattern = Pattern.compile(regex, Pattern.DOTALL
   + (regexIgnoreCase ? Pattern.CASE_INSENSITIVE : 0));
 charset = Charset.forName(context.getString(CHARSET_CONFIG,
   CHARSET_DEFAULT));
 String colNameStr = context.getString(COL_NAME_CONFIG, COLUMN_NAME_DEFAULT);
 String[] columnNames = colNameStr.split(",");
 for (String s : columnNames) {
  colNames.add(s.getBytes(charset));
 }
 //Rowkey is optional, default is -1
 rowKeyIndex = context.getInteger(ROW_KEY_INDEX_CONFIG, -1);
 //if row key is being used, make sure it is specified correct
 if (rowKeyIndex >= 0) {
  if (rowKeyIndex >= columnNames.length) {
   throw new IllegalArgumentException(ROW_KEY_INDEX_CONFIG + " must be " +
     "less than num columns " + columnNames.length);
  }
  if (!ROW_KEY_NAME.equalsIgnoreCase(columnNames[rowKeyIndex])) {
   throw new IllegalArgumentException("Column at " + rowKeyIndex + " must be "
     + ROW_KEY_NAME + " and is " + columnNames[rowKeyIndex]);
  }
 }
}

代码示例来源:origin: apache/flume

@Override
public void configure(Context context) {
 super.configure(context);
 serializerType = context.getString("serializer", "TEXT");
 useRawLocalFileSystem = context.getBoolean("hdfs.useRawLocalFileSystem",
   false);
 serializerContext = new Context(
   context.getSubProperties(EventSerializer.CTX_PREFIX));
 logger.info("Serializer = " + serializerType + ", UseRawLocalFileSystem = "
   + useRawLocalFileSystem);
}

代码示例来源:origin: apache/flume

@Override
public void configure(Context context) {
 super.configure(context);
 serializerType = context.getString("serializer", "TEXT");
 useRawLocalFileSystem = context.getBoolean("hdfs.useRawLocalFileSystem",
   false);
 serializerContext =
   new Context(context.getSubProperties(EventSerializer.CTX_PREFIX));
 logger.info("Serializer = " + serializerType + ", UseRawLocalFileSystem = "
   + useRawLocalFileSystem);
}

代码示例来源:origin: apache/flume

@Override
public void configure(Context context) {
 this.pollFrequency = context.getInteger(this.CONF_POLL_FREQUENCY, 60);
 String localHosts = context.getString(this.CONF_HOSTS);
 if (localHosts == null || localHosts.isEmpty()) {
  throw new ConfigurationException("Hosts list cannot be empty.");
 }
 this.hosts = this.getHostsFromString(localHosts);
 this.isGanglia3 = context.getBoolean(this.CONF_ISGANGLIA3, false);
}

代码示例来源:origin: apache/flume

@Override
public void configure(Context context) {
 command = context.getString("command");
 Preconditions.checkState(command != null,
   "The parameter command must be specified");
 restartThrottle = context.getLong(ExecSourceConfigurationConstants.CONFIG_RESTART_THROTTLE,
   ExecSourceConfigurationConstants.DEFAULT_RESTART_THROTTLE);
 restart = context.getBoolean(ExecSourceConfigurationConstants.CONFIG_RESTART,
   ExecSourceConfigurationConstants.DEFAULT_RESTART);
 logStderr = context.getBoolean(ExecSourceConfigurationConstants.CONFIG_LOG_STDERR,
   ExecSourceConfigurationConstants.DEFAULT_LOG_STDERR);
 bufferCount = context.getInteger(ExecSourceConfigurationConstants.CONFIG_BATCH_SIZE,
   ExecSourceConfigurationConstants.DEFAULT_BATCH_SIZE);
 batchTimeout = context.getLong(ExecSourceConfigurationConstants.CONFIG_BATCH_TIME_OUT,
   ExecSourceConfigurationConstants.DEFAULT_BATCH_TIME_OUT);
 charset = Charset.forName(context.getString(ExecSourceConfigurationConstants.CHARSET,
   ExecSourceConfigurationConstants.DEFAULT_CHARSET));
 shell = context.getString(ExecSourceConfigurationConstants.CONFIG_SHELL, null);
 if (sourceCounter == null) {
  sourceCounter = new SourceCounter(getName());
 }
}

代码示例来源:origin: apache/flume

public void configure(Context context) {
 hostname = context.getString("hostname");
 String portStr = context.getString("port");
 nick = context.getString("nick");
 password = context.getString("password");
 user = context.getString("user");
 name = context.getString("name");
 chan = context.getString("chan");
 splitLines = context.getBoolean("splitlines", false);
 splitChars = context.getString("splitchars");
 if (portStr != null) {
  port = Integer.parseInt(portStr);
 } else {
  port = DEFAULT_PORT;
 }
 if (splitChars == null) {
  splitChars = DEFAULT_SPLIT_CHARS;
 }
 
 Preconditions.checkState(hostname != null, "No hostname specified");
 Preconditions.checkState(nick != null, "No nick specified");
 Preconditions.checkState(chan != null, "No chan specified");
}

代码示例来源:origin: apache/flume

@Override
public void configure(Context context) {
 Preconditions.checkState(getSinks().size() > 1,
   "The LoadBalancingSinkProcessor cannot be used for a single sink. "
   + "Please configure more than one sinks and try again.");
 String selectorTypeName = context.getString(CONFIG_SELECTOR,
   SELECTOR_NAME_ROUND_ROBIN);
 Boolean shouldBackOff = context.getBoolean(CONFIG_BACKOFF, false);
 selector = null;
 if (selectorTypeName.equalsIgnoreCase(SELECTOR_NAME_ROUND_ROBIN)) {
  selector = new RoundRobinSinkSelector(shouldBackOff);
 } else if (selectorTypeName.equalsIgnoreCase(SELECTOR_NAME_RANDOM)) {
  selector = new RandomOrderSinkSelector(shouldBackOff);
 } else {
  try {
   @SuppressWarnings("unchecked")
   Class<? extends SinkSelector> klass = (Class<? extends SinkSelector>)
     Class.forName(selectorTypeName);
   selector = klass.newInstance();
  } catch (Exception ex) {
   throw new FlumeException("Unable to instantiate sink selector: "
     + selectorTypeName, ex);
  }
 }
 selector.setSinks(getSinks());
 selector.configure(
   new Context(context.getSubProperties(CONFIG_SELECTOR_PREFIX)));
 LOGGER.debug("Sink selector: " + selector + " initialized");
}

代码示例来源:origin: apache/flume

@Override
public void configure(Context context) {
 super.configure(context);
 // use binary writable serialize by default
 writeFormat = context.getString("hdfs.writeFormat",
  SequenceFileSerializerType.Writable.name());
 useRawLocalFileSystem = context.getBoolean("hdfs.useRawLocalFileSystem",
   false);
 serializerContext = new Context(
     context.getSubProperties(SequenceFileSerializerFactory.CTX_PREFIX));
 serializer = SequenceFileSerializerFactory
     .getSerializer(writeFormat, serializerContext);
 logger.info("writeFormat = " + writeFormat + ", UseRawLocalFileSystem = "
   + useRawLocalFileSystem);
}

代码示例来源:origin: apache/flume

context.getBoolean(FaultTolerance.IS_PRODUCTION_MODE, false), 
context.getBoolean(FaultTolerance.IS_IGNORING_RECOVERABLE_EXCEPTIONS, false),
context.getString(FaultTolerance.RECOVERABLE_EXCEPTION_CLASSES));

代码示例来源:origin: apache/flume

@Override
public void configure(Context context) {
 String hostKey = NetcatSourceConfigurationConstants.CONFIG_HOSTNAME;
 String portKey = NetcatSourceConfigurationConstants.CONFIG_PORT;
 String ackEventKey = NetcatSourceConfigurationConstants.CONFIG_ACKEVENT;
 Configurables.ensureRequiredNonNull(context, hostKey, portKey);
 hostName = context.getString(hostKey);
 port = context.getInteger(portKey);
 ackEveryEvent = context.getBoolean(ackEventKey, true);
 maxLineLength = context.getInteger(
   NetcatSourceConfigurationConstants.CONFIG_MAX_LINE_LENGTH,
   NetcatSourceConfigurationConstants.DEFAULT_MAX_LINE_LENGTH);
 sourceEncoding = context.getString(
   NetcatSourceConfigurationConstants.CONFIG_SOURCE_ENCODING,
   NetcatSourceConfigurationConstants.DEFAULT_ENCODING
 );
}

代码示例来源:origin: apache/flume

protected void configureSsl(Context context) {
 sslEnabled = context.getBoolean(SSL_ENABLED_KEY, SSL_ENABLED_DEFAULT_VALUE);
 keystore = context.getString(KEYSTORE_KEY, SSLUtil.getGlobalKeystorePath());
 keystorePassword = context.getString(
   KEYSTORE_PASSWORD_KEY, SSLUtil.getGlobalKeystorePassword());
 keystoreType = context.getString(
   KEYSTORE_TYPE_KEY, SSLUtil.getGlobalKeystoreType(KEYSTORE_TYPE_DEFAULT_VALUE));
 parseList(context.getString(EXCLUDE_PROTOCOLS, SSLUtil.getGlobalExcludeProtocols()),
   excludeProtocols);
 parseList(context.getString(INCLUDE_PROTOCOLS, SSLUtil.getGlobalIncludeProtocols()),
   includeProtocols);
 parseList(context.getString(EXCLUDE_CIPHER_SUITES, SSLUtil.getGlobalExcludeCipherSuites()),
   excludeCipherSuites);
 parseList(context.getString(INCLUDE_CIPHER_SUITES, SSLUtil.getGlobalIncludeCipherSuites()),
   includeCipherSuites);
 if (sslEnabled) {
  Objects.requireNonNull(keystore,
    KEYSTORE_KEY + " must be specified when SSL is enabled");
  Objects.requireNonNull(keystorePassword,
    KEYSTORE_PASSWORD_KEY + " must be specified when SSL is enabled");
  try {
   KeyStore ks = KeyStore.getInstance(keystoreType);
   ks.load(new FileInputStream(keystore), keystorePassword.toCharArray());
  } catch (Exception ex) {
   throw new FlumeException(
    "Source " + getName() + " configured with invalid keystore: " + keystore, ex);
  }
 }
}

相关文章