use of com.thinkbiganalytics.nifi.v2.sqoop.PasswordMode in project kylo by Teradata.
the class ImportSqoop method customValidate.
/**
* Called by the framework, this method does additional validation on properties
*
* @param validationContext used to retrieves the properties to check
* @return A collection of {@link ValidationResult} which will be checked by the framework
*/
@Override
protected Collection<ValidationResult> customValidate(ValidationContext validationContext) {
final List<ValidationResult> results = new ArrayList<>();
final SqoopLoadStrategy sourceLoadStrategy = SqoopLoadStrategy.valueOf(validationContext.getProperty(SOURCE_LOAD_STRATEGY).getValue());
final String sourceCheckColumnName = validationContext.getProperty(SOURCE_CHECK_COLUMN_NAME).evaluateAttributeExpressions().getValue();
final String sourceCheckColumnLastValue = validationContext.getProperty(SOURCE_CHECK_COLUMN_LAST_VALUE).evaluateAttributeExpressions().getValue();
final HiveDelimStrategy targetHiveDelimStrategy = HiveDelimStrategy.valueOf(validationContext.getProperty(TARGET_HIVE_DELIM_STRATEGY).getValue());
final String targetHiveReplaceDelim = validationContext.getProperty(TARGET_HIVE_REPLACE_DELIM).evaluateAttributeExpressions().getValue();
final SqoopConnectionService sqoopConnectionService = validationContext.getProperty(SQOOP_CONNECTION_SERVICE).asControllerService(SqoopConnectionService.class);
final PasswordMode passwordMode = sqoopConnectionService.getPasswordMode();
final ExtractDataFormat targetExtractDataFormat = ExtractDataFormat.valueOf(validationContext.getProperty(TARGET_EXTRACT_DATA_FORMAT).getValue());
final CompressionAlgorithm targetCompressionAlgorithm = CompressionAlgorithm.valueOf(validationContext.getProperty(TARGET_COMPRESSION_ALGORITHM).getValue());
final String targetColumnTypeMapping = validationContext.getProperty(TARGET_COLUMN_TYPE_MAPPING).evaluateAttributeExpressions().getValue();
SqoopUtils sqoopUtils = new SqoopUtils();
if (sourceLoadStrategy == SqoopLoadStrategy.INCREMENTAL_LASTMODIFIED || sourceLoadStrategy == SqoopLoadStrategy.INCREMENTAL_APPEND) {
if ((sourceCheckColumnName == null) || (sourceCheckColumnLastValue == null)) {
results.add(new ValidationResult.Builder().subject(this.getClass().getSimpleName()).valid(false).explanation("Both 'Check Column Name' and 'Check Column Last Value' are required for incremental load.").build());
}
}
if (targetHiveDelimStrategy == HiveDelimStrategy.REPLACE) {
if (targetHiveReplaceDelim == null) {
results.add(new ValidationResult.Builder().subject(this.getClass().getSimpleName()).valid(false).explanation("Replacement delimiter must be specified for Hive Delimiter REPLACE Strategy.").build());
}
}
if (passwordMode == PasswordMode.ENCRYPTED_ON_HDFS_FILE) {
if (sqoopConnectionService.getPasswordHdfsFile() == null || sqoopConnectionService.getPasswordPassphrase() == null) {
results.add(new ValidationResult.Builder().subject(this.getClass().getSimpleName()).valid(false).explanation("For encrypted password on HDFS, both encrypted HDFS file location and passphrase are required.").build());
}
} else if (passwordMode == PasswordMode.ENCRYPTED_TEXT_ENTRY) {
if (sqoopConnectionService.getEnteredPassword() == null || sqoopConnectionService.getPasswordPassphrase() == null) {
results.add(new ValidationResult.Builder().subject(this.getClass().getSimpleName()).valid(false).explanation("For encrypted password entry mode, both the encrypted password and passphrase are required.").build());
}
} else if (passwordMode == PasswordMode.CLEAR_TEXT_ENTRY) {
if (sqoopConnectionService.getEnteredPassword() == null) {
results.add(new ValidationResult.Builder().subject(this.getClass().getSimpleName()).valid(false).explanation("For clear text password entry mode, the password must be provided.").build());
}
}
if ((targetExtractDataFormat == ExtractDataFormat.PARQUET) && (targetCompressionAlgorithm != CompressionAlgorithm.NONE)) {
results.add(new ValidationResult.Builder().subject(this.getClass().getSimpleName()).valid(false).explanation("For PARQUET data format, compression is not supported.").build());
}
if ((sqoopUtils.isTeradataDatabase(sqoopConnectionService.getConnectionString()) && (sourceLoadStrategy == SqoopLoadStrategy.INCREMENTAL_LASTMODIFIED))) {
results.add(new ValidationResult.Builder().subject(this.getClass().getSimpleName()).valid(false).explanation("For Teradata source system, INCREMENTAL_LASTMODIFIED mode of load is not supported. This is due to a known issue with Sqoop (SQOOP-2402).").build());
}
if ((targetColumnTypeMapping != null) && (!targetColumnTypeMapping.isEmpty())) {
if (!sqoopUtils.checkMappingInput(targetColumnTypeMapping)) {
results.add(new ValidationResult.Builder().subject(this.getClass().getSimpleName()).valid(false).explanation("For Target Column Type Mapping, ensure that mappings are provided as COLUMN=Type pairs separated by comma. " + "Ensure no spaces in entry. " + "Example: PO_ID=Integer,PO_DETAILS=String").build());
}
}
return results;
}
Aggregations