本文整理了Java中org.apache.nifi.components.PropertyValue
类的一些代码示例,展示了PropertyValue
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PropertyValue
类的具体详情如下:
包路径:org.apache.nifi.components.PropertyValue
类名称:PropertyValue
[英]A PropertyValue provides a mechanism whereby the currently configured value of a processor property can be obtained in different forms.
[中]PropertyValue提供了一种机制,可以通过该机制以不同的形式获取处理器属性的当前配置值。
代码示例来源:origin: apache/nifi
private ReplaceTextCallback(ProcessContext context, FlowFile flowFile, int maxBufferSize) {
this.regex = context.getProperty(REGEX).evaluateAttributeExpressions(flowFile, quotedAttributeDecorator).getValue();
this.flowFile = flowFile;
this.charset = Charset.forName(context.getProperty(CHARACTER_SET).getValue());
final String regexValue = context.getProperty(REGEX).evaluateAttributeExpressions().getValue();
this.numCapturingGroups = Pattern.compile(regexValue).matcher("").groupCount();
this.buffer = new byte[maxBufferSize];
this.groupToMatch = context.getProperty(MATCHING_GROUP_FOR_LOOKUP_KEY).evaluateAttributeExpressions().asInteger();
}
代码示例来源:origin: apache/nifi
@OnEnabled
public void onEnabled(final ConfigurationContext context) {
cache = context.getProperty(PROP_DISTRIBUTED_CACHE_SERVICE).asControllerService(DistributedMapCacheClient.class);
charset = Charset.forName(context.getProperty(CHARACTER_ENCODING).getValue());
}
代码示例来源:origin: apache/nifi
@OnScheduled
public void onScheduled(ProcessContext context) {
attributesToRemove = context.getProperty(INCLUDE_CORE_ATTRIBUTES).asBoolean() ? Collections.EMPTY_SET : Arrays.stream(CoreAttributes.values())
.map(CoreAttributes::key)
.collect(Collectors.toSet());
attributes = buildAtrs(context.getProperty(ATTRIBUTES_LIST).getValue(), attributesToRemove);
nullValueForEmptyString = context.getProperty(NULL_VALUE_FOR_EMPTY_STRING).asBoolean();
destinationContent = DESTINATION_CONTENT.equals(context.getProperty(DESTINATION).getValue());
if(context.getProperty(ATTRIBUTES_REGEX).isSet()) {
pattern = Pattern.compile(context.getProperty(ATTRIBUTES_REGEX).evaluateAttributeExpressions().getValue());
}
}
代码示例来源:origin: apache/nifi
private boolean computeGroupId() {
groupId = groupIdentifierProperty.evaluateAttributeExpressions(flowFile).getValue();
if (isBlank(groupId)) {
transferToFailure(flowFile, "Failed to get Group Identifier.");
return false;
}
return true;
}
代码示例来源:origin: apache/nifi
protected ChannelSender createSender(final ProcessContext context) throws IOException {
final int port = context.getProperty(PORT).evaluateAttributeExpressions().asInteger();
final String host = context.getProperty(HOSTNAME).evaluateAttributeExpressions().getValue();
final String protocol = context.getProperty(PROTOCOL).getValue();
final int maxSendBuffer = context.getProperty(MAX_SOCKET_SEND_BUFFER_SIZE).evaluateAttributeExpressions().asDataSize(DataUnit.B).intValue();
final int timeout = context.getProperty(TIMEOUT).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS).intValue();
final SSLContextService sslContextService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
return createSender(sslContextService, protocol, host, port, maxSendBuffer, timeout);
}
代码示例来源:origin: apache/nifi
private PathFilter createPathFilter(final ProcessContext context) {
final Pattern filePattern = Pattern.compile(context.getProperty(FILE_FILTER).getValue());
final String filterMode = context.getProperty(FILE_FILTER_MODE).getValue();
return path -> {
final boolean accepted;
if (FILTER_FULL_PATH_VALUE.getValue().equals(filterMode)) {
accepted = filePattern.matcher(path.toString()).matches();
} else {
accepted = filePattern.matcher(path.getName()).matches();
}
return accepted;
};
}
代码示例来源:origin: apache/nifi
private Set<String> createDictionary(final ProcessContext context) throws IOException {
final Set<String> terms = new HashSet<>();
final File file = new File(context.getProperty(DICTIONARY_FILE).evaluateAttributeExpressions().getValue());
try (final InputStream fis = new FileInputStream(file);
final BufferedReader reader = new BufferedReader(new InputStreamReader(fis))) {
String line;
while ((line = reader.readLine()) != null) {
if (line.trim().isEmpty()) {
continue;
}
String matchingTerm = line;
if (dictionaryFilterPattern != null) {
final Matcher matcher = dictionaryFilterPattern.matcher(line);
if (!matcher.matches()) {
continue;
}
// Determine if we should use the entire line or only a part, depending on whether or not
// a Matching Group was specified in the regex.
if (matcher.groupCount() == 1) {
matchingTerm = matcher.group(1);
} else {
matchingTerm = line;
}
}
terms.add(matchingTerm);
}
}
return Collections.unmodifiableSet(terms);
}
代码示例来源:origin: apache/nifi
@Override
public void onTrigger(final ReportingContext context) {
final String thresholdValue = context.getProperty(DIR_THRESHOLD).getValue();
final Matcher thresholdMatcher = PERCENT_PATTERN.matcher(thresholdValue.trim());
thresholdMatcher.find();
final String thresholdPercentageVal = thresholdMatcher.group(1);
final int contentRepoThreshold = Integer.parseInt(thresholdPercentageVal);
final File dir = new File(context.getProperty(DIR_LOCATION).getValue());
final String dirName = context.getProperty(DIR_DISPLAY_NAME).getValue();
checkThreshold(dirName, dir.toPath(), contentRepoThreshold, getLogger());
}
代码示例来源:origin: apache/nifi
private Request.Builder setHeaderProperties(final ProcessContext context, Request.Builder requestBuilder, final FlowFile requestFlowFile) {
if (context.getProperty(PROP_DATE_HEADER).asBoolean()) {
requestBuilder = requestBuilder.addHeader("Date", DATE_FORMAT.print(System.currentTimeMillis()));
String headerValue = context.getProperty(headerKey).evaluateAttributeExpressions(requestFlowFile).getValue();
requestBuilder = requestBuilder.addHeader(headerKey, headerValue);
Matcher m = regexAttributesToSend.matcher("");
for (Map.Entry<String, String> entry : attributes.entrySet()) {
String headerKey = trimToEmpty(entry.getKey());
m.reset(headerKey);
if (m.matches()) {
String headerVal = trimToEmpty(entry.getValue());
requestBuilder = requestBuilder.addHeader(headerKey, headerVal);
代码示例来源:origin: apache/nifi
@Override
public void onConfigured(AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {
final PropertyValue configurableUserGroupProviderKey = configurationContext.getProperty(PROP_CONFIGURABLE_USER_GROUP_PROVIDER);
if (!configurableUserGroupProviderKey.isSet()) {
throw new AuthorizerCreationException("The Configurable User Group Provider must be set.");
}
final UserGroupProvider userGroupProvider = userGroupProviderLookup.getUserGroupProvider(configurableUserGroupProviderKey.getValue());
if (userGroupProvider == null) {
throw new AuthorizerCreationException(String.format("Unable to locate the Configurable User Group Provider: %s", configurableUserGroupProviderKey));
}
if (!(userGroupProvider instanceof ConfigurableUserGroupProvider)) {
throw new AuthorizerCreationException(String.format("The Configurable User Group Provider is not configurable: %s", configurableUserGroupProviderKey));
}
// Ensure that the ConfigurableUserGroupProvider is not also listed as one of the providers for the CompositeUserGroupProvider
for (Map.Entry<String, String> entry : configurationContext.getProperties().entrySet()) {
Matcher matcher = USER_GROUP_PROVIDER_PATTERN.matcher(entry.getKey());
if (matcher.matches() && !StringUtils.isBlank(entry.getValue())) {
final String userGroupProviderKey = entry.getValue();
if (userGroupProviderKey.equals(configurableUserGroupProviderKey.getValue())) {
throw new AuthorizerCreationException(String.format("Duplicate provider in Composite Configurable User Group Provider configuration: %s", userGroupProviderKey));
}
}
}
configurableUserGroupProvider = (ConfigurableUserGroupProvider) userGroupProvider;
// configure the CompositeUserGroupProvider
super.onConfigured(configurationContext);
}
代码示例来源:origin: apache/nifi
@OnScheduled
public void onConfigured(final ConfigurationContext config) throws InitializationException {
final String desiredMemoryPoolName = config.getProperty(MEMORY_POOL_PROPERTY).getValue();
final String thresholdValue = config.getProperty(THRESHOLD_PROPERTY).getValue().trim();
threshold = thresholdValue;
final Long reportingIntervalValue = config.getProperty(REPORTING_INTERVAL).asTimePeriod(TimeUnit.MILLISECONDS);
if (reportingIntervalValue == null) {
reportingIntervalMillis = config.getSchedulingPeriod(TimeUnit.MILLISECONDS);
if (memoryPoolBean.isCollectionUsageThresholdSupported()) {
long calculatedThreshold;
if (DATA_SIZE_PATTERN.matcher(thresholdValue).matches()) {
calculatedThreshold = DataUnit.parseDataSize(thresholdValue, DataUnit.B).longValue();
} else {
代码示例来源:origin: apache/nifi
@SuppressWarnings("unused")
@OnScheduled
public void onScheduled(ProcessContext context) {
String metadataKeyFilterInput = context.getProperty(METADATA_KEY_FILTER).getValue();
if (metadataKeyFilterInput != null && metadataKeyFilterInput.length() > 0) {
metadataKeyFilterRef.set(Pattern.compile(metadataKeyFilterInput));
} else {
metadataKeyFilterRef.set(null);
}
autoDetectParser = new AutoDetectParser();
}
代码示例来源:origin: apache/nifi
@OnScheduled
public void onScheduled(final ProcessContext context) {
final String attributeNameRegex = context.getProperty(ATTRIBUTE_NAME_REGEX).getValue();
this.attributeNamePattern = attributeNameRegex == null ? null : Pattern.compile(attributeNameRegex);
}
代码示例来源:origin: apache/nifi
ProcessorConfiguration(final ProcessContext context) {
ignoreDottedFiles = context.getProperty(IGNORE_DOTTED_FILES).asBoolean();
final String fileFilterRegex = context.getProperty(FILE_FILTER_REGEX).getValue();
fileFilterPattern = (fileFilterRegex == null) ? null : Pattern.compile(fileFilterRegex);
filterMatchBasenameOnly = context.getProperty(FILTER_MATCH_NAME_ONLY).asBoolean();
final Long minAgeProp = context.getProperty(MIN_AGE).asTimePeriod(TimeUnit.MILLISECONDS);
minimumAge = (minAgeProp == null) ? 0L : minAgeProp;
final Long maxAgeProp = context.getProperty(MAX_AGE).asTimePeriod(TimeUnit.MILLISECONDS);
maximumAge = (maxAgeProp == null) ? Long.MAX_VALUE : maxAgeProp;
recurseSubdirs = context.getProperty(RECURSE_SUBDIRS).asBoolean();
}
代码示例来源:origin: apache/nifi
@OnScheduled
public void onScheduled(final ProcessContext context) throws IOException {
final String filterRegex = context.getProperty(DICTIONARY_FILTER).getValue();
this.dictionaryFilterPattern = (filterRegex == null) ? null : Pattern.compile(filterRegex);
final String attributeRegex = context.getProperty(ATTRIBUTE_PATTERN).getValue();
this.attributePattern = (attributeRegex.equals(".*")) ? null : Pattern.compile(attributeRegex);
this.dictionaryTerms = createDictionary(context);
this.fileWatcher = new SynchronousFileWatcher(Paths.get(context.getProperty(DICTIONARY_FILE).evaluateAttributeExpressions().getValue()), new LastModifiedMonitor(), 1000L);
}
代码示例来源:origin: apache/nifi
@OnScheduled
public void onScheduled(ProcessContext context) {
this.decodeCharset = Charset.forName(context.getProperty(DECODE_CHARSET).getValue());
this.encodeCharset = Charset.forName(context.getProperty(ENCODE_CHARSET).getValue());
final String jsonFormat = context.getProperty(JSON_FORMAT).getValue();
if (jsonFormat.equals(JSON_FORMAT_FULL_ROW.getValue())) {
this.serializer = new JsonFullRowSerializer(decodeCharset, encodeCharset);
} else {
this.serializer = new JsonQualifierAndValueRowSerializer(decodeCharset, encodeCharset);
}
}
代码示例来源:origin: apache/nifi
public static Collection<ValidationResult> validateCredentialProperties(ValidationContext validationContext) {
final List<ValidationResult> results = new ArrayList<>();
String sasToken = validationContext.getProperty(PROP_SAS_TOKEN).getValue();
String acctName = validationContext.getProperty(ACCOUNT_KEY).getValue();
if ((StringUtils.isBlank(sasToken) && StringUtils.isBlank(acctName))
|| (StringUtils.isNotBlank(sasToken) && StringUtils.isNotBlank(acctName))) {
results.add(new ValidationResult.Builder().subject("AzureStorageUtils Credentials")
.valid(false)
.explanation("either Azure Account Key or Shared Access Signature required, but not both")
.build());
}
return results;
}
代码示例来源:origin: apache/nifi
@Override
public void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException {
final Boolean rollbackOnFailure = context.getProperty(RollbackOnFailure.ROLLBACK_ON_FAILURE).asBoolean();
final Charset charset = Charset.forName(context.getProperty(CHARSET).getValue());
final String statementDelimiter = context.getProperty(STATEMENT_DELIMITER).getValue();
final FunctionContext functionContext = new FunctionContext(rollbackOnFailure, charset, statementDelimiter);
RollbackOnFailure.onTrigger(context, sessionFactory, functionContext, getLogger(), session -> process.onTrigger(context, session, functionContext));
}
}
代码示例来源:origin: apache/nifi
/**
* Create the {@link #graphiteSender} according to configuration.
*
* @param context used to access properties.
*/
@OnEnabled
public void onEnabled(final ConfigurationContext context) {
String host = context.getProperty(HOST).evaluateAttributeExpressions().getValue();
int port = context.getProperty(PORT).evaluateAttributeExpressions().asInteger();
Charset charset = Charset.forName(context.getProperty(CHARSET).getValue());
graphiteSender = createSender(host, port, charset);
metricNamePrefix = context.getProperty(METRIC_NAME_PREFIX).evaluateAttributeExpressions().getValue();
}
代码示例来源:origin: apache/nifi
@Override
public void process(InputStream inputStream) throws IOException {
final String baseUrl = getBaseUrl(inputFlowFile, context);
if (baseUrl == null || baseUrl.isEmpty()) {
throw new RuntimeException("Base URL was empty.");
}
doc.set(Jsoup.parse(inputStream,
context.getProperty(HTML_CHARSET).getValue(),
baseUrl));
}
});
内容来源于网络,如有侵权,请联系作者删除!