Search in sources :

Example 51 with CarbonTableIdentifier

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);
}
Also used : CarbonTableIdentifier(org.apache.carbondata.core.metadata.CarbonTableIdentifier) LoggerAction(org.apache.carbondata.common.constants.LoggerAction)

Aggregations

CarbonTableIdentifier (org.apache.carbondata.core.metadata.CarbonTableIdentifier)51 IOException (java.io.IOException)11 Test (org.junit.Test)11 AbsoluteTableIdentifier (org.apache.carbondata.core.metadata.AbsoluteTableIdentifier)10 ArrayList (java.util.ArrayList)9 ColumnIdentifier (org.apache.carbondata.core.metadata.ColumnIdentifier)7 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)6 File (java.io.File)5 DictionaryColumnUniqueIdentifier (org.apache.carbondata.core.cache.dictionary.DictionaryColumnUniqueIdentifier)5 Before (org.junit.Before)5 BeforeClass (org.junit.BeforeClass)5 HashMap (java.util.HashMap)4 Iterator (java.util.Iterator)4 TableBlockInfo (org.apache.carbondata.core.datastore.block.TableBlockInfo)4 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)4 CarbonFactDataHandlerModel (org.apache.carbondata.processing.store.CarbonFactDataHandlerModel)4 CarbonFactHandler (org.apache.carbondata.processing.store.CarbonFactHandler)4 ExecutorService (java.util.concurrent.ExecutorService)3 AbstractIndex (org.apache.carbondata.core.datastore.block.AbstractIndex)3 TableBlockUniqueIdentifier (org.apache.carbondata.core.datastore.block.TableBlockUniqueIdentifier)3