Search in sources :

Example 21 with CarbonDataLoadingException

use of org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException in project carbondata by apache.

the class UnsafeParallelReadMergeSorterWithColumnRangeImpl method processRowToNextStep.

/**
 * Below method will be used to process data to next step
 */
private boolean processRowToNextStep(UnsafeSortDataRows[] sortDataRows, SortParameters parameters) throws CarbonDataLoadingException {
    if (null == sortDataRows || sortDataRows.length == 0) {
        LOGGER.info("Record Processed For table: " + parameters.getTableName());
        LOGGER.info("Number of Records was Zero");
        String logMessage = "Summary: Carbon Sort Key Step: Read: " + 0 + ": Write: " + 0;
        LOGGER.info(logMessage);
        return false;
    }
    try {
        for (int i = 0; i < sortDataRows.length; i++) {
            // start sorting
            sortDataRows[i].startSorting();
        }
        // check any more rows are present
        LOGGER.info("Record Processed For table: " + parameters.getTableName());
        CarbonTimeStatisticsFactory.getLoadStatisticsInstance().recordSortRowsStepTotalTime(parameters.getPartitionID(), System.currentTimeMillis());
        CarbonTimeStatisticsFactory.getLoadStatisticsInstance().recordDictionaryValuesTotalTime(parameters.getPartitionID(), System.currentTimeMillis());
        return false;
    } catch (Exception e) {
        throw new CarbonDataLoadingException(e);
    }
}
Also used : CarbonDataLoadingException(org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException) MemoryException(org.apache.carbondata.core.memory.MemoryException) CarbonDataLoadingException(org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException)

Example 22 with CarbonDataLoadingException

use of org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException in project carbondata by apache.

the class DataLoadExecutor method execute.

public void execute(CarbonLoadModel loadModel, String[] storeLocation, CarbonIterator<Object[]>[] inputIterators) throws Exception {
    try {
        loadProcessorStep = new DataLoadProcessBuilder().build(loadModel, storeLocation, inputIterators);
        // 1. initialize
        loadProcessorStep.initialize();
        LOGGER.info("Data Loading is started for table " + loadModel.getTableName());
        // 2. execute the step
        loadProcessorStep.execute();
        // check and remove any bad record key from bad record entry logger static map
        if (CarbonBadRecordUtil.hasBadRecord(loadModel)) {
            LOGGER.error("Data Load is partially success for table " + loadModel.getTableName());
        } else {
            LOGGER.info("Data loading is successful for table " + loadModel.getTableName());
        }
    } catch (CarbonDataLoadingException e) {
        if (e instanceof BadRecordFoundException) {
            throw new NoRetryException(e.getMessage());
        } else {
            throw e;
        }
    } catch (Exception e) {
        LOGGER.error(e, "Data Loading failed for table " + loadModel.getTableName());
        throw new CarbonDataLoadingException("Data Loading failed for table " + loadModel.getTableName(), e);
    }
}
Also used : CarbonDataLoadingException(org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException) NoRetryException(org.apache.carbondata.processing.loading.exception.NoRetryException) CarbonDataLoadingException(org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException) NoRetryException(org.apache.carbondata.processing.loading.exception.NoRetryException) BadRecordFoundException(org.apache.carbondata.processing.loading.exception.BadRecordFoundException) BadRecordFoundException(org.apache.carbondata.processing.loading.exception.BadRecordFoundException)

Example 23 with CarbonDataLoadingException

use of org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException in project carbondata by apache.

the class BadRecordsLogger method writeBadRecordsToFile.

/**
 */
