@Override protected String getDefaultTimePrecision() { // User does not have to choose one. // AUTO_DETECT can handle most cases, but it may incur longer latency // when all listed files do not have SECOND part in their timestamps although Azure Blob Storage does support seconds. return PRECISION_SECONDS.getValue(); }
private static String encodeKafkaKey(final byte[] key, final String encoding) { if (key == null) { return null; } if (HEX_ENCODING.getValue().equals(encoding)) { return DatatypeConverter.printHexBinary(key); } else if (UTF8_ENCODING.getValue().equals(encoding)) { return new String(key, StandardCharsets.UTF_8); } else { return null; // won't happen because it is guaranteed by the Allowable Values } }
private static String encodeKafkaKey(final byte[] key, final String encoding) { if (key == null) { return null; } if (HEX_ENCODING.getValue().equals(encoding)) { return DatatypeConverter.printHexBinary(key); } else if (UTF8_ENCODING.getValue().equals(encoding)) { return new String(key, StandardCharsets.UTF_8); } else { return null; // won't happen because it is guaranteed by the Allowable Values } }
private static String getSchemaAccessStrategyName(final String schemaAccessValue, final List<AllowableValue> schemaAccessStrategyValues) { for (final AllowableValue allowableValue : schemaAccessStrategyValues) { if (allowableValue.getValue().equalsIgnoreCase(schemaAccessValue)) { return allowableValue.getDisplayName(); } } return null; }
protected Object getValue(Map<String, AttributeValue> item, String keyName, String valueType) { if ( ALLOWABLE_VALUE_STRING.getValue().equals(valueType)) { AttributeValue val = item.get(keyName); if ( val == null ) return val; else return val.getS(); } else { AttributeValue val = item.get(keyName); if ( val == null ) return val; else return val.getN(); } }
@Override protected Scope getStateScope(final PropertyContext context) { final String location = context.getProperty(DIRECTORY_LOCATION).getValue(); if (LOCATION_REMOTE.getValue().equalsIgnoreCase(location)) { return Scope.CLUSTER; } return Scope.LOCAL; }
@Override protected SchemaAccessStrategy getSchemaAccessStrategy(final String strategy, final SchemaRegistry schemaRegistry, final ConfigurationContext context) { if (strategy.equalsIgnoreCase(STRING_FIELDS_FROM_GROK_EXPRESSION.getValue())) { return createAccessStrategy(); } else { return super.getSchemaAccessStrategy(strategy, schemaRegistry, context); } }
@OnScheduled public void initializeByteSequence(final ProcessContext context) throws DecoderException { final String bytePattern = context.getProperty(BYTE_SEQUENCE).getValue(); final String format = context.getProperty(FORMAT).getValue(); if (HEX_FORMAT.getValue().equals(format)) { this.byteSequence.set(Hex.decodeHex(bytePattern.toCharArray())); } else { this.byteSequence.set(bytePattern.getBytes(StandardCharsets.UTF_8)); } }
protected Object getAttributeValue(ProcessContext context, PropertyDescriptor propertyType, AttributeValue value) { if ( context.getProperty(propertyType).getValue().equals(ALLOWABLE_VALUE_STRING.getValue())) { if ( value == null ) return null; else return value.getS(); } else { if ( value == null ) return null; else return new BigDecimal(value.getN()); } }
private DMLSettings(ProcessContext context) { translateFieldNames = context.getProperty(TRANSLATE_FIELD_NAMES).asBoolean(); ignoreUnmappedFields = IGNORE_UNMATCHED_FIELD.getValue().equalsIgnoreCase(context.getProperty(UNMATCHED_FIELD_BEHAVIOR).getValue()); failUnmappedColumns = FAIL_UNMATCHED_COLUMN.getValue().equalsIgnoreCase(context.getProperty(UNMATCHED_COLUMN_BEHAVIOR).getValue()); warningUnmappedColumns = WARNING_UNMATCHED_COLUMN.getValue().equalsIgnoreCase(context.getProperty(UNMATCHED_COLUMN_BEHAVIOR).getValue()); escapeColumnNames = context.getProperty(QUOTED_IDENTIFIERS).asBoolean(); quoteTableName = context.getProperty(QUOTED_TABLE_IDENTIFIER).asBoolean(); }
private void updateDataDogTransport(ReportingContext context) throws IOException { String dataDogTransport = context.getProperty(DATADOG_TRANSPORT).getValue(); if (dataDogTransport.equalsIgnoreCase(DATADOG_AGENT.getValue())) { ddMetricRegistryBuilder.build("agent"); } else if (dataDogTransport.equalsIgnoreCase(DATADOG_HTTP.getValue()) && context.getProperty(API_KEY).isSet()) { ddMetricRegistryBuilder.build(context.getProperty(API_KEY).getValue()); } }
@Override protected Collection<ValidationResult> customValidate(final ValidationContext validationContext) { final List<ValidationResult> results = new ArrayList<>(1); final String format = validationContext.getProperty(FORMAT).getValue(); if (HEX_FORMAT.getValue().equals(format)) { final String byteSequence = validationContext.getProperty(BYTE_SEQUENCE).getValue(); final ValidationResult result = new HexStringPropertyValidator().validate(BYTE_SEQUENCE.getName(), byteSequence, validationContext); results.add(result); } return results; }
@OnScheduled public void onScheduled(ProcessContext context) { includeCoreAttributes = context.getProperty(INCLUDE_CORE_ATTRIBUTES).asBoolean(); coreAttributes = Arrays.stream(CoreAttributes.values()).map(CoreAttributes::key).collect(Collectors.toSet()); destinationContent = OUTPUT_OVERWRITE_CONTENT.getValue().equals(context.getProperty(DESTINATION).getValue()); nullValForEmptyString = context.getProperty(NULL_VALUE_FOR_EMPTY_STRING).asBoolean(); includeSchema = context.getProperty(INCLUDE_SCHEMA).asBoolean(); }
@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); } }
@Override public synchronized void init(final StateProviderInitializationContext context) { connectionString = context.getProperty(CONNECTION_STRING).getValue(); rootNode = context.getProperty(ROOT_NODE).getValue(); timeoutMillis = context.getProperty(SESSION_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue(); if (context.getProperty(ACCESS_CONTROL).getValue().equalsIgnoreCase(CREATOR_ONLY.getValue())) { acl = Ids.CREATOR_ALL_ACL; } else { acl = Ids.OPEN_ACL_UNSAFE; } }
@Test public void testStartAtCurrentTime() throws IOException, InterruptedException { runner.setProperty(TailFile.START_POSITION, TailFile.START_CURRENT_TIME.getValue()); raf.write("hello world\n".getBytes()); Thread.sleep(1000L); runner.run(100); runner.assertAllFlowFilesTransferred(TailFile.REL_SUCCESS, 0); }
protected PropertyDescriptor buildStrategyProperty(AllowableValue[] values) { return new PropertyDescriptor.Builder() .fromPropertyDescriptor(SCHEMA_ACCESS_STRATEGY) .allowableValues(values) .defaultValue(getDefaultSchemaAccessStrategy().getValue()) .build(); }
@Test public void testInvalidRecordPathUsingExpressionLanguage() { runner.setProperty("/name", "${recordPath}"); runner.setProperty(UpdateRecord.REPLACEMENT_VALUE_STRATEGY, UpdateRecord.RECORD_PATH_VALUES.getValue()); runner.enqueue("", Collections.singletonMap("recordPath", "hello")); readerService.addRecord("John Doe", 35); runner.run(); runner.assertAllFlowFilesTransferred(UpdateRecord.REL_FAILURE, 1); }
@Test public void testTLS() throws InitializationException, IOException, InterruptedException { configureSSLContextService(listenSyslogRunner); listenSyslogRunner.setProperty(ListenSyslog.SSL_CONTEXT_SERVICE, "ssl-context"); configureSSLContextService(putSyslogRunner); putSyslogRunner.setProperty(PutSyslog.SSL_CONTEXT_SERVICE, "ssl-context"); run(ListenSyslog.TCP_VALUE.getValue(), 7, 7); }