use of org.apache.carbondata.common.constants.LoggerAction in project carbondata by apache.
the class CarbonDataProcessorUtil method isRawDataRequired.
/**
* The method returns true is either logger is enabled or action is redirect
* @param configuration
* @return
*/
public static boolean isRawDataRequired(CarbonDataLoadConfiguration configuration) {
boolean isRawDataRequired = Boolean.parseBoolean(configuration.getDataLoadProperty(DataLoadProcessorConstants.BAD_RECORDS_LOGGER_ENABLE).toString());
// if logger is disabled then check if action is redirect then raw data will be required.
if (!isRawDataRequired) {
Object bad_records_action = configuration.getDataLoadProperty(DataLoadProcessorConstants.BAD_RECORDS_LOGGER_ACTION);
if (null != bad_records_action) {
LoggerAction loggerAction = null;
try {
loggerAction = LoggerAction.valueOf(bad_records_action.toString().toUpperCase());
} catch (IllegalArgumentException e) {
loggerAction = LoggerAction.FORCE;
}
isRawDataRequired = loggerAction == LoggerAction.REDIRECT;
}
}
return isRawDataRequired;
}
use of org.apache.carbondata.common.constants.LoggerAction 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