本文整理汇总了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();
}
示例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);
}
示例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)));
}
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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");
}
}
}
示例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);
}
}