Search in sources :

Example 26 with DatasetFramework

use of co.cask.cdap.data2.dataset2.DatasetFramework in project cdap by caskdata.

the class DatasetBasedStreamSizeScheduleStoreTest method set.

@BeforeClass
public static void set() throws Exception {
    Injector injector = AppFabricTestHelper.getInjector();
    scheduleStore = injector.getInstance(DatasetBasedStreamSizeScheduleStore.class);
    txExecutorFactory = injector.getInstance(TransactionExecutorFactory.class);
    datasetFramework = injector.getInstance(DatasetFramework.class);
    // this effectively waits for the relevant services to start up
    final SchedulerService schedulerService = injector.getInstance(SchedulerService.class);
    Tasks.waitFor(true, new Callable<Boolean>() {

        @Override
        public Boolean call() throws Exception {
            return schedulerService.isRunning();
        }
    }, 10, TimeUnit.SECONDS);
}
Also used : DatasetFramework(co.cask.cdap.data2.dataset2.DatasetFramework) SchedulerService(co.cask.cdap.internal.app.runtime.schedule.SchedulerService) Injector(com.google.inject.Injector) TransactionExecutorFactory(co.cask.cdap.data2.transaction.TransactionExecutorFactory) BeforeClass(org.junit.BeforeClass)

Example 27 with DatasetFramework

use of co.cask.cdap.data2.dataset2.DatasetFramework in project cdap by caskdata.

the class AppMetadataStoreTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    Injector injector = AppFabricTestHelper.getInjector();
    AppFabricTestHelper.ensureNamespaceExists(NamespaceId.DEFAULT);
    datasetFramework = injector.getInstance(DatasetFramework.class);
    txExecutorFactory = injector.getInstance(TransactionExecutorFactory.class);
    cConf = injector.getInstance(CConfiguration.class);
}
Also used : DatasetFramework(co.cask.cdap.data2.dataset2.DatasetFramework) Injector(com.google.inject.Injector) CConfiguration(co.cask.cdap.common.conf.CConfiguration) TransactionExecutorFactory(co.cask.cdap.data2.transaction.TransactionExecutorFactory) BeforeClass(org.junit.BeforeClass)

Example 28 with DatasetFramework

use of co.cask.cdap.data2.dataset2.DatasetFramework in project cdap by caskdata.

the class BaseHiveExploreServiceTest method initialize.

