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


Java Context.getSubProperties方法代码示例

本文整理汇总了Java中org.apache.flume.Context.getSubProperties方法的典型用法代码示例。如果您正苦于以下问题:Java Context.getSubProperties方法的具体用法?Java Context.getSubProperties怎么用?Java Context.getSubProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flume.Context的用法示例。


在下文中一共展示了Context.getSubProperties方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: configure

import org.apache.flume.Context; //导入方法依赖的package包/类
@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);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:17,代码来源:HDFSSequenceFile.java

示例3: configureSerializers

import org.apache.flume.Context; //导入方法依赖的package包/类
private void configureSerializers(Context context) {
  String serializerListStr = context.getString(SERIALIZERS);
  Preconditions.checkArgument(!StringUtils.isEmpty(serializerListStr),
      "Must supply at least one name and serializer");

  String[] serializerNames = serializerListStr.split("\\s+");

  Context serializerContexts =
      new Context(context.getSubProperties(SERIALIZERS + "."));

  serializerList = Lists.newArrayListWithCapacity(serializerNames.length);
  for (String serializerName : serializerNames) {
    Context serializerContext = new Context(
        serializerContexts.getSubProperties(serializerName + "."));
    String type = serializerContext.getString("type", "DEFAULT");
    String name = serializerContext.getString("name");
    Preconditions.checkArgument(!StringUtils.isEmpty(name),
        "Supplied name cannot be empty.");

    if ("DEFAULT".equals(type)) {
      serializerList.add(new NameAndSerializer(name, defaultSerializer));
    } else {
      serializerList.add(new NameAndSerializer(name, getCustomSerializer(
          type, serializerContext)));
    }
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:28,代码来源:RegexExtractorInterceptor.java

示例4: configure

import org.apache.flume.Context; //导入方法依赖的package包/类
@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);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:13,代码来源:HDFSDataStream.java

示例5: configure

import org.apache.flume.Context; //导入方法依赖的package包/类
@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);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:13,代码来源:HDFSCompressedDataStream.java

示例6: testWithNewKeyStore

import org.apache.flume.Context; //导入方法依赖的package包/类
@Test
public void testWithNewKeyStore() throws Exception {
  createNewKeyStore();
  EncryptionTestUtils.createKeyStore(keyStoreFile, keyStorePasswordFile,
      keyAliasPassword);
  Context context = new Context(
      EncryptionTestUtils.configureForKeyStore(keyStoreFile,
                                               keyStorePasswordFile,
                                               keyAliasPassword));
  Context keyProviderContext = new Context(
      context.getSubProperties(EncryptionConfiguration.KEY_PROVIDER + "."));
  KeyProvider keyProvider =
      KeyProviderFactory.getInstance(KeyProviderType.JCEKSFILE.name(), keyProviderContext);
  testKeyProvider(keyProvider);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:16,代码来源:TestJCEFileKeyProvider.java

示例7: testWithExistingKeyStore

import org.apache.flume.Context; //导入方法依赖的package包/类
@Test
public void testWithExistingKeyStore() throws Exception {
  keyAliasPassword.putAll(EncryptionTestUtils.configureTestKeyStore(baseDir, keyStoreFile));
  Context context = new Context(
      EncryptionTestUtils.configureForKeyStore(keyStoreFile,
                                               keyStorePasswordFile,
                                               keyAliasPassword));
  Context keyProviderContext = new Context(
      context.getSubProperties(EncryptionConfiguration.KEY_PROVIDER + "."));
  KeyProvider keyProvider =
      KeyProviderFactory.getInstance(KeyProviderType.JCEKSFILE.name(), keyProviderContext);
  testKeyProvider(keyProvider);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:14,代码来源:TestJCEFileKeyProvider.java

示例8: initializeSystemProperties

import org.apache.flume.Context; //导入方法依赖的package包/类
private void initializeSystemProperties(Context context) {
  Map<String, String> sysProps = new HashMap<String, String>();

  Map<String, String> sysPropsOld = context.getSubProperties(
      ConfigurationConstants.OLD_CONFIG_JDBC_SYSPROP_PREFIX);

  if (sysPropsOld.size() > 0) {
    LOGGER.warn("Long form configuration prefix \""
        + ConfigurationConstants.OLD_CONFIG_JDBC_SYSPROP_PREFIX
        + "\" is deprecated. Please use the short form prefix \""
        + ConfigurationConstants.CONFIG_JDBC_SYSPROP_PREFIX
        + "\" instead.");

    sysProps.putAll(sysPropsOld);
  }

  Map<String, String> sysPropsNew = context.getSubProperties(
      ConfigurationConstants.CONFIG_JDBC_SYSPROP_PREFIX);

  // Override the deprecated values with the non-deprecated
  if (sysPropsNew.size() > 0) {
    sysProps.putAll(sysPropsNew);
  }

  for (String key: sysProps.keySet()) {
    String value = sysProps.get(key);
    if (key != null && value != null) {
      System.setProperty(key, value);
    }
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:32,代码来源:JdbcChannelProviderImpl.java

示例9: configure

import org.apache.flume.Context; //导入方法依赖的package包/类
@Override
public void configure(Context context) {
  this.headerName = context.getString(CONFIG_MULTIPLEX_HEADER_NAME,
      DEFAULT_MULTIPLEX_HEADER);

  Map<String, Channel> channelNameMap = getChannelNameMap();

  defaultChannels = getChannelListFromNames(
      context.getString(CONFIG_DEFAULT_CHANNEL), channelNameMap);

  Map<String, String> mapConfig =
      context.getSubProperties(CONFIG_PREFIX_MAPPING);

  channelMapping = new HashMap<String, List<Channel>>();

  for (String headerValue : mapConfig.keySet()) {
    List<Channel> configuredChannels = getChannelListFromNames(
        mapConfig.get(headerValue),
        channelNameMap);

    //This should not go to default channel(s)
    //because this seems to be a bad way to configure.
    if (configuredChannels.size() == 0) {
      throw new FlumeException("No channel configured for when "
          + "header value is: " + headerValue);
    }

    if (channelMapping.put(headerValue, configuredChannels) != null) {
      throw new FlumeException("Selector channel configured twice");
    }
  }
  //If no mapping is configured, it is ok.
  //All events will go to the default channel(s).
  Map<String, String> optionalChannelsMapping =
      context.getSubProperties(CONFIG_PREFIX_OPTIONAL + ".");

  optionalChannels = new HashMap<String, List<Channel>>();
  for (String hdr : optionalChannelsMapping.keySet()) {
    List<Channel> confChannels = getChannelListFromNames(
            optionalChannelsMapping.get(hdr), channelNameMap);
    if (confChannels.isEmpty()) {
      confChannels = EMPTY_LIST;
    }
    //Remove channels from optional channels, which are already
    //configured to be required channels.

    List<Channel> reqdChannels = channelMapping.get(hdr);
    //Check if there are required channels, else defaults to default channels
    if (reqdChannels == null || reqdChannels.isEmpty()) {
      reqdChannels = defaultChannels;
    }
    for (Channel c : reqdChannels) {
      if (confChannels.contains(c)) {
        confChannels.remove(c);
      }
    }

    if (optionalChannels.put(hdr, confChannels) != null) {
      throw new FlumeException("Selector channel configured twice");
    }
  }

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

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