Search in sources :

Example 1 with ConfigurationTable

use of co.cask.cdap.data2.util.hbase.ConfigurationTable in project cdap by caskdata.

the class HBaseQueueTest method init.

@BeforeClass
public static void init() throws Exception {
    hConf = TEST_HBASE.getConfiguration();
    // Customize test configuration
    cConf = CConfiguration.create();
    cConf.set(Constants.Zookeeper.QUORUM, TEST_HBASE.getZkConnectionString());
    cConf.set(TxConstants.Service.CFG_DATA_TX_BIND_PORT, Integer.toString(Networks.getRandomPort()));
    cConf.set(Constants.Dataset.TABLE_PREFIX, TABLE_PREFIX);
    cConf.set(Constants.CFG_HDFS_USER, System.getProperty("user.name"));
    cConf.setLong(QueueConstants.QUEUE_CONFIG_UPDATE_FREQUENCY, 10000L);
    // Test with fewer splits than default (16).
    // Fewer splits make the forceEvict runs faster, which makes all queue tests run faster
    cConf.setInt(QueueConstants.ConfigKeys.QUEUE_TABLE_PRESPLITS, 4);
    cConf.setLong(TxConstants.Manager.CFG_TX_TIMEOUT, 100000000L);
    cConf.setLong(TxConstants.Manager.CFG_TX_MAX_TIMEOUT, 100000000L);
    injector = Guice.createInjector(new DataFabricModules().getDistributedModules(), new ConfigModule(cConf, hConf), new ZKClientModule(), new LocationRuntimeModule().getDistributedModules(), new NamespaceClientUnitTestModule().getModule(), new DiscoveryRuntimeModule().getDistributedModules(), new TransactionMetricsModule(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), new DataSetsModules().getInMemoryModules(), new SystemDatasetRuntimeModule().getDistributedModules(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(NotificationFeedManager.class).to(NoOpNotificationFeedManager.class).in(Scopes.SINGLETON);
            bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
            bind(UGIProvider.class).to(UnsupportedUGIProvider.class);
        }
    });
    //create HBase namespace
    hbaseAdmin = TEST_HBASE.getHBaseAdmin();
    ddlExecutor = new HBaseDDLExecutorFactory(cConf, hbaseAdmin.getConfiguration()).get();
    tableUtil = injector.getInstance(HBaseTableUtil.class);
    ddlExecutor.createNamespaceIfNotExists(tableUtil.getHBaseNamespace(NamespaceId.SYSTEM));
    ddlExecutor.createNamespaceIfNotExists(tableUtil.getHBaseNamespace(NAMESPACE_ID));
    ddlExecutor.createNamespaceIfNotExists(tableUtil.getHBaseNamespace(NAMESPACE_ID1));
    ConfigurationTable configTable = new ConfigurationTable(hConf);
    configTable.write(ConfigurationTable.Type.DEFAULT, cConf);
    zkClientService = injector.getInstance(ZKClientService.class);
    zkClientService.startAndWait();
    txService = injector.getInstance(TransactionService.class);
    Thread t = new Thread() {

        @Override
        public void run() {
            txService.start();
        }
    };
    t.start();
    // The TransactionManager should be started by the txService.
    // We just want a reference to that so that we can ask for tx snapshot
    txSystemClient = injector.getInstance(TransactionSystemClient.class);
    queueClientFactory = injector.getInstance(QueueClientFactory.class);
    queueAdmin = injector.getInstance(QueueAdmin.class);
    executorFactory = injector.getInstance(TransactionExecutorFactory.class);
}
Also used : ConfigModule(co.cask.cdap.common.guice.ConfigModule) UGIProvider(co.cask.cdap.security.impersonation.UGIProvider) UnsupportedUGIProvider(co.cask.cdap.security.impersonation.UnsupportedUGIProvider) TransactionMetricsModule(co.cask.cdap.data.runtime.TransactionMetricsModule) TransactionExecutorFactory(org.apache.tephra.TransactionExecutorFactory) ZKClientModule(co.cask.cdap.common.guice.ZKClientModule) TransactionSystemClient(org.apache.tephra.TransactionSystemClient) HBaseDDLExecutorFactory(co.cask.cdap.data2.util.hbase.HBaseDDLExecutorFactory) SystemDatasetRuntimeModule(co.cask.cdap.data.runtime.SystemDatasetRuntimeModule) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) NamespaceClientUnitTestModule(co.cask.cdap.common.guice.NamespaceClientUnitTestModule) TransactionService(org.apache.tephra.distributed.TransactionService) AuthenticationContextModules(co.cask.cdap.security.auth.context.AuthenticationContextModules) DataSetsModules(co.cask.cdap.data.runtime.DataSetsModules) DefaultOwnerAdmin(co.cask.cdap.security.impersonation.DefaultOwnerAdmin) OwnerAdmin(co.cask.cdap.security.impersonation.OwnerAdmin) LocationRuntimeModule(co.cask.cdap.common.guice.LocationRuntimeModule) AuthorizationTestModule(co.cask.cdap.security.authorization.AuthorizationTestModule) HBaseTableUtil(co.cask.cdap.data2.util.hbase.HBaseTableUtil) AbstractModule(com.google.inject.AbstractModule) QueueAdmin(co.cask.cdap.data2.transaction.queue.QueueAdmin) ZKClientService(org.apache.twill.zookeeper.ZKClientService) ConfigurationTable(co.cask.cdap.data2.util.hbase.ConfigurationTable) QueueClientFactory(co.cask.cdap.data2.queue.QueueClientFactory) NoOpNotificationFeedManager(co.cask.cdap.notifications.feeds.service.NoOpNotificationFeedManager) DataFabricModules(co.cask.cdap.data.runtime.DataFabricModules) AuthorizationEnforcementModule(co.cask.cdap.security.authorization.AuthorizationEnforcementModule) BeforeClass(org.junit.BeforeClass)

