@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 AllowableValue buildDefaultWeakCryptoAllowableValue() { return new AllowableValue(WEAK_CRYPTO_NOT_ALLOWED_NAME, "Not Allowed", "When set, operation will be blocked and alerts will be presented to the user " + "if unsafe combinations of encryption algorithms and passwords are provided on a JVM with limited strength crypto. To fix this, see the Admin Guide."); }
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; }
private boolean shouldReportOnlyOnPrimary(boolean isClusterScope, final ProcessContext context) { if (REPORT_NODE_PRIMARY.equals(context.getProperty(REPORTING_NODE).getValue())) { if (isClusterScope) { return true; } } return false; }
private static void validateRequiredProperty(ValidationContext context, Collection<ValidationResult> results, PropertyDescriptor property) { if (!context.getProperty(property).isSet()) { final String displayName = property.getDisplayName(); results.add(new ValidationResult.Builder() .subject(displayName) .explanation(format("'%s' is required to use '%s' listing strategy", displayName, AbstractListProcessor.BY_ENTITIES.getDisplayName())) .valid(false) .build()); } }
@Override public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { final String listingStrategy = context.getProperty(LISTING_STRATEGY).getValue(); if (BY_TIMESTAMPS.equals(listingStrategy)) { listByTrackingTimestamps(context, session); } else if (BY_ENTITIES.equals(listingStrategy)) { listByTrackingEntities(context, session); } else { throw new ProcessException("Unknown listing strategy: " + listingStrategy); } }
static void validateProperties(ValidationContext context, Collection<ValidationResult> results, Scope scope) { validateRequiredProperty(context, results, ListedEntityTracker.TRACKING_STATE_CACHE); validateRequiredProperty(context, results, ListedEntityTracker.TRACKING_TIME_WINDOW); if (Scope.LOCAL.equals(scope) && StringUtils.isEmpty(context.getProperty(NODE_IDENTIFIER).evaluateAttributeExpressions().getValue())) { results.add(new ValidationResult.Builder() .subject(NODE_IDENTIFIER.getDisplayName()) .explanation(format("'%s' is required to use local scope with '%s' listing strategy", NODE_IDENTIFIER.getDisplayName(), AbstractListProcessor.BY_ENTITIES.getDisplayName())) .build()); } }
@Override protected Collection<ValidationResult> customValidate(final ValidationContext validationContext) { if (!validationContext.getProperty(ARRAY_WRAPPING).getValue().equals(NO_WRAPPING.getValue())) { if (!validationContext.getProperty(ARRAY_TAG_NAME).isSet()) { StringBuilder explanation = new StringBuilder() .append("if property \'") .append(ARRAY_WRAPPING.getName()) .append("\' is defined as \'") .append(USE_PROPERTY_AS_WRAPPER.getDisplayName()) .append("\' or \'") .append(USE_PROPERTY_FOR_ELEMENTS.getDisplayName()) .append("\' the property \'") .append(ARRAY_TAG_NAME.getDisplayName()) .append("\' has to be set."); return Collections.singleton(new ValidationResult.Builder() .subject(ARRAY_TAG_NAME.getName()) .valid(false) .explanation(explanation.toString()) .build()); } } return Collections.emptyList(); }
/** * @param values contrained set of values * @return the builder */ public Builder allowableValues(final Set<String> values) { if (null != values) { this.allowableValues = new ArrayList<>(); for (final String value : values) { this.allowableValues.add(new AllowableValue(value, value)); } } return this; }
@Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { if (descriptor.equals(ROUTE_STRATEGY)) { configuredRouteStrategy = newValue; } else { final Set<String> newDynamicPropertyNames = new HashSet<>(dynamicPropertyNames); if (newValue == null) { newDynamicPropertyNames.remove(descriptor.getName()); } else if (oldValue == null) { // new property newDynamicPropertyNames.add(descriptor.getName()); } this.dynamicPropertyNames = Collections.unmodifiableSet(newDynamicPropertyNames); } // formulate the new set of Relationships final Set<String> allDynamicProps = this.dynamicPropertyNames; final Set<Relationship> newRelationships = new HashSet<>(); final String routeStrategy = configuredRouteStrategy; if (ROUTE_PROPERTY_NAME.equals(routeStrategy)) { for (final String propName : allDynamicProps) { newRelationships.add(new Relationship.Builder().name(propName).build()); } } else { newRelationships.add(REL_MATCH); } newRelationships.add(REL_NO_MATCH); this.relationships.set(newRelationships); }
private boolean isValueAllowed(final String value) { if (allowableValues == null || value == null) { return true; } for (final AllowableValue allowableValue : allowableValues) { if (allowableValue.getValue().equals(value)) { return true; } } return false; }
@Override protected Collection<ValidationResult> customValidate(ValidationContext validationContext) { final List<ValidationResult> problems = new ArrayList<>(super.customValidate(validationContext)); final boolean isWriterSet = validationContext.getProperty(RECORD_WRITER).isSet(); if (validationContext.getProperty(FORMAT).getValue().equals(RECORD_FORMAT.getValue()) && !isWriterSet) { problems.add(new ValidationResult.Builder() .input("Record Writer") .valid(false) .explanation("If using " + RECORD_FORMAT.getDisplayName() + ", a record writer needs to be set.") .build()); } if (validationContext.getProperty(FORMAT).getValue().equals(AMBARI_FORMAT.getValue()) && isWriterSet) { problems.add(new ValidationResult.Builder() .input("Record Writer") .valid(false) .explanation("If using " + AMBARI_FORMAT.getDisplayName() + ", no record writer should be set.") .build()); } return problems; }
/** * @param values constrained set of values * @return the builder */ public Builder allowableValues(final String... values) { if (null != values) { this.allowableValues = new ArrayList<>(); for (final String value : values) { allowableValues.add(new AllowableValue(value, value)); } } return this; }
private SslContextFactory createSslFactory(final ConfigurationContext context) { final SSLContextService sslService = context.getProperty(SSL_CONTEXT).asControllerService(SSLContextService.class); final String clientAuthValue = context.getProperty(CLIENT_AUTH).getValue(); final boolean need; final boolean want; if (CLIENT_NEED.equals(clientAuthValue)) { need = true; want = false; } else if (CLIENT_WANT.equals(clientAuthValue)) { need = false; want = true; } else { need = false; want = false; } final SslContextFactory sslFactory = (sslService == null) ? null : createSslFactory(sslService, need, want); return sslFactory; }
private static boolean isSchemaRegistryRequired(final String schemaAccessValue) { return HWX_CONTENT_ENCODED_SCHEMA.getValue().equalsIgnoreCase(schemaAccessValue) || SCHEMA_NAME_PROPERTY.getValue().equalsIgnoreCase(schemaAccessValue) || HWX_SCHEMA_REF_ATTRIBUTES.getValue().equalsIgnoreCase(schemaAccessValue) || CONFLUENT_ENCODED_SCHEMA.getValue().equalsIgnoreCase(schemaAccessValue); }
@Override protected Collection<ValidationResult> customValidate(final ValidationContext validationContext) { final List<ValidationResult> results = new ArrayList<>(); if (COMPLETION_MOVE.getValue().equalsIgnoreCase(validationContext.getProperty(COMPLETION_STRATEGY).getValue())) { if (!validationContext.getProperty(MOVE_DESTINATION_DIR).isSet()) { results.add(new ValidationResult.Builder().subject(MOVE_DESTINATION_DIR.getName()).input(null).valid(false).explanation( MOVE_DESTINATION_DIR.getName() + " must be specified if " + COMPLETION_STRATEGY.getName() + " is set to " + COMPLETION_MOVE.getDisplayName()).build()); } } return results; }
public <E extends Enum<E>> Builder allowableValues(final E[] values) { if (null != values) { this.allowableValues = new ArrayList<>(); for (final E value : values) { allowableValues.add(new AllowableValue(value.name(), value.name())); } } return this; }
private void initLineageStrategy(ConfigurationContext context) throws IOException { nifiAtlasHook = new NiFiAtlasHook(); final String strategy = context.getProperty(NIFI_LINEAGE_STRATEGY).getValue(); if (LINEAGE_STRATEGY_SIMPLE_PATH.equals(strategy)) { lineageStrategy = new SimpleFlowPathLineage(); } else if (LINEAGE_STRATEGY_COMPLETE_PATH.equals(strategy)) { lineageStrategy = new CompleteFlowPathLineage(); } lineageStrategy.setLineageContext(nifiAtlasHook); initProvenanceConsumer(context); }
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 } }