use of org.apache.carbondata.core.metadata.CarbonTableIdentifier in project carbondata by apache.
the class BadRecordsLoggerProvider method createBadRecordLogger.
/**
* method returns the BadRecordsLogger instance
* @param configuration
* @return
*/
public static BadRecordsLogger createBadRecordLogger(CarbonDataLoadConfiguration configuration) {
boolean badRecordsLogRedirect = false;
boolean badRecordConvertNullDisable = false;
boolean isDataLoadFail = false;
boolean badRecordsLoggerEnable = Boolean.parseBoolean(configuration.getDataLoadProperty(DataLoadProcessorConstants.BAD_RECORDS_LOGGER_ENABLE).toString());
Object bad_records_action = configuration.getDataLoadProperty(DataLoadProcessorConstants.BAD_RECORDS_LOGGER_ACTION).toString();
if (null != bad_records_action) {
LoggerAction loggerAction = null;
try {
loggerAction = LoggerAction.valueOf(bad_records_action.toString().toUpperCase());
} catch (IllegalArgumentException e) {
loggerAction = LoggerAction.FORCE;
}
switch(loggerAction) {
case FORCE:
badRecordConvertNullDisable = false;
break;
case REDIRECT:
badRecordsLogRedirect = true;
badRecordConvertNullDisable = true;
break;
case IGNORE:
badRecordsLogRedirect = false;
badRecordConvertNullDisable = true;
break;
case FAIL:
isDataLoadFail = true;
break;
}
}
CarbonTableIdentifier identifier = configuration.getTableIdentifier().getCarbonTableIdentifier();
return new BadRecordsLogger(identifier.getBadRecordLoggerKey(), identifier.getTableName() + '_' + System.currentTimeMillis(), getBadLogStoreLocation(configuration, identifier.getDatabaseName() + CarbonCommonConstants.FILE_SEPARATOR + identifier.getTableName() + CarbonCommonConstants.FILE_SEPARATOR + configuration.getSegmentId() + CarbonCommonConstants.FILE_SEPARATOR + configuration.getTaskNo()), badRecordsLogRedirect, badRecordsLoggerEnable, badRecordConvertNullDisable, isDataLoadFail);
}
Aggregations