private synchronized void writeBadRecordsToFile(StringBuilder logStrings) throws CarbonDataLoadingException {
    if (null == logFilePath) {
        logFilePath = this.storePath + File.separator + this.fileName + CarbonCommonConstants.LOG_FILE_EXTENSION + CarbonCommonConstants.FILE_INPROGRESS_STATUS;
    }
    try {
        if (null == bufferedWriter) {
            FileType fileType = FileFactory.getFileType(storePath);
            if (!FileFactory.isFileExist(this.storePath, fileType)) {
                // create the folders if not exist
                FileFactory.mkdirs(this.storePath, fileType);
                // create the files
                FileFactory.createNewFile(logFilePath, fileType);
            }
            outStream = FileFactory.getDataOutputStream(logFilePath, fileType);
            bufferedWriter = new BufferedWriter(new OutputStreamWriter(outStream, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET)));
        }
        bufferedWriter.write(logStrings.toString());
        bufferedWriter.newLine();
    } catch (FileNotFoundException e) {
        LOGGER.error("Bad Log Files not found");
        throw new CarbonDataLoadingException("Bad Log Files not found", e);
    } catch (IOException e) {
        LOGGER.error("Error While writing bad record log File");
        throw new CarbonDataLoadingException("Error While writing bad record log File", e);
    } finally {
        // if the Bad record file is created means it partially success
        // if any entry present with key that means its have bad record for
        // that key
        badRecordEntry.put(taskKey, "Partially");
    }
}
Also used : CarbonDataLoadingException(org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException) FileType(org.apache.carbondata.core.datastore.impl.FileFactory.FileType) FileNotFoundException(java.io.FileNotFoundException) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter)

Example 24 with CarbonDataLoadingException

use of org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException in project carbondata by apache.

the class BadRecordsLogger method writeBadRecordsToCSVFile.

/**
 * method will write the row having bad record in the csv file.
 *
 * @param logStrings
 */
private synchronized void writeBadRecordsToCSVFile(StringBuilder logStrings) throws CarbonDataLoadingException {
    if (null == csvFilePath) {
        csvFilePath = this.storePath + File.separator + this.fileName + CarbonCommonConstants.CSV_FILE_EXTENSION + CarbonCommonConstants.FILE_INPROGRESS_STATUS;
    }
    try {
        if (null == bufferedCSVWriter) {
            FileType fileType = FileFactory.getFileType(storePath);
            if (!FileFactory.isFileExist(this.storePath, fileType)) {
                // create the folders if not exist
                FileFactory.mkdirs(this.storePath, fileType);
                // create the files
                FileFactory.createNewFile(csvFilePath, fileType);
            }
            outCSVStream = FileFactory.getDataOutputStream(csvFilePath, fileType);
            bufferedCSVWriter = new BufferedWriter(new OutputStreamWriter(outCSVStream, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET)));
        }
        bufferedCSVWriter.write(logStrings.toString());
        bufferedCSVWriter.newLine();
    } catch (FileNotFoundException e) {
        LOGGER.error("Bad record csv Files not found");
        throw new CarbonDataLoadingException("Bad record csv Files not found", e);
    } catch (IOException e) {
        LOGGER.error("Error While writing bad record csv File");
        throw new CarbonDataLoadingException("Error While writing bad record csv File", e);
    } finally {
        badRecordEntry.put(taskKey, "Partially");
    }
}
Also used : CarbonDataLoadingException(org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException) FileType(org.apache.carbondata.core.datastore.impl.FileFactory.FileType) FileNotFoundException(java.io.FileNotFoundException) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter)

Aggregations

CarbonDataLoadingException (org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException)24 IOException (java.io.IOException)10 CarbonDataWriterException (org.apache.carbondata.core.datastore.exception.CarbonDataWriterException)9 Iterator (java.util.Iterator)8 CarbonSortKeyAndGroupByException (org.apache.carbondata.processing.sort.exception.CarbonSortKeyAndGroupByException)6 CarbonIterator (org.apache.carbondata.common.CarbonIterator)5 KeyGenException (org.apache.carbondata.core.keygenerator.KeyGenException)5 ExecutorService (java.util.concurrent.ExecutorService)4 CarbonRow (org.apache.carbondata.core.datastore.row.CarbonRow)4 MemoryException (org.apache.carbondata.core.memory.MemoryException)4 CarbonThreadFactory (org.apache.carbondata.core.util.CarbonThreadFactory)4 BadRecordFoundException (org.apache.carbondata.processing.loading.exception.BadRecordFoundException)4 CarbonRowBatch (org.apache.carbondata.processing.loading.row.CarbonRowBatch)4 ExecutionException (java.util.concurrent.ExecutionException)3 BufferedWriter (java.io.BufferedWriter)2 FileNotFoundException (java.io.FileNotFoundException)2 OutputStreamWriter (java.io.OutputStreamWriter)2 Future (java.util.concurrent.Future)2 FileType (org.apache.carbondata.core.datastore.impl.FileFactory.FileType)2 CarbonTableIdentifier (org.apache.carbondata.core.metadata.CarbonTableIdentifier)2