当前位置: 首页>>代码示例>>Java>>正文


Java Context.putAll方法代码示例

本文整理汇总了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();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:26,代码来源:SinkGroupConfiguration.java

示例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();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:18,代码来源:TestMemoryChannel.java

示例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();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:27,代码来源:TestMemoryChannel.java

示例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();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:26,代码来源:TestMemoryChannel.java

示例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();


}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:25,代码来源:TestMemoryChannel.java

示例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);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:19,代码来源:TestMemoryChannel.java

示例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;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:15,代码来源:ChannelSelectorFactory.java

示例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();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:32,代码来源:TestMemoryChannel.java

示例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();

}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:29,代码来源:TestMemoryChannel.java

示例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();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:28,代码来源:TestMemoryChannel.java

示例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);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:38,代码来源:TestAsyncHBaseSink.java

示例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;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:14,代码来源:TestUtils.java

示例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);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:16,代码来源:TestSpillableMemoryChannel.java

示例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();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:63,代码来源:TestMemoryChannel.java

示例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);
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:60,代码来源:SourceConfiguration.java


注:本文中的org.apache.flume.Context.putAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。