Search in sources :

Example 26 with CarbonTableIdentifier

use of org.apache.carbondata.core.metadata.CarbonTableIdentifier in project carbondata by apache.

the class ZooKeeperLockingTest method testZooKeeperLockingByTryingToAcquire2Locks.

@Test
public void testZooKeeperLockingByTryingToAcquire2Locks() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
    final CarbonProperties cp = CarbonProperties.getInstance();
    new NonStrictExpectations(cp) {

        {
            cp.getProperty("/CarbonLocks");
            result = "/carbontests";
            cp.getProperty("spark.deploy.zookeeper.url");
            result = "127.0.0.1:" + freePort;
        }
    };
    ZookeeperInit zki = ZookeeperInit.getInstance("127.0.0.1:" + freePort);
    CarbonTableIdentifier tableIdentifier = new CarbonTableIdentifier("dbName", "tableName", "tableId");
    ZooKeeperLocking zkl = new ZooKeeperLocking(tableIdentifier, LockUsage.METADATA_LOCK);
    Assert.assertTrue(zkl.lock());
    ZooKeeperLocking zk2 = new ZooKeeperLocking(tableIdentifier, LockUsage.METADATA_LOCK);
    Assert.assertTrue(!zk2.lock());
    Assert.assertTrue(zkl.unlock());
    Assert.assertTrue(zk2.lock());
    Assert.assertTrue(zk2.unlock());
}
Also used : ZooKeeperLocking(org.apache.carbondata.core.locks.ZooKeeperLocking) CarbonTableIdentifier(org.apache.carbondata.core.metadata.CarbonTableIdentifier) CarbonProperties(org.apache.carbondata.core.util.CarbonProperties) ZookeeperInit(org.apache.carbondata.core.locks.ZookeeperInit) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Example 27 with CarbonTableIdentifier

use of org.apache.carbondata.core.metadata.CarbonTableIdentifier in project carbondata by apache.

the class TableBlockUniqueIdentifier method getUniqueTableBlockName.

/**
   * returns the String value to uniquely identify a block
   *
   * @return
   */
public String getUniqueTableBlockName() {
    BlockInfo blockInfo = new BlockInfo(this.tableBlockInfo);
    CarbonTableIdentifier carbonTableIdentifier = this.absoluteTableIdentifier.getCarbonTableIdentifier();
    return carbonTableIdentifier.getDatabaseName() + CarbonCommonConstants.FILE_SEPARATOR + carbonTableIdentifier.getDatabaseName() + CarbonCommonConstants.FILE_SEPARATOR + this.tableBlockInfo.getSegmentId() + CarbonCommonConstants.FILE_SEPARATOR + blockInfo.hashCode();
}
Also used : CarbonTableIdentifier(org.apache.carbondata.core.metadata.CarbonTableIdentifier)

Example 28 with CarbonTableIdentifier

use of org.apache.carbondata.core.metadata.CarbonTableIdentifier in project carbondata by apache.

the class DataConverterProcessorStepImpl method close.

@Override
public void close() {
    if (!closed) {
        if (null != badRecordLogger) {
            badRecordLogger.closeStreams();
            // rename the bad record in progress to normal
            CarbonTableIdentifier identifier = configuration.getTableIdentifier().getCarbonTableIdentifier();
            CarbonDataProcessorUtil.renameBadRecordsFromInProgressToNormal(identifier.getDatabaseName() + File.separator + identifier.getTableName() + File.separator + configuration.getSegmentId() + File.separator + configuration.getTaskNo());
        }
        super.close();
        if (converters != null) {
            for (RowConverter converter : converters) {
                converter.finish();
            }
        }
    }
}
Also used : CarbonTableIdentifier(org.apache.carbondata.core.metadata.CarbonTableIdentifier) RowConverter(org.apache.carbondata.processing.newflow.converter.RowConverter)

Example 29 with CarbonTableIdentifier

use of org.apache.carbondata.core.metadata.CarbonTableIdentifier in project carbondata by apache.

the class DataConverterProcessorStepImpl method createBadRecordLogger.

private BadRecordsLogger createBadRecordLogger() {
    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(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.processing.constants.LoggerAction) BadRecordsLogger(org.apache.carbondata.processing.surrogatekeysgenerator.csvbased.BadRecordsLogger)

Example 30 with CarbonTableIdentifier

use of org.apache.carbondata.core.metadata.CarbonTableIdentifier in project carbondata by apache.

the class DataConverterProcessorWithBucketingStepImpl method createBadRecordLogger.

private BadRecordsLogger createBadRecordLogger() {
    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(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.processing.constants.LoggerAction) BadRecordsLogger(org.apache.carbondata.processing.surrogatekeysgenerator.csvbased.BadRecordsLogger)

Aggregations

CarbonTableIdentifier (org.apache.carbondata.core.metadata.CarbonTableIdentifier)42 Test (org.junit.Test)13 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)7 ColumnIdentifier (org.apache.carbondata.core.metadata.ColumnIdentifier)7 AbsoluteTableIdentifier (org.apache.carbondata.core.metadata.AbsoluteTableIdentifier)6 CarbonTablePath (org.apache.carbondata.core.util.path.CarbonTablePath)6 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)5 Before (org.junit.Before)5 BeforeClass (org.junit.BeforeClass)5 TableBlockInfo (org.apache.carbondata.core.datastore.block.TableBlockInfo)4 File (java.io.File)3 HashMap (java.util.HashMap)3 AbstractIndex (org.apache.carbondata.core.datastore.block.AbstractIndex)3 TableBlockUniqueIdentifier (org.apache.carbondata.core.datastore.block.TableBlockUniqueIdentifier)3 CarbonDataLoadingException (org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException)3 Iterator (java.util.Iterator)2 ExecutorService (java.util.concurrent.ExecutorService)2 ICarbonLock (org.apache.carbondata.core.locks.ICarbonLock)2 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)2