Search in sources :

Example 1 with TransactionManager

use of org.apache.tephra.TransactionManager in project phoenix by apache.

the class BaseTest method setupTxManager.

protected static void setupTxManager() throws SQLException, IOException {
    ConnectionInfo connInfo = ConnectionInfo.create(getUrl());
    zkClient = ZKClientServices.delegate(ZKClients.reWatchOnExpire(ZKClients.retryOnFailure(ZKClientService.Builder.of(connInfo.getZookeeperConnectionString()).setSessionTimeout(config.getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT)).build(), RetryStrategies.exponentialDelay(500, 2000, TimeUnit.MILLISECONDS))));
    zkClient.startAndWait();
    DiscoveryService discovery = new ZKDiscoveryService(zkClient);
    txManager = new TransactionManager(config, new HDFSTransactionStateStorage(config, new SnapshotCodecProvider(config), new TxMetricsCollector()), new TxMetricsCollector());
    txService = new TransactionService(config, zkClient, discovery, Providers.of(txManager));
    txService.startAndWait();
}
Also used : ZKDiscoveryService(org.apache.twill.discovery.ZKDiscoveryService) HDFSTransactionStateStorage(org.apache.tephra.persist.HDFSTransactionStateStorage) TransactionService(org.apache.tephra.distributed.TransactionService) TransactionManager(org.apache.tephra.TransactionManager) TxMetricsCollector(org.apache.tephra.metrics.TxMetricsCollector) ConnectionInfo(org.apache.phoenix.jdbc.PhoenixEmbeddedDriver.ConnectionInfo) DiscoveryService(org.apache.twill.discovery.DiscoveryService) ZKDiscoveryService(org.apache.twill.discovery.ZKDiscoveryService) SnapshotCodecProvider(org.apache.tephra.snapshot.SnapshotCodecProvider)

Example 2 with TransactionManager

use of org.apache.tephra.TransactionManager in project cdap by caskdata.

the class HBaseQueueTest method takeTxSnapshot.

/**
 * Asks the tx manager to take a snapshot.
 */
private void takeTxSnapshot() throws Exception {
    TransactionManager transactionManager = getTransactionManager();
    Method doSnapshot = transactionManager.getClass().getDeclaredMethod("doSnapshot", boolean.class);
    doSnapshot.setAccessible(true);
    doSnapshot.invoke(transactionManager, false);
    LOG.info("Read pointer: {}", transactionManager.getCurrentState().getReadPointer());
    LOG.info("Snapshot read pointer: {}", transactionManager.getSnapshot().getReadPointer());
}
Also used : TransactionManager(org.apache.tephra.TransactionManager) Method(java.lang.reflect.Method)

Example 3 with TransactionManager

use of org.apache.tephra.TransactionManager in project cdap by caskdata.

the class InMemoryQueueTest method init.

@BeforeClass
public static void init() throws Exception {
    injector = Guice.createInjector(new ConfigModule(), new NonCustomLocationUnitTestModule().getModule(), new DiscoveryRuntimeModule().getInMemoryModules(), new SystemDatasetRuntimeModule().getInMemoryModules(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), new DataSetsModules().getInMemoryModules(), new DataFabricModules().getInMemoryModules(), new TransactionMetricsModule(), new ExploreClientModule(), new ViewAdminModules().getInMemoryModules(), Modules.override(new StreamAdminModules().getInMemoryModules()).with(new AbstractModule() {

        @Override
        protected void configure() {
            // The tests are actually testing stream on queue implementation, hence bind it to the queue implementation
            bind(StreamAdmin.class).to(InMemoryStreamAdmin.class);
            bind(StreamAdmin.class).annotatedWith(Names.named(StreamAdminModules.NOAUTH_STREAM_ADMIN)).to(InMemoryStreamAdmin.class);
            bind(StreamMetaStore.class).to(InMemoryStreamMetaStore.class);
        }
    }));
    // transaction manager is a "service" and must be started
    transactionManager = injector.getInstance(TransactionManager.class);
    transactionManager.startAndWait();
    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) AuthenticationContextModules(co.cask.cdap.security.auth.context.AuthenticationContextModules) DataSetsModules(co.cask.cdap.data.runtime.DataSetsModules) NonCustomLocationUnitTestModule(co.cask.cdap.common.guice.NonCustomLocationUnitTestModule) AuthorizationTestModule(co.cask.cdap.security.authorization.AuthorizationTestModule) TransactionMetricsModule(co.cask.cdap.data.runtime.TransactionMetricsModule) ViewAdminModules(co.cask.cdap.data.view.ViewAdminModules) AbstractModule(com.google.inject.AbstractModule) TransactionExecutorFactory(org.apache.tephra.TransactionExecutorFactory) StreamAdminModules(co.cask.cdap.data.stream.StreamAdminModules) TransactionSystemClient(org.apache.tephra.TransactionSystemClient) QueueAdmin(co.cask.cdap.data2.transaction.queue.QueueAdmin) StreamAdmin(co.cask.cdap.data2.transaction.stream.StreamAdmin) InMemoryStreamMetaStore(co.cask.cdap.data.stream.service.InMemoryStreamMetaStore) ExploreClientModule(co.cask.cdap.explore.guice.ExploreClientModule) TransactionManager(org.apache.tephra.TransactionManager) QueueClientFactory(co.cask.cdap.data2.queue.QueueClientFactory) SystemDatasetRuntimeModule(co.cask.cdap.data.runtime.SystemDatasetRuntimeModule) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) DataFabricModules(co.cask.cdap.data.runtime.DataFabricModules) AuthorizationEnforcementModule(co.cask.cdap.security.authorization.AuthorizationEnforcementModule) BeforeClass(org.junit.BeforeClass)

