Refine search
public RecordBinManager(final ProcessContext context, final ProcessSessionFactory sessionFactory, final ComponentLog logger) { this.context = context; this.sessionFactory = sessionFactory; this.logger = logger; final Integer maxBins = context.getProperty(MergeRecord.MAX_BIN_COUNT).asInteger(); this.maxBinCount = maxBins == null ? Integer.MAX_VALUE : maxBins.intValue(); }
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(); }
/** * 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(); }
@OnScheduled public void onSchedule(ProcessContext context) { this.removeTrailingNewLines = context.getProperty(REMOVE_TRAILING_NEWLINES).isSet() ? context.getProperty(REMOVE_TRAILING_NEWLINES).asBoolean() : false; this.maxSplitSize = context.getProperty(FRAGMENT_MAX_SIZE).isSet() ? context.getProperty(FRAGMENT_MAX_SIZE).asDataSize(DataUnit.B).longValue() : Long.MAX_VALUE; this.lineCount = context.getProperty(LINE_SPLIT_COUNT).asInteger(); this.headerLineCount = context.getProperty(HEADER_LINE_COUNT).asInteger(); this.headerMarker = context.getProperty(HEADER_MARKER).getValue(); }
@Override protected Collection<ValidationResult> customValidate(final ValidationContext context) { final List<ValidationResult> errors = new ArrayList<>(super.customValidate(context)); final String regexValue = context.getProperty(REGEX).evaluateAttributeExpressions().getValue(); final int numCapturingGroups = Pattern.compile(regexValue).matcher("").groupCount(); final int groupToMatch = context.getProperty(MATCHING_GROUP_FOR_LOOKUP_KEY).evaluateAttributeExpressions().asInteger(); if (groupToMatch > numCapturingGroups) { errors.add( new ValidationResult.Builder() .subject("Insufficient Matching Groups") .valid(false) .explanation("The specified matching group does not exist for the regular expression provided") .build()); } return errors; }
@OnScheduled @SuppressWarnings("unchecked") public void onScheduled(ProcessContext context) throws ClassNotFoundException, InterruptedException { flowFileMaxSuccess = context.getProperty(FF_SUCCESS_ITERATIONS).asInteger(); flowFileMaxFailure = context.getProperty(FF_FAILURE_ITERATIONS).asInteger(); flowFileMaxYield = context.getProperty(FF_ROLLBACK_YIELD_ITERATIONS).asInteger(); flowFileMaxRollback = context.getProperty(FF_ROLLBACK_ITERATIONS).asInteger(); flowFileMaxPenalty = context.getProperty(FF_ROLLBACK_PENALTY_ITERATIONS).asInteger(); flowFileMaxException = context.getProperty(FF_EXCEPTION_ITERATIONS).asInteger(); noFlowFileMaxException = context.getProperty(NO_FF_EXCEPTION_ITERATIONS).asInteger(); noFlowFileMaxYield = context.getProperty(NO_FF_YIELD_ITERATIONS).asInteger(); noFlowFileMaxSkip = context.getProperty(NO_FF_SKIP_ITERATIONS).asInteger(); curr_ff_resp.reset(); curr_noff_resp.reset(); flowFileExceptionClass = (Class<? extends RuntimeException>) Class.forName(context.getProperty(FF_EXCEPTION_CLASS).toString()); noFlowFileExceptionClass = (Class<? extends RuntimeException>) Class.forName(context.getProperty(NO_FF_EXCEPTION_CLASS).toString()); sleep(context.getProperty(ON_SCHEDULED_SLEEP_TIME).asTimePeriod(TimeUnit.MILLISECONDS), context.getProperty(IGNORE_INTERRUPTS).asBoolean()); fail(context.getProperty(ON_SCHEDULED_FAIL).asBoolean(), OnScheduled.class); }
@Override public List<FileInfo> getListing() throws IOException { final String path = ctx.getProperty(FileTransfer.REMOTE_PATH).evaluateAttributeExpressions().getValue(); final int depth = 0; final int maxResults = ctx.getProperty(FileTransfer.REMOTE_POLL_BATCH_SIZE).asInteger(); return getListing(path, depth, maxResults); }
@Override protected CacheServer createCacheServer(final ConfigurationContext context) { final int port = context.getProperty(PORT).asInteger(); final String persistencePath = context.getProperty(PERSISTENCE_PATH).getValue(); final SSLContextService sslContextService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class); final int maxSize = context.getProperty(MAX_CACHE_ENTRIES).asInteger(); final String evictionPolicyName = context.getProperty(EVICTION_POLICY).getValue();
@OnScheduled public void onScheduled(final ProcessContext context) { super.onScheduled(context); // Initialize the prepared statement cache int statementCacheSize = context.getProperty(STATEMENT_CACHE_SIZE).evaluateAttributeExpressions().asInteger(); statementCache = CacheBuilder.newBuilder() .maximumSize(statementCacheSize) .<String, PreparedStatement>build() .asMap(); }
@OnScheduled public void onScheduled(final ProcessContext context) { super.onScheduled(context); qos = context.getProperty(PROP_QOS).asInteger(); maxQueueSize = context.getProperty(PROP_MAX_QUEUE_SIZE).asLong(); topicFilter = context.getProperty(PROP_TOPIC_FILTER).getValue(); scheduled.set(true); }
@OnEnabled public void enable(final ConfigurationContext context) throws InitializationException { schemaRegistryConfig = new HashMap<>(); versionInfoCacheNanos = context.getProperty(CACHE_EXPIRATION).asTimePeriod(TimeUnit.NANOSECONDS); // The below properties may or may not need to be exposed to the end // user. We just need to watch usage patterns to see if sensible default // can satisfy NiFi requirements String urlValue = context.getProperty(URL).evaluateAttributeExpressions().getValue(); if (urlValue == null || urlValue.trim().isEmpty()) { throw new IllegalArgumentException("'Schema Registry URL' must not be null or empty."); } schemaRegistryConfig.put(SchemaRegistryClient.Configuration.SCHEMA_REGISTRY_URL.name(), urlValue); schemaRegistryConfig.put(SchemaRegistryClient.Configuration.CLASSLOADER_CACHE_SIZE.name(), 10L); schemaRegistryConfig.put(SchemaRegistryClient.Configuration.CLASSLOADER_CACHE_EXPIRY_INTERVAL_SECS.name(), context.getProperty(CACHE_EXPIRATION).asTimePeriod(TimeUnit.SECONDS)); schemaRegistryConfig.put(SchemaRegistryClient.Configuration.SCHEMA_VERSION_CACHE_SIZE.name(), context.getProperty(CACHE_SIZE).asInteger()); schemaRegistryConfig.put(SchemaRegistryClient.Configuration.SCHEMA_VERSION_CACHE_EXPIRY_INTERVAL_SECS.name(), context.getProperty(CACHE_EXPIRATION).asTimePeriod(TimeUnit.SECONDS)); }
private int migrateBins(final ProcessContext context) { int added = 0; for (final Bin bin : binManager.removeReadyBins(true)) { this.readyBins.add(bin); added++; } // if we have created all of the bins that are allowed, go ahead and remove the oldest one. If we don't do // this, then we will simply wait for it to expire because we can't get any more FlowFiles into the // bins. So we may as well expire it now. if (added == 0 && binManager.getBinCount() >= context.getProperty(MAX_BIN_COUNT).asInteger()) { final Bin bin = binManager.removeOldestBin(); if (bin != null) { added++; this.readyBins.add(bin); } } return added; }
@Override public List<FileInfo> getListing() throws IOException { final String path = ctx.getProperty(FileTransfer.REMOTE_PATH).evaluateAttributeExpressions().getValue(); final int depth = 0; final int maxResults; final PropertyValue batchSizeValue = ctx.getProperty(FileTransfer.REMOTE_POLL_BATCH_SIZE); if (batchSizeValue == null) { maxResults = Integer.MAX_VALUE; } else { final Integer configuredValue = batchSizeValue.asInteger(); maxResults = configuredValue == null ? Integer.MAX_VALUE : configuredValue; } final List<FileInfo> listing = new ArrayList<>(1000); getListing(path, depth, maxResults, listing); return listing; }
@Override protected CacheServer createCacheServer(final ConfigurationContext context) { final int port = context.getProperty(PORT).asInteger(); final String persistencePath = context.getProperty(PERSISTENCE_PATH).getValue(); final SSLContextService sslContextService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class); final int maxSize = context.getProperty(MAX_CACHE_ENTRIES).asInteger(); final String evictionPolicyName = context.getProperty(EVICTION_POLICY).getValue();
@OnScheduled public void onScheduled(final ProcessContext context) { final ComponentLog logger = getLogger(); final Integer cacheSize = context.getProperty(CACHE_SIZE).asInteger(); final Long cacheTTL = context.getProperty(CACHE_TTL_AFTER_LAST_ACCESS).asTimePeriod(TimeUnit.SECONDS); if (cacheSize > 0) { CacheBuilder<Object, Object> cacheBuilder = CacheBuilder.newBuilder().maximumSize(cacheSize); if (cacheTTL > 0) { cacheBuilder = cacheBuilder.expireAfterAccess(cacheTTL, TimeUnit.SECONDS); } cache = cacheBuilder.build( new CacheLoader<String, Templates>() { @Override public Templates load(String path) throws TransformerConfigurationException, LookupFailureException { return newTemplates(context, path); } }); } else { cache = null; logger.info("Stylesheet cache disabled because cache size is set to 0"); } }
@Override public void process(InputStream in) throws IOException { Schema as = JsonUtil.inferSchema( in, context.getProperty(RECORD_NAME).evaluateAttributeExpressions(inputFlowFile).getValue(), context.getProperty(NUM_RECORDS_TO_ANALYZE).evaluateAttributeExpressions(inputFlowFile).asInteger()); avroSchema.set(as.toString(context.getProperty(PRETTY_AVRO_OUTPUT).asBoolean())); } });
@Override public synchronized void init(final StateProviderInitializationContext context) throws IOException { long checkpointIntervalMillis = context.getProperty(CHECKPOINT_INTERVAL).asTimePeriod(TimeUnit.MILLISECONDS); int numPartitions = context.getProperty(NUM_PARTITIONS).asInteger(); alwaysSync = context.getProperty(ALWAYS_SYNC).asBoolean(); final File basePath = new File(context.getProperty(PATH).getValue());
@OnScheduled public void setup(final ProcessContext context) { int maxTransformsToCache = context.getProperty(TRANSFORM_CACHE_SIZE).asInteger(); transformCache = Caffeine.newBuilder() .maximumSize(maxTransformsToCache) .build(specString -> createTransform(context, specString.orElse(null))); }
@OnScheduled public void onScheduled(final ProcessContext context) throws ProcessException { this.receiveBufferSize = context.getProperty(RECEIVE_BUFFER_SIZE).asDataSize(DataUnit.B).intValue(); this.originalServerAddressList = context.getProperty(ENDPOINT_LIST).getValue(); this.endOfMessageByte = ((byte) context.getProperty(END_OF_MESSAGE_BYTE).asInteger().intValue()); this.connectionAttemptCount = context.getProperty(CONNECTION_ATTEMPT_COUNT).asInteger(); this.reconnectInterval = context.getProperty(RECONNECT_INTERVAL).asTimePeriod(TimeUnit.MILLISECONDS); this.clientScheduler = new ScheduledThreadPoolExecutor(originalServerAddressList.split(",").length + 1); this.clientScheduler.setKeepAliveTime(10, TimeUnit.SECONDS); this.clientScheduler.allowCoreThreadTimeOut(true); for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); if (descriptor.isDynamic()) { this.dynamicAttributes.put(descriptor.getName(), entry.getValue()); } } }
@OnEnabled public void onEnabled(final ConfigurationContext context) { prettyPrint = context.getProperty(PRETTY_PRINT_JSON).asBoolean(); final NullSuppression suppression; final String suppressNullValue = context.getProperty(SUPPRESS_NULLS).getValue(); if (ALWAYS_SUPPRESS.getValue().equals(suppressNullValue)) { suppression = NullSuppression.ALWAYS_SUPPRESS; } else if (SUPPRESS_MISSING.getValue().equals(suppressNullValue)) { suppression = NullSuppression.SUPPRESS_MISSING; } else { suppression = NullSuppression.NEVER_SUPPRESS; } this.nullSuppression = suppression; String outputGroupingValue = context.getProperty(OUTPUT_GROUPING).getValue(); final OutputGrouping grouping; if(OUTPUT_ONELINE.getValue().equals(outputGroupingValue)) { grouping = OutputGrouping.OUTPUT_ONELINE; } else { grouping = OutputGrouping.OUTPUT_ARRAY; } this.outputGrouping = grouping; this.compressionFormat = context.getProperty(COMPRESSION_FORMAT).getValue(); this.compressionLevel = context.getProperty(COMPRESSION_LEVEL).asInteger(); }