本文整理了Java中org.apache.flume.Context.getInteger()
方法的一些代码示例,展示了Context.getInteger()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getInteger()
方法的具体详情如下:
包路径:org.apache.flume.Context
类名称:Context
方法名:getInteger
[英]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.
[中]获取映射到键的值,如果未映射,则返回null。
请注意,此方法返回一个对象,而不是原语。请求的配置键可能没有映射到值,通过返回原语对象包装器,我们可以返回null。如果键不存在,则此方法的返回值直接分配给原语,将引发NullPointerException。
代码示例来源:origin: apache/flume
@Override
public void configure(Context context) {
port = context.getInteger(CONFIG_PORT, DEFAULT_PORT);
}
代码示例来源: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 Integer getInteger(String key) {
return getInteger(key, null);
}
/**
代码示例来源:origin: apache/flume
@Override
public void configure(Context context) {
port = context.getInteger("port", DEFAULT_PORT);
maxReadBufferBytes = context.getInteger("maxReadBufferBytes", DEFAULT_MAX_READ_BUFFER_BYTES);
if(maxReadBufferBytes <= 0){
maxReadBufferBytes = DEFAULT_MAX_READ_BUFFER_BYTES;
}
workers = context.getInteger("workerThreads", DEFAULT_WORKERS);
if (workers <= 0) {
workers = DEFAULT_WORKERS;
}
if (sourceCounter == null) {
sourceCounter = new SourceCounter(getName());
}
}
代码示例来源:origin: apache/flume
@Override
public void configure(Context context) {
this.maxBlobLength = context.getInteger(MAX_BLOB_LENGTH_KEY, MAX_BLOB_LENGTH_DEFAULT);
if (this.maxBlobLength <= 0) {
throw new ConfigurationException("Configuration parameter " + MAX_BLOB_LENGTH_KEY
+ " must be greater than zero: " + maxBlobLength);
}
}
代码示例来源:origin: apache/flume
@Override
public void configure(Context context) {
batchSize = context.getInteger("batchSize", DFLT_BATCH_SIZE);
logger.debug(this.getName() + " " +
"batch size set to " + String.valueOf(batchSize));
Preconditions.checkArgument(batchSize > 0, "Batch size must be > 0");
logEveryNEvents = context.getInteger("logEveryNEvents", DFLT_LOG_EVERY_N_EVENTS);
logger.debug(this.getName() + " " +
"log event N events set to " + logEveryNEvents);
Preconditions.checkArgument(logEveryNEvents > 0, "logEveryNEvents must be > 0");
}
代码示例来源:origin: apache/flume
protected BlobDeserializer(Context context, ResettableInputStream in) {
this.in = in;
this.maxBlobLength = context.getInteger(MAX_BLOB_LENGTH_KEY, MAX_BLOB_LENGTH_DEFAULT);
if (this.maxBlobLength <= 0) {
throw new ConfigurationException("Configuration parameter " + MAX_BLOB_LENGTH_KEY
+ " must be greater than zero: " + maxBlobLength);
}
this.isOpen = true;
}
代码示例来源:origin: apache/flume
LineDeserializer(Context context, ResettableInputStream in) {
this.in = in;
this.outputCharset = Charset.forName(
context.getString(OUT_CHARSET_KEY, CHARSET_DFLT));
this.maxLineLength = context.getInteger(MAXLINE_KEY, MAXLINE_DFLT);
this.isOpen = true;
}
代码示例来源:origin: apache/flume
@Override
public void configure(Context context) {
Integer capacity = context.getInteger("capacity");
keepAlive = context.getInteger("keep-alive");
if (capacity == null) {
capacity = defaultCapacity;
}
if (keepAlive == null) {
keepAlive = defaultKeepAlive;
}
queue = new ArrayBlockingQueue<Event>(capacity);
if (channelCounter == null) {
channelCounter = new ChannelCounter(getName());
}
}
代码示例来源:origin: apache/flume
@Override
public void configure(Context context) {
syncIntervalBytes =
context.getInteger(SYNC_INTERVAL_BYTES, DEFAULT_SYNC_INTERVAL_BYTES);
compressionCodec =
context.getString(COMPRESSION_CODEC, DEFAULT_COMPRESSION_CODEC);
staticSchemaURL = context.getString(STATIC_SCHEMA_URL, DEFAULT_STATIC_SCHEMA_URL);
}
代码示例来源:origin: kaaproject/kaa
@Override
public void configure(Context context) {
syncIntervalBytes = context.getInteger(SYNC_INTERVAL_BYTES,
DEFAULT_SYNC_INTERVAL_BYTES);
compressionCodec = context.getString(COMPRESSION_CODEC,
DEFAULT_COMPRESSION_CODEC);
schemaSource.configure(context);
}
代码示例来源:origin: apache/flume
/**
* Read parameters from context
* <li>batchSize = type int that defines the size of event batches
*/
@Override
protected void doConfigure(Context context) throws FlumeException {
batchSize = context.getInteger("batchSize", 1);
totalEvents = context.getLong("totalEvents", Long.MAX_VALUE);
Preconditions.checkArgument(batchSize > 0, "batchSize was %s but expected positive", batchSize);
if (sourceCounter == null) {
sourceCounter = new SourceCounter(getName());
}
}
代码示例来源: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
@Override
public void configure(Context context) {
this.context = context;
maxBatchSize = context.getInteger(BATCH_SIZE, maxBatchSize);
maxBatchDurationMillis = context.getLong(BATCH_DURATION_MILLIS, maxBatchDurationMillis);
handlerClass = context.getString(HANDLER_CLASS, MorphlineHandlerImpl.class.getName());
if (sinkCounter == null) {
sinkCounter = new SinkCounter(getName());
}
}
代码示例来源: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) {
Configurables.ensureRequiredNonNull(
context, CONFIG_PORT);
port = context.getInteger(CONFIG_PORT);
host = context.getString(CONFIG_HOST);
remoteHostHeader = context.getString(REMOTE_ADDRESS_HEADER);
}
代码示例来源:origin: apache/ignite
/**
* Sink configurations with Ignite-specific settings.
*
* @param context Context for sink.
*/
@Override public void configure(Context context) {
springCfgPath = context.getString(IgniteSinkConstants.CFG_PATH);
cacheName = context.getString(IgniteSinkConstants.CFG_CACHE_NAME);
eventTransformerCls = context.getString(IgniteSinkConstants.CFG_EVENT_TRANSFORMER);
batchSize = context.getInteger(IgniteSinkConstants.CFG_BATCH_SIZE, DFLT_BATCH_SIZE);
if (sinkCounter == null)
sinkCounter = new SinkCounter(getName());
}
代码示例来源:origin: apache/flume
@Override
public void configure(Context context) {
String consumerKey = context.getString("consumerKey");
String consumerSecret = context.getString("consumerSecret");
String accessToken = context.getString("accessToken");
String accessTokenSecret = context.getString("accessTokenSecret");
twitterStream = new TwitterStreamFactory().getInstance();
twitterStream.setOAuthConsumer(consumerKey, consumerSecret);
twitterStream.setOAuthAccessToken(new AccessToken(accessToken,
accessTokenSecret));
twitterStream.addListener(this);
avroSchema = createAvroSchema();
dataFileWriter = new DataFileWriter<GenericRecord>(
new GenericDatumWriter<GenericRecord>(avroSchema));
maxBatchSize = context.getInteger("maxBatchSize", maxBatchSize);
maxBatchDurationMillis = context.getInteger("maxBatchDurationMillis",
maxBatchDurationMillis);
}
代码示例来源:origin: apache/flume
@Override
public void configure(Context context) {
int syncIntervalBytes =
context.getInteger(SYNC_INTERVAL_BYTES, DEFAULT_SYNC_INTERVAL_BYTES);
String compressionCodec =
context.getString(COMPRESSION_CODEC, DEFAULT_COMPRESSION_CODEC);
writer = new ReflectDatumWriter<T>(getSchema());
dataFileWriter = new DataFileWriter<T>(writer);
dataFileWriter.setSyncInterval(syncIntervalBytes);
try {
CodecFactory codecFactory = CodecFactory.fromString(compressionCodec);
dataFileWriter.setCodec(codecFactory);
} catch (AvroRuntimeException e) {
logger.warn("Unable to instantiate avro codec with name (" +
compressionCodec + "). Compression disabled. Exception follows.", e);
}
}
代码示例来源:origin: apache/rocketmq-externals
@Override protected void doConfigure(Context context) throws FlumeException {
nameServer = context.getString(NAME_SERVER_CONFIG);
if (nameServer == null) {
throw new ConfigurationException("NameServer must not be null");
}
topic = context.getString(TOPIC_CONFIG, TOPIC_DEFAULT);
tag = context.getString(TAG_CONFIG, TAG_DEFAULT);
consumerGroup = context.getString(CONSUMER_GROUP_CONFIG, CONSUMER_GROUP_DEFAULT);
messageModel = context.getString(MESSAGE_MODEL_CONFIG, MESSAGE_MODEL_DEFAULT);
batchSize = context.getInteger(BATCH_SIZE_CONFIG, BATCH_SIZE_DEFAULT);
if (sourceCounter == null) {
sourceCounter = new SourceCounter(getName());
}
}
代码示例来源:origin: apache/rocketmq-externals
@Override
public void configure(Context context) {
nameServer = context.getString(NAME_SERVER_CONFIG);
if (nameServer == null) {
throw new ConfigurationException("NameServer must not be null");
}
topic = context.getString(TOPIC_CONFIG, TOPIC_DEFAULT);
tag = context.getString(TAG_CONFIG, TAG_DEFAULT);
producerGroup = context.getString(PRODUCER_GROUP_CONFIG, PRODUCER_GROUP_DEFAULT);
batchSize = context.getInteger(BATCH_SIZE_CONFIG, BATCH_SIZE_DEFAULT);
maxProcessTime = context.getLong(MAX_PROCESS_TIME_CONFIG, MAX_PROCESS_TIME_DEFAULT);
if (sinkCounter == null) {
sinkCounter = new SinkCounter(getName());
}
}
内容来源于网络,如有侵权,请联系作者删除!