本文整理汇总了Java中org.apache.flume.Context.putAll方法的典型用法代码示例。如果您正苦于以下问题:Java Context.putAll方法的具体用法?Java Context.putAll怎么用?Java Context.putAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flume.Context
的用法示例。
在下文中一共展示了Context.putAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.apache.flume.Context; //导入方法依赖的package包/类
@Override
public void configure(Context context) throws ConfigurationException {
super.configure(context);
sinks = Arrays.asList(context.getString(
BasicConfigurationConstants.CONFIG_SINKS).split("\\s+"));
Map<String, String> params = context.getSubProperties(
BasicConfigurationConstants.CONFIG_SINK_PROCESSOR_PREFIX);
processorContext = new Context();
processorContext.putAll(params);
SinkProcessorType spType = getKnownSinkProcessor(processorContext.getString(
BasicConfigurationConstants.CONFIG_TYPE));
if (spType != null) {
processorConf =
(SinkProcessorConfiguration) ComponentConfigurationFactory.create(
this.getComponentName() + "-processor",
spType.toString(),
ComponentType.SINK_PROCESSOR);
if (processorConf != null) {
processorConf.setSinks(new HashSet<String>(sinks));
processorConf.configure(processorContext);
}
}
setConfigured();
}
示例2: testTransactionPutCapacityOverload
import org.apache.flume.Context; //导入方法依赖的package包/类
@Test(expected = ChannelException.class)
public void testTransactionPutCapacityOverload() {
Context context = new Context();
Map<String, String> parms = new HashMap<String, String>();
parms.put("capacity", "5");
parms.put("transactionCapacity", "2");
context.putAll(parms);
Configurables.configure(channel, context);
Transaction transaction = channel.getTransaction();
transaction.begin();
channel.put(EventBuilder.withBody("test".getBytes()));
channel.put(EventBuilder.withBody("test".getBytes()));
// shouldn't be able to fit a third in the buffer
channel.put(EventBuilder.withBody("test".getBytes()));
Assert.fail();
}
示例3: testCapacityOverload
import org.apache.flume.Context; //导入方法依赖的package包/类
@Test(expected = ChannelException.class)
public void testCapacityOverload() {
Context context = new Context();
Map<String, String> parms = new HashMap<String, String>();
parms.put("capacity", "5");
parms.put("transactionCapacity", "3");
context.putAll(parms);
Configurables.configure(channel, context);
Transaction transaction = channel.getTransaction();
transaction.begin();
channel.put(EventBuilder.withBody("test".getBytes()));
channel.put(EventBuilder.withBody("test".getBytes()));
channel.put(EventBuilder.withBody("test".getBytes()));
transaction.commit();
transaction.close();
transaction = channel.getTransaction();
transaction.begin();
channel.put(EventBuilder.withBody("test".getBytes()));
channel.put(EventBuilder.withBody("test".getBytes()));
channel.put(EventBuilder.withBody("test".getBytes()));
// this should kill it
transaction.commit();
Assert.fail();
}
示例4: testCapacityBufferEmptyingAfterRollback
import org.apache.flume.Context; //导入方法依赖的package包/类
@Test
public void testCapacityBufferEmptyingAfterRollback() {
Context context = new Context();
Map<String, String> parms = new HashMap<String, String>();
parms.put("capacity", "3");
parms.put("transactionCapacity", "3");
context.putAll(parms);
Configurables.configure(channel, context);
Transaction tx = channel.getTransaction();
tx.begin();
channel.put(EventBuilder.withBody("test".getBytes()));
channel.put(EventBuilder.withBody("test".getBytes()));
channel.put(EventBuilder.withBody("test".getBytes()));
tx.rollback();
tx.close();
tx = channel.getTransaction();
tx.begin();
channel.put(EventBuilder.withBody("test".getBytes()));
channel.put(EventBuilder.withBody("test".getBytes()));
channel.put(EventBuilder.withBody("test".getBytes()));
tx.commit();
tx.close();
}
示例5: testNullEmptyEvent
import org.apache.flume.Context; //导入方法依赖的package包/类
@Test
public void testNullEmptyEvent() {
Context context = new Context();
Map<String, String> parms = new HashMap<String, String>();
parms.put("byteCapacity", "2000");
parms.put("byteCapacityBufferPercentage", "20");
context.putAll(parms);
Configurables.configure(channel, context);
Transaction tx = channel.getTransaction();
tx.begin();
//This line would cause a NPE without FLUME-1622.
channel.put(EventBuilder.withBody(null));
tx.commit();
tx.close();
tx = channel.getTransaction();
tx.begin();
channel.put(EventBuilder.withBody(new byte[0]));
tx.commit();
tx.close();
}
示例6: testNegativeCapacities
import org.apache.flume.Context; //导入方法依赖的package包/类
@Test
public void testNegativeCapacities() {
Context context = new Context();
Map<String, String> parms = new HashMap<String, String>();
parms.put("capacity", "-3");
parms.put("transactionCapacity", "-1");
context.putAll(parms);
Configurables.configure(channel, context);
Assert.assertTrue(field("queue")
.ofType(LinkedBlockingDeque.class)
.in(channel).get()
.remainingCapacity() > 0);
Assert.assertTrue(field("transCapacity")
.ofType(Integer.class)
.in(channel).get() > 0);
}
示例7: create
import org.apache.flume.Context; //导入方法依赖的package包/类
public static ChannelSelector create(List<Channel> channels,
Map<String, String> config) {
ChannelSelector selector = getSelectorForType(config.get(
BasicConfigurationConstants.CONFIG_TYPE));
selector.setChannels(channels);
Context context = new Context();
context.putAll(config);
Configurables.configure(selector, context);
return selector;
}
示例8: testCapacityBufferEmptyingAfterTakeCommit
import org.apache.flume.Context; //导入方法依赖的package包/类
@Test
public void testCapacityBufferEmptyingAfterTakeCommit() {
Context context = new Context();
Map<String, String> parms = new HashMap<String, String>();
parms.put("capacity", "3");
parms.put("transactionCapacity", "3");
context.putAll(parms);
Configurables.configure(channel, context);
Transaction tx = channel.getTransaction();
tx.begin();
channel.put(EventBuilder.withBody("test".getBytes()));
channel.put(EventBuilder.withBody("test".getBytes()));
channel.put(EventBuilder.withBody("test".getBytes()));
tx.commit();
tx.close();
tx = channel.getTransaction();
tx.begin();
channel.take();
channel.take();
tx.commit();
tx.close();
tx = channel.getTransaction();
tx.begin();
channel.put(EventBuilder.withBody("test".getBytes()));
channel.put(EventBuilder.withBody("test".getBytes()));
tx.commit();
tx.close();
}
示例9: testByteCapacityOverload
import org.apache.flume.Context; //导入方法依赖的package包/类
@Test(expected = ChannelException.class)
public void testByteCapacityOverload() {
Context context = new Context();
Map<String, String> parms = new HashMap<String, String>();
parms.put("byteCapacity", "2000");
parms.put("byteCapacityBufferPercentage", "20");
context.putAll(parms);
Configurables.configure(channel, context);
byte[] eventBody = new byte[405];
Transaction transaction = channel.getTransaction();
transaction.begin();
channel.put(EventBuilder.withBody(eventBody));
channel.put(EventBuilder.withBody(eventBody));
channel.put(EventBuilder.withBody(eventBody));
transaction.commit();
transaction.close();
transaction = channel.getTransaction();
transaction.begin();
channel.put(EventBuilder.withBody(eventBody));
channel.put(EventBuilder.withBody(eventBody));
// this should kill it
transaction.commit();
Assert.fail();
}
示例10: testByteCapacityBufferEmptyingAfterRollback
import org.apache.flume.Context; //导入方法依赖的package包/类
@Test
public void testByteCapacityBufferEmptyingAfterRollback() {
Context context = new Context();
Map<String, String> parms = new HashMap<String, String>();
parms.put("byteCapacity", "2000");
parms.put("byteCapacityBufferPercentage", "20");
context.putAll(parms);
Configurables.configure(channel, context);
byte[] eventBody = new byte[405];
Transaction tx = channel.getTransaction();
tx.begin();
channel.put(EventBuilder.withBody(eventBody));
channel.put(EventBuilder.withBody(eventBody));
channel.put(EventBuilder.withBody(eventBody));
tx.rollback();
tx.close();
tx = channel.getTransaction();
tx.begin();
channel.put(EventBuilder.withBody(eventBody));
channel.put(EventBuilder.withBody(eventBody));
channel.put(EventBuilder.withBody(eventBody));
tx.commit();
tx.close();
}
示例11: testOneEventWithDefaults
import org.apache.flume.Context; //导入方法依赖的package包/类
@Test
public void testOneEventWithDefaults() throws Exception {
Map<String,String> ctxMap = new HashMap<String,String>();
ctxMap.put("table", tableName);
ctxMap.put("columnFamily", columnFamily);
ctxMap.put("serializer",
"org.apache.flume.sink.hbase.SimpleAsyncHbaseEventSerializer");
ctxMap.put("keep-alive", "0");
ctxMap.put("timeout", "10000");
Context tmpctx = new Context();
tmpctx.putAll(ctxMap);
testUtility.createTable(tableName.getBytes(), columnFamily.getBytes());
deleteTable = true;
AsyncHBaseSink sink = new AsyncHBaseSink(testUtility.getConfiguration());
Configurables.configure(sink, tmpctx);
Channel channel = new MemoryChannel();
Configurables.configure(channel, tmpctx);
sink.setChannel(channel);
sink.start();
Transaction tx = channel.getTransaction();
tx.begin();
Event e = EventBuilder.withBody(
Bytes.toBytes(valBase));
channel.put(e);
tx.commit();
tx.close();
Assert.assertFalse(sink.isConfNull());
sink.process();
sink.stop();
HTable table = new HTable(testUtility.getConfiguration(), tableName);
byte[][] results = getResults(table, 1);
byte[] out = results[0];
Assert.assertArrayEquals(e.getBody(), out);
out = results[1];
Assert.assertArrayEquals(Longs.toByteArray(1), out);
}
示例12: createFileChannelContext
import org.apache.flume.Context; //导入方法依赖的package包/类
public static Context createFileChannelContext(String checkpointDir, String dataDir,
String backupDir, Map<String, String> overrides) {
Context context = new Context();
context.put(FileChannelConfiguration.CHECKPOINT_DIR, checkpointDir);
if (backupDir != null) {
context.put(FileChannelConfiguration.BACKUP_CHECKPOINT_DIR, backupDir);
}
context.put(FileChannelConfiguration.DATA_DIRS, dataDir);
context.put(FileChannelConfiguration.KEEP_ALIVE, String.valueOf(1));
context.put(FileChannelConfiguration.CAPACITY, String.valueOf(10000));
context.putAll(overrides);
return context;
}
示例13: configureChannel
import org.apache.flume.Context; //导入方法依赖的package包/类
private void configureChannel(Map<String, String> overrides) {
Context context = new Context();
File checkPointDir = fileChannelDir.newFolder("checkpoint");
File dataDir = fileChannelDir.newFolder("data");
context.put(FileChannelConfiguration.CHECKPOINT_DIR, checkPointDir.getAbsolutePath());
context.put(FileChannelConfiguration.DATA_DIRS, dataDir.getAbsolutePath());
// Set checkpoint for 5 seconds otherwise test will run out of memory
context.put(FileChannelConfiguration.CHECKPOINT_INTERVAL, "5000");
if (overrides != null) {
context.putAll(overrides);
}
Configurables.configure(channel, context);
}
示例14: testChannelResize
import org.apache.flume.Context; //导入方法依赖的package包/类
@Test
public void testChannelResize() {
Context context = new Context();
Map<String, String> parms = new HashMap<String, String>();
parms.put("capacity", "5");
parms.put("transactionCapacity", "5");
context.putAll(parms);
Configurables.configure(channel, context);
Transaction transaction = channel.getTransaction();
transaction.begin();
for (int i = 0; i < 5; i++) {
channel.put(EventBuilder.withBody(String.format("test event %d", i).getBytes()));
}
transaction.commit();
transaction.close();
/*
* Verify overflow semantics
*/
transaction = channel.getTransaction();
boolean overflowed = false;
try {
transaction.begin();
channel.put(EventBuilder.withBody("overflow event".getBytes()));
transaction.commit();
} catch (ChannelException e) {
overflowed = true;
transaction.rollback();
} finally {
transaction.close();
}
Assert.assertTrue(overflowed);
/*
* Reconfigure capacity down and add another event, shouldn't result in exception
*/
parms.put("capacity", "6");
context.putAll(parms);
Configurables.configure(channel, context);
transaction = channel.getTransaction();
transaction.begin();
channel.put(EventBuilder.withBody("extended capacity event".getBytes()));
transaction.commit();
transaction.close();
/*
* Attempt to reconfigure capacity to below current entry count and verify
* it wasn't carried out
*/
parms.put("capacity", "2");
parms.put("transactionCapacity", "2");
context.putAll(parms);
Configurables.configure(channel, context);
for (int i = 0; i < 6; i++) {
transaction = channel.getTransaction();
transaction.begin();
Assert.assertNotNull(channel.take());
transaction.commit();
transaction.close();
}
}
示例15: configure
import org.apache.flume.Context; //导入方法依赖的package包/类
public void configure(Context context) throws ConfigurationException {
super.configure(context);
try {
String channelList = context.getString(
BasicConfigurationConstants.CONFIG_CHANNELS);
if (channelList != null) {
this.channels =
new HashSet<String>(Arrays.asList(channelList.split("\\s+")));
}
if (channels.isEmpty()) {
errors.add(new FlumeConfigurationError(componentName,
ComponentType.CHANNEL.getComponentType(),
FlumeConfigurationErrorType.PROPERTY_VALUE_NULL,
ErrorOrWarning.ERROR));
throw new ConfigurationException("No channels set for "
+ this.getComponentName());
}
Map<String, String> selectorParams = context.getSubProperties(
BasicConfigurationConstants.CONFIG_SOURCE_CHANNELSELECTOR_PREFIX);
String selType;
if (selectorParams != null && !selectorParams.isEmpty()) {
selType = selectorParams.get(BasicConfigurationConstants.CONFIG_TYPE);
} else {
selType = ChannelSelectorConfigurationType.REPLICATING.toString();
}
if (selType == null || selType.isEmpty()) {
selType = ChannelSelectorConfigurationType.REPLICATING.toString();
}
ChannelSelectorType selectorType =
this.getKnownChannelSelector(selType);
Context selectorContext = new Context();
selectorContext.putAll(selectorParams);
String config = null;
if (selectorType == null) {
config = selectorContext.getString(
BasicConfigurationConstants.CONFIG_CONFIG);
if (config == null || config.isEmpty()) {
config = "OTHER";
}
} else {
config = selectorType.toString().toUpperCase(Locale.ENGLISH);
}
this.selectorConf =
(ChannelSelectorConfiguration) ComponentConfigurationFactory
.create(ComponentType.CHANNELSELECTOR.getComponentType(), config,
ComponentType.CHANNELSELECTOR);
selectorConf.setChannels(channels);
selectorConf.configure(selectorContext);
} catch (Exception e) {
errors.add(new FlumeConfigurationError(componentName,
ComponentType.CHANNELSELECTOR.getComponentType(),
FlumeConfigurationErrorType.CONFIG_ERROR,
ErrorOrWarning.ERROR));
throw new ConfigurationException("Failed to configure component!", e);
}
}