Example 4 with TransactionManager

use of org.apache.tephra.TransactionManager in project cdap by caskdata.

the class LevelDBQueueTest method init.

@BeforeClass
public static void init() throws Exception {
    CConfiguration conf = CConfiguration.create();
    conf.set(Constants.CFG_LOCAL_DATA_DIR, tmpFolder.newFolder().getAbsolutePath());
    conf.set(Constants.Dataset.TABLE_PREFIX, "test");
    Injector injector = Guice.createInjector(new ConfigModule(conf), new NonCustomLocationUnitTestModule().getModule(), new DiscoveryRuntimeModule().getStandaloneModules(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getMasterModule(), new DataSetsModules().getStandaloneModules(), new DataFabricLevelDBModule(), new TransactionMetricsModule());
    // transaction manager is a "service" and must be started
    transactionManager = injector.getInstance(TransactionManager.class);
    transactionManager.startAndWait();
    txSystemClient = injector.getInstance(TransactionSystemClient.class);
    queueClientFactory = injector.getInstance(QueueClientFactory.class);
    queueAdmin = injector.getInstance(QueueAdmin.class);
    executorFactory = injector.getInstance(TransactionExecutorFactory.class);
    LevelDBTableService.getInstance().clearTables();
}
Also used : ConfigModule(co.cask.cdap.common.guice.ConfigModule) AuthenticationContextModules(co.cask.cdap.security.auth.context.AuthenticationContextModules) DataSetsModules(co.cask.cdap.data.runtime.DataSetsModules) NonCustomLocationUnitTestModule(co.cask.cdap.common.guice.NonCustomLocationUnitTestModule) CConfiguration(co.cask.cdap.common.conf.CConfiguration) AuthorizationTestModule(co.cask.cdap.security.authorization.AuthorizationTestModule) DataFabricLevelDBModule(co.cask.cdap.data.runtime.DataFabricLevelDBModule) TransactionMetricsModule(co.cask.cdap.data.runtime.TransactionMetricsModule) TransactionExecutorFactory(org.apache.tephra.TransactionExecutorFactory) TransactionSystemClient(org.apache.tephra.TransactionSystemClient) QueueAdmin(co.cask.cdap.data2.transaction.queue.QueueAdmin) Injector(com.google.inject.Injector) TransactionManager(org.apache.tephra.TransactionManager) QueueClientFactory(co.cask.cdap.data2.queue.QueueClientFactory) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) AuthorizationEnforcementModule(co.cask.cdap.security.authorization.AuthorizationEnforcementModule) BeforeClass(org.junit.BeforeClass)

Example 5 with TransactionManager

use of org.apache.tephra.TransactionManager in project cdap by caskdata.

the class TableTest method before.

@Before
public void before() {
    Configuration txConf = HBaseConfiguration.create();
    TransactionManager txManager = new TransactionManager(txConf);
    txManager.startAndWait();
    txClient = new InMemoryTxSystemClient(txManager);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) TransactionManager(org.apache.tephra.TransactionManager) InMemoryTxSystemClient(org.apache.tephra.inmemory.InMemoryTxSystemClient) Before(org.junit.Before)

Aggregations

TransactionManager (org.apache.tephra.TransactionManager)26 Configuration (org.apache.hadoop.conf.Configuration)15 Injector (com.google.inject.Injector)14 ConfigModule (co.cask.cdap.common.guice.ConfigModule)13 BeforeClass (org.junit.BeforeClass)13 AbstractModule (com.google.inject.AbstractModule)12 CConfiguration (co.cask.cdap.common.conf.CConfiguration)11 AuthorizationEnforcementModule (co.cask.cdap.security.authorization.AuthorizationEnforcementModule)11 AuthorizationTestModule (co.cask.cdap.security.authorization.AuthorizationTestModule)11 DiscoveryRuntimeModule (co.cask.cdap.common.guice.DiscoveryRuntimeModule)10 AuthenticationContextModules (co.cask.cdap.security.auth.context.AuthenticationContextModules)10 DataSetsModules (co.cask.cdap.data.runtime.DataSetsModules)9 DatasetService (co.cask.cdap.data2.datafabric.dataset.service.DatasetService)9 NamespaceClientRuntimeModule (co.cask.cdap.common.namespace.guice.NamespaceClientRuntimeModule)8 InMemoryTxSystemClient (org.apache.tephra.inmemory.InMemoryTxSystemClient)8 NonCustomLocationUnitTestModule (co.cask.cdap.common.guice.NonCustomLocationUnitTestModule)7 DataFabricModules (co.cask.cdap.data.runtime.DataFabricModules)6 ExploreClientModule (co.cask.cdap.explore.guice.ExploreClientModule)6 LocationRuntimeModule (co.cask.cdap.common.guice.LocationRuntimeModule)5 DataSetServiceModules (co.cask.cdap.data.runtime.DataSetServiceModules)5