Example 2 with ConfigurationTable

use of co.cask.cdap.data2.util.hbase.ConfigurationTable in project cdap by caskdata.

the class ConfigurationTableTest method testConfigurationSerialization.

@Test
public void testConfigurationSerialization() throws Exception {
    ConfigurationTable configTable = new ConfigurationTable(TEST_HBASE.getConfiguration());
    configTable.write(ConfigurationTable.Type.DEFAULT, cConf);
    String configTableQualifier = "configuration";
    TableId configTableId = tableUtil.createHTableId(NamespaceId.SYSTEM, configTableQualifier);
    String configTableName = tableUtil.buildHTableDescriptor(configTableId).build().getNameAsString();
    // the config table name minus the qualifier ('configuration'). Example: 'cdap.system.'
    String configTablePrefix = configTableName.substring(0, configTableName.length() - configTableQualifier.length());
    CConfiguration cConf2 = configTable.read(ConfigurationTable.Type.DEFAULT, configTablePrefix);
    assertNotNull(cConf2);
    for (Map.Entry<String, String> e : cConf) {
        assertEquals("Configuration value mismatch (cConf -> cConf2) for key: " + e.getKey(), e.getValue(), cConf2.get(e.getKey()));
    }
    for (Map.Entry<String, String> e : cConf2) {
        assertEquals("Configuration value mismatch (cConf2 -> cConf) for key: " + e.getKey(), e.getValue(), cConf.get(e.getKey()));
    }
}
Also used : TableId(co.cask.cdap.data2.util.TableId) CConfiguration(co.cask.cdap.common.conf.CConfiguration) Map(java.util.Map) Test(org.junit.Test)

Example 3 with ConfigurationTable

use of co.cask.cdap.data2.util.hbase.ConfigurationTable in project cdap by caskdata.

the class DefaultTransactionStateCache method setConf.

@Override
public void setConf(Configuration conf) {
    super.setConf(conf);
    this.configTable = new ConfigurationTable(conf);
}
Also used : ConfigurationTable(co.cask.cdap.data2.util.hbase.ConfigurationTable)

Example 4 with ConfigurationTable

use of co.cask.cdap.data2.util.hbase.ConfigurationTable in project cdap by caskdata.

the class HBasePayloadTableTestRun method setupBeforeClass.

@BeforeClass
public static void setupBeforeClass() throws Exception {
    hConf = HBASE_TEST_BASE.getConfiguration();
    hConf.set(HBaseTableUtil.CFG_HBASE_TABLE_COMPRESSION, HBaseTableUtil.CompressionType.NONE.name());
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    cConf.set(Constants.CFG_HDFS_NAMESPACE, cConf.get(Constants.CFG_LOCAL_DATA_DIR));
    cConf.set(Constants.CFG_HDFS_USER, System.getProperty("user.name"));
    tableUtil = new HBaseTableUtilFactory(cConf).get();
    ddlExecutor = new HBaseDDLExecutorFactory(cConf, hConf).get();
    ddlExecutor.createNamespaceIfNotExists(tableUtil.getHBaseNamespace(NamespaceId.SYSTEM));
    LocationFactory locationFactory = getInjector().getInstance(LocationFactory.class);
    tableFactory = new HBaseTableFactory(cConf, hConf, tableUtil, locationFactory);
    ConfigurationTable configTable = new ConfigurationTable(hConf);
    configTable.write(ConfigurationTable.Type.DEFAULT, cConf);
}
Also used : ConfigurationTable(co.cask.cdap.data2.util.hbase.ConfigurationTable) HBaseDDLExecutorFactory(co.cask.cdap.data2.util.hbase.HBaseDDLExecutorFactory) HBaseTableUtilFactory(co.cask.cdap.data2.util.hbase.HBaseTableUtilFactory) LocationFactory(org.apache.twill.filesystem.LocationFactory) BeforeClass(org.junit.BeforeClass)

Example 5 with ConfigurationTable

use of co.cask.cdap.data2.util.hbase.ConfigurationTable in project cdap by caskdata.

the class HBaseTableCoprocessorTestRun method setupBeforeClass.

@BeforeClass
public static void setupBeforeClass() throws Exception {
    hConf = HBASE_TEST_BASE.getConfiguration();
    hConf.set(HBaseTableUtil.CFG_HBASE_TABLE_COMPRESSION, HBaseTableUtil.CompressionType.NONE.name());
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    cConf.set(Constants.CFG_HDFS_NAMESPACE, cConf.get(Constants.CFG_LOCAL_DATA_DIR));
    cConf.set(Constants.CFG_HDFS_USER, System.getProperty("user.name"));
    // Reduce the metadata cache refresh frequency for unit tests
    cConf.set(Constants.MessagingSystem.COPROCESSOR_METADATA_CACHE_UPDATE_FREQUENCY_SECONDS, Integer.toString(METADATA_CACHE_EXPIRY));
    hBaseAdmin = HBASE_TEST_BASE.getHBaseAdmin();
    hBaseAdmin.getConfiguration().set(HBaseTableUtil.CFG_HBASE_TABLE_COMPRESSION, HBaseTableUtil.CompressionType.NONE.name());
    tableUtil = new HBaseTableUtilFactory(cConf).get();
    ddlExecutor = new HBaseDDLExecutorFactory(cConf, hConf).get();
    ddlExecutor.createNamespaceIfNotExists(tableUtil.getHBaseNamespace(NamespaceId.SYSTEM));
    LocationFactory locationFactory = getInjector().getInstance(LocationFactory.class);
    tableFactory = new HBaseTableFactory(cConf, hBaseAdmin.getConfiguration(), tableUtil, locationFactory);
    ConfigurationTable configTable = new ConfigurationTable(hConf);
    configTable.write(ConfigurationTable.Type.DEFAULT, cConf);
    // write an initial transaction snapshot
    TransactionSnapshot txSnapshot = TransactionSnapshot.copyFrom(System.currentTimeMillis(), V[6] - 1, V[7], invalidSet, // this will set visibility upper bound to V[6]
    Maps.newTreeMap(ImmutableSortedMap.of(V[6], new TransactionManager.InProgressTx(V[6] - 1, Long.MAX_VALUE, TransactionManager.InProgressType.SHORT))), new HashMap<Long, Set<ChangeId>>(), new TreeMap<Long, Set<ChangeId>>());
    HDFSTransactionStateStorage tmpStorage = new HDFSTransactionStateStorage(hConf, new SnapshotCodecProvider(hConf), new TxMetricsCollector());
    tmpStorage.startAndWait();
    tmpStorage.writeSnapshot(txSnapshot);
    tmpStorage.stopAndWait();
}
Also used : Set(java.util.Set) TxMetricsCollector(org.apache.tephra.metrics.TxMetricsCollector) SnapshotCodecProvider(org.apache.tephra.snapshot.SnapshotCodecProvider) LocationFactory(org.apache.twill.filesystem.LocationFactory) HDFSTransactionStateStorage(org.apache.tephra.persist.HDFSTransactionStateStorage) TransactionSnapshot(org.apache.tephra.persist.TransactionSnapshot) ConfigurationTable(co.cask.cdap.data2.util.hbase.ConfigurationTable) TransactionManager(org.apache.tephra.TransactionManager) HBaseDDLExecutorFactory(co.cask.cdap.data2.util.hbase.HBaseDDLExecutorFactory) HBaseTableUtilFactory(co.cask.cdap.data2.util.hbase.HBaseTableUtilFactory) BeforeClass(org.junit.BeforeClass)

Aggregations

ConfigurationTable (co.cask.cdap.data2.util.hbase.ConfigurationTable)5 HBaseDDLExecutorFactory (co.cask.cdap.data2.util.hbase.HBaseDDLExecutorFactory)4 BeforeClass (org.junit.BeforeClass)4 HBaseTableUtilFactory (co.cask.cdap.data2.util.hbase.HBaseTableUtilFactory)3 LocationFactory (org.apache.twill.filesystem.LocationFactory)3 CConfiguration (co.cask.cdap.common.conf.CConfiguration)1 ConfigModule (co.cask.cdap.common.guice.ConfigModule)1 DiscoveryRuntimeModule (co.cask.cdap.common.guice.DiscoveryRuntimeModule)1 LocationRuntimeModule (co.cask.cdap.common.guice.LocationRuntimeModule)1 NamespaceClientUnitTestModule (co.cask.cdap.common.guice.NamespaceClientUnitTestModule)1 ZKClientModule (co.cask.cdap.common.guice.ZKClientModule)1 DataFabricModules (co.cask.cdap.data.runtime.DataFabricModules)1 DataSetsModules (co.cask.cdap.data.runtime.DataSetsModules)1 SystemDatasetRuntimeModule (co.cask.cdap.data.runtime.SystemDatasetRuntimeModule)1 TransactionMetricsModule (co.cask.cdap.data.runtime.TransactionMetricsModule)1 QueueClientFactory (co.cask.cdap.data2.queue.QueueClientFactory)1 QueueAdmin (co.cask.cdap.data2.transaction.queue.QueueAdmin)1 TableId (co.cask.cdap.data2.util.TableId)1 HBaseTableUtil (co.cask.cdap.data2.util.hbase.HBaseTableUtil)1 NoOpNotificationFeedManager (co.cask.cdap.notifications.feeds.service.NoOpNotificationFeedManager)1