protected static void initialize(CConfiguration cConf, TemporaryFolder tmpFolder, boolean useStandalone, boolean enableAuthorization) throws Exception {
    if (!runBefore) {
        return;
    }
    Configuration hConf = new Configuration();
    if (enableAuthorization) {
        LocationFactory locationFactory = new LocalLocationFactory(tmpFolder.newFolder());
        Location authExtensionJar = AppJarHelper.createDeploymentJar(locationFactory, InMemoryAuthorizer.class);
        cConf.setBoolean(Constants.Security.ENABLED, true);
        cConf.setBoolean(Constants.Security.Authorization.ENABLED, true);
        cConf.set(Constants.Security.Authorization.EXTENSION_JAR_PATH, authExtensionJar.toURI().getPath());
        cConf.setBoolean(Constants.Security.KERBEROS_ENABLED, false);
        cConf.setInt(Constants.Security.Authorization.CACHE_MAX_ENTRIES, 0);
    }
    List<Module> modules = useStandalone ? createStandaloneModules(cConf, hConf, tmpFolder) : createInMemoryModules(cConf, hConf, tmpFolder);
    injector = Guice.createInjector(modules);
    if (enableAuthorization) {
        injector.getInstance(AuthorizationBootstrapper.class).run();
    }
    transactionManager = injector.getInstance(TransactionManager.class);
    transactionManager.startAndWait();
    transactionSystemClient = injector.getInstance(TransactionSystemClient.class);
    dsOpService = injector.getInstance(DatasetOpExecutor.class);
    dsOpService.startAndWait();
    datasetService = injector.getInstance(DatasetService.class);
    datasetService.startAndWait();
    exploreExecutorService = injector.getInstance(ExploreExecutorService.class);
    exploreExecutorService.startAndWait();
    datasetFramework = injector.getInstance(DatasetFramework.class);
    exploreClient = injector.getInstance(DiscoveryExploreClient.class);
    exploreService = injector.getInstance(ExploreService.class);
    exploreClient.ping();
    notificationService = injector.getInstance(NotificationService.class);
    notificationService.startAndWait();
    streamService = injector.getInstance(StreamService.class);
    streamService.startAndWait();
    streamHttpService = injector.getInstance(StreamHttpService.class);
    streamHttpService.startAndWait();
    exploreTableManager = injector.getInstance(ExploreTableManager.class);
    streamAdmin = injector.getInstance(StreamAdmin.class);
    streamMetaStore = injector.getInstance(StreamMetaStore.class);
    namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
    namespacedLocationFactory = injector.getInstance(NamespacedLocationFactory.class);
    // create namespaces
    // This happens when you create a namespace via REST APIs. However, since we do not start AppFabricServer in
    // Explore tests, simulating that scenario by explicitly calling DatasetFramework APIs.
    createNamespace(NamespaceId.DEFAULT);
    createNamespace(NAMESPACE_ID);
    createNamespace(OTHER_NAMESPACE_ID);
}
Also used : StreamService(co.cask.cdap.data.stream.service.StreamService) CConfiguration(co.cask.cdap.common.conf.CConfiguration) Configuration(org.apache.hadoop.conf.Configuration) NamespaceAdmin(co.cask.cdap.common.namespace.NamespaceAdmin) DatasetService(co.cask.cdap.data2.datafabric.dataset.service.DatasetService) NotificationService(co.cask.cdap.notifications.service.NotificationService) DatasetOpExecutor(co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutor) StreamHttpService(co.cask.cdap.data.stream.service.StreamHttpService) NamespacedLocationFactory(co.cask.cdap.common.namespace.NamespacedLocationFactory) NamespacedLocationFactory(co.cask.cdap.common.namespace.NamespacedLocationFactory) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) LocationFactory(org.apache.twill.filesystem.LocationFactory) DatasetFramework(co.cask.cdap.data2.dataset2.DatasetFramework) TransactionSystemClient(org.apache.tephra.TransactionSystemClient) DiscoveryExploreClient(co.cask.cdap.explore.client.DiscoveryExploreClient) StreamAdmin(co.cask.cdap.data2.transaction.stream.StreamAdmin) AuthorizationBootstrapper(co.cask.cdap.security.authorization.AuthorizationBootstrapper) TransactionManager(org.apache.tephra.TransactionManager) ExploreExecutorService(co.cask.cdap.explore.executor.ExploreExecutorService) StreamMetaStore(co.cask.cdap.data.stream.service.StreamMetaStore) AuthorizationEnforcementModule(co.cask.cdap.security.authorization.AuthorizationEnforcementModule) NonCustomLocationUnitTestModule(co.cask.cdap.common.guice.NonCustomLocationUnitTestModule) ExploreRuntimeModule(co.cask.cdap.explore.guice.ExploreRuntimeModule) ExploreClientModule(co.cask.cdap.explore.guice.ExploreClientModule) MetricsClientRuntimeModule(co.cask.cdap.metrics.guice.MetricsClientRuntimeModule) NamespaceClientRuntimeModule(co.cask.cdap.common.namespace.guice.NamespaceClientRuntimeModule) ConfigModule(co.cask.cdap.common.guice.ConfigModule) AbstractModule(com.google.inject.AbstractModule) Module(com.google.inject.Module) NotificationServiceRuntimeModule(co.cask.cdap.notifications.guice.NotificationServiceRuntimeModule) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) NamespaceClientUnitTestModule(co.cask.cdap.common.guice.NamespaceClientUnitTestModule) StreamServiceRuntimeModule(co.cask.cdap.data.stream.service.StreamServiceRuntimeModule) AuthorizationTestModule(co.cask.cdap.security.authorization.AuthorizationTestModule) IOModule(co.cask.cdap.common.guice.IOModule) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) Location(org.apache.twill.filesystem.Location)

Example 29 with DatasetFramework

use of co.cask.cdap.data2.dataset2.DatasetFramework in project cdap by caskdata.

the class ExploreDisabledTest method start.

@BeforeClass
public static void start() throws Exception {
    Injector injector = Guice.createInjector(createInMemoryModules(CConfiguration.create(), new Configuration()));
    transactionManager = injector.getInstance(TransactionManager.class);
    transactionManager.startAndWait();
    dsOpExecutor = injector.getInstance(DatasetOpExecutor.class);
    dsOpExecutor.startAndWait();
    datasetService = injector.getInstance(DatasetService.class);
    datasetService.startAndWait();
    exploreClient = injector.getInstance(DiscoveryExploreClient.class);
    try {
        exploreClient.ping();
        Assert.fail("Expected not to be able to ping explore client.");
    } catch (ServiceUnavailableException e) {
    // expected
    }
    datasetFramework = injector.getInstance(DatasetFramework.class);
    namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
    NamespacedLocationFactory namespacedLocationFactory = injector.getInstance(NamespacedLocationFactory.class);
    NamespaceMeta namespaceMeta = new NamespaceMeta.Builder().setName(namespaceId).build();
    namespaceAdmin.create(namespaceMeta);
    // This happens when you create a namespace via REST APIs. However, since we do not start AppFabricServer in
    // Explore tests, simulating that scenario by explicitly calling DatasetFramework APIs.
    namespacedLocationFactory.get(namespaceId).mkdirs();
    exploreClient.addNamespace(namespaceMeta);
}
Also used : DatasetFramework(co.cask.cdap.data2.dataset2.DatasetFramework) DiscoveryExploreClient(co.cask.cdap.explore.client.DiscoveryExploreClient) CConfiguration(co.cask.cdap.common.conf.CConfiguration) Configuration(org.apache.hadoop.conf.Configuration) Injector(com.google.inject.Injector) TransactionManager(org.apache.tephra.TransactionManager) NamespaceMeta(co.cask.cdap.proto.NamespaceMeta) NamespaceAdmin(co.cask.cdap.common.namespace.NamespaceAdmin) DatasetService(co.cask.cdap.data2.datafabric.dataset.service.DatasetService) DatasetOpExecutor(co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutor) ServiceUnavailableException(co.cask.cdap.common.ServiceUnavailableException) NamespacedLocationFactory(co.cask.cdap.common.namespace.NamespacedLocationFactory) BeforeClass(org.junit.BeforeClass)

Example 30 with DatasetFramework

use of co.cask.cdap.data2.dataset2.DatasetFramework in project cdap by caskdata.

the class UpgradeTool method createInjector.

@VisibleForTesting
Injector createInjector() throws Exception {
    return Guice.createInjector(new ConfigModule(cConf, hConf), new LocationRuntimeModule().getDistributedModules(), new ZKClientModule(), new DiscoveryRuntimeModule().getDistributedModules(), new MessagingClientModule(), Modules.override(new DataSetsModules().getDistributedModules()).with(new AbstractModule() {

        @Override
        protected void configure() {
            bind(DatasetFramework.class).to(InMemoryDatasetFramework.class).in(Scopes.SINGLETON);
            // the DataSetsModules().getDistributedModules() binds to RemoteDatasetFramework so override that to
            // the same InMemoryDatasetFramework
            bind(DatasetFramework.class).annotatedWith(Names.named(DataSetsModules.BASE_DATASET_FRAMEWORK)).to(DatasetFramework.class);
            install(new FactoryModuleBuilder().implement(DatasetDefinitionRegistry.class, DefaultDatasetDefinitionRegistry.class).build(DatasetDefinitionRegistryFactory.class));
            // CDAP-5954 Upgrade tool does not need to record lineage and metadata changes for now.
            bind(LineageWriter.class).to(NoOpLineageWriter.class);
        }
    }), new ViewAdminModules().getDistributedModules(), new StreamAdminModules().getDistributedModules(), new NotificationFeedClientModule(), new TwillModule(), new ExploreClientModule(), new ProgramRunnerRuntimeModule().getDistributedModules(), new ServiceStoreModules().getDistributedModules(), new SystemDatasetRuntimeModule().getDistributedModules(), // don't need real notifications for upgrade, so use the in-memory implementations
    new NotificationServiceRuntimeModule().getInMemoryModules(), new KafkaClientModule(), new NamespaceStoreModule().getDistributedModules(), new AuthenticationContextModules().getMasterModule(), new AuthorizationModule(), new AuthorizationEnforcementModule().getMasterModule(), new SecureStoreModules().getDistributedModules(), new DataFabricModules(UpgradeTool.class.getName()).getDistributedModules(), new AppFabricServiceRuntimeModule().getDistributedModules(), new AbstractModule() {

        @Override
        protected void configure() {
            // the DataFabricDistributedModule needs MetricsCollectionService binding and since Upgrade tool does not do
            // anything with Metrics we just bind it to NoOpMetricsCollectionService
            bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class).in(Scopes.SINGLETON);
            bind(MetricDatasetFactory.class).to(DefaultMetricDatasetFactory.class).in(Scopes.SINGLETON);
            bind(MetricStore.class).to(DefaultMetricStore.class);
        }

        @Provides
        @Singleton
        @Named("datasetInstanceManager")
        @SuppressWarnings("unused")
        public DatasetInstanceManager getDatasetInstanceManager(TransactionSystemClientService txClient, TransactionExecutorFactory txExecutorFactory, @Named("datasetMDS") DatasetFramework framework) {
            return new DatasetInstanceManager(txClient, txExecutorFactory, framework);
        }

        // This is needed because the LocalApplicationManager
        // expects a dsframework injection named datasetMDS
        @Provides
        @Singleton
        @Named("datasetMDS")
        @SuppressWarnings("unused")
        public DatasetFramework getInDsFramework(DatasetFramework dsFramework) {
            return dsFramework;
        }
    });
}
Also used : MessagingClientModule(co.cask.cdap.messaging.guice.MessagingClientModule) ConfigModule(co.cask.cdap.common.guice.ConfigModule) FactoryModuleBuilder(com.google.inject.assistedinject.FactoryModuleBuilder) NamespaceStoreModule(co.cask.cdap.store.guice.NamespaceStoreModule) NotificationServiceRuntimeModule(co.cask.cdap.notifications.guice.NotificationServiceRuntimeModule) ViewAdminModules(co.cask.cdap.data.view.ViewAdminModules) TransactionExecutorFactory(co.cask.cdap.data2.transaction.TransactionExecutorFactory) MetricDatasetFactory(co.cask.cdap.metrics.store.MetricDatasetFactory) DefaultMetricDatasetFactory(co.cask.cdap.metrics.store.DefaultMetricDatasetFactory) DatasetFramework(co.cask.cdap.data2.dataset2.DatasetFramework) InMemoryDatasetFramework(co.cask.cdap.data2.dataset2.InMemoryDatasetFramework) ZKClientModule(co.cask.cdap.common.guice.ZKClientModule) DatasetDefinitionRegistryFactory(co.cask.cdap.data2.dataset2.DatasetDefinitionRegistryFactory) KafkaClientModule(co.cask.cdap.common.guice.KafkaClientModule) TransactionSystemClientService(co.cask.cdap.data2.transaction.TransactionSystemClientService) SystemDatasetRuntimeModule(co.cask.cdap.data.runtime.SystemDatasetRuntimeModule) DiscoveryRuntimeModule(co.cask.cdap.common.guice.DiscoveryRuntimeModule) AuthorizationModule(co.cask.cdap.app.guice.AuthorizationModule) InMemoryDatasetFramework(co.cask.cdap.data2.dataset2.InMemoryDatasetFramework) Named(com.google.inject.name.Named) TwillModule(co.cask.cdap.app.guice.TwillModule) DatasetInstanceManager(co.cask.cdap.data2.datafabric.dataset.instance.DatasetInstanceManager) MetricsCollectionService(co.cask.cdap.api.metrics.MetricsCollectionService) NoOpMetricsCollectionService(co.cask.cdap.common.metrics.NoOpMetricsCollectionService) AuthenticationContextModules(co.cask.cdap.security.auth.context.AuthenticationContextModules) DataSetsModules(co.cask.cdap.data.runtime.DataSetsModules) SecureStoreModules(co.cask.cdap.security.guice.SecureStoreModules) LocationRuntimeModule(co.cask.cdap.common.guice.LocationRuntimeModule) DefaultMetricStore(co.cask.cdap.metrics.store.DefaultMetricStore) Provides(com.google.inject.Provides) AbstractModule(com.google.inject.AbstractModule) StreamAdminModules(co.cask.cdap.data.stream.StreamAdminModules) ProgramRunnerRuntimeModule(co.cask.cdap.app.guice.ProgramRunnerRuntimeModule) LineageWriter(co.cask.cdap.data2.metadata.writer.LineageWriter) NoOpLineageWriter(co.cask.cdap.data2.metadata.writer.NoOpLineageWriter) ExploreClientModule(co.cask.cdap.explore.guice.ExploreClientModule) Singleton(com.google.inject.Singleton) NotificationFeedClientModule(co.cask.cdap.notifications.feeds.client.NotificationFeedClientModule) DataFabricModules(co.cask.cdap.data.runtime.DataFabricModules) ServiceStoreModules(co.cask.cdap.app.guice.ServiceStoreModules) AuthorizationEnforcementModule(co.cask.cdap.security.authorization.AuthorizationEnforcementModule) AppFabricServiceRuntimeModule(co.cask.cdap.app.guice.AppFabricServiceRuntimeModule) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

DatasetFramework (co.cask.cdap.data2.dataset2.DatasetFramework)26 Test (org.junit.Test)21 TransactionSystemClient (org.apache.tephra.TransactionSystemClient)11 CConfiguration (co.cask.cdap.common.conf.CConfiguration)10 Location (org.apache.twill.filesystem.Location)9 SystemDatasetInstantiator (co.cask.cdap.data.dataset.SystemDatasetInstantiator)8 LineageWriterDatasetFramework (co.cask.cdap.data2.metadata.writer.LineageWriterDatasetFramework)8 DatasetManagementException (co.cask.cdap.api.dataset.DatasetManagementException)7 IOException (java.io.IOException)7 LocationFactory (org.apache.twill.filesystem.LocationFactory)6 Transactional (co.cask.cdap.api.Transactional)5 DatasetManager (co.cask.cdap.api.dataset.DatasetManager)5 DefaultDatasetManager (co.cask.cdap.data2.datafabric.dataset.DefaultDatasetManager)5 MultiThreadDatasetCache (co.cask.cdap.data2.dataset2.MultiThreadDatasetCache)5 CoreDatasetsModule (co.cask.cdap.data2.dataset2.lib.table.CoreDatasetsModule)5 LogPathIdentifier (co.cask.cdap.logging.appender.system.LogPathIdentifier)5 FileMetaDataWriter (co.cask.cdap.logging.meta.FileMetaDataWriter)5 Injector (com.google.inject.Injector)5 Table (co.cask.cdap.api.dataset.table.Table)4 MetricsCollectionService (co.cask.cdap.api.metrics.MetricsCollectionService)4