Search in sources :

Example 1 with DatasetDefinitionRegistryFactory

use of io.cdap.cdap.data2.dataset2.DatasetDefinitionRegistryFactory in project cdap by caskdata.

the class AbstractDatasetFrameworkTest method setup.

@BeforeClass
public static void setup() throws Exception {
    cConf = CConfiguration.create();
    File dataDir = new File(TMP_FOLDER.newFolder(), "data");
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, dataDir.getAbsolutePath());
    final Injector injector = Guice.createInjector(new ConfigModule(cConf), new NonCustomLocationUnitTestModule(), new TransactionInMemoryModule(), new NamespaceAdminTestModule(), new AuditTestModule(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(OwnerStore.class).to(InMemoryOwnerStore.class).in(Scopes.SINGLETON);
            bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
        }
    });
    locationFactory = injector.getInstance(LocationFactory.class);
    namespacePathLocator = injector.getInstance(NamespacePathLocator.class);
    txExecutorFactory = injector.getInstance(TransactionExecutorFactory.class);
    registryFactory = new DatasetDefinitionRegistryFactory() {

        @Override
        public DatasetDefinitionRegistry create() {
            DefaultDatasetDefinitionRegistry registry = new DefaultDatasetDefinitionRegistry();
            injector.injectMembers(registry);
            return registry;
        }
    };
    namespaceAdmin = injector.getInstance(NamespaceAdmin.class);
    namespaceQueryAdmin = injector.getInstance(NamespaceQueryAdmin.class);
    ownerAdmin = injector.getInstance(OwnerAdmin.class);
    inMemoryAuditPublisher = injector.getInstance(InMemoryAuditPublisher.class);
}
Also used : TransactionInMemoryModule(org.apache.tephra.runtime.TransactionInMemoryModule) NamespaceAdminTestModule(io.cdap.cdap.common.guice.NamespaceAdminTestModule) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) DefaultOwnerAdmin(io.cdap.cdap.security.impersonation.DefaultOwnerAdmin) OwnerAdmin(io.cdap.cdap.security.impersonation.OwnerAdmin) NamespaceAdmin(io.cdap.cdap.common.namespace.NamespaceAdmin) NamespacePathLocator(io.cdap.cdap.common.namespace.NamespacePathLocator) DatasetDefinitionRegistry(io.cdap.cdap.api.dataset.module.DatasetDefinitionRegistry) NonCustomLocationUnitTestModule(io.cdap.cdap.common.guice.NonCustomLocationUnitTestModule) DefaultOwnerAdmin(io.cdap.cdap.security.impersonation.DefaultOwnerAdmin) OwnerStore(io.cdap.cdap.security.impersonation.OwnerStore) InMemoryOwnerStore(io.cdap.cdap.security.impersonation.InMemoryOwnerStore) AbstractModule(com.google.inject.AbstractModule) LocationFactory(org.apache.twill.filesystem.LocationFactory) TransactionExecutorFactory(org.apache.tephra.TransactionExecutorFactory) InMemoryAuditPublisher(io.cdap.cdap.data2.audit.InMemoryAuditPublisher) Injector(com.google.inject.Injector) NamespaceQueryAdmin(io.cdap.cdap.common.namespace.NamespaceQueryAdmin) AuditTestModule(io.cdap.cdap.data2.audit.AuditTestModule) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 2 with DatasetDefinitionRegistryFactory

use of io.cdap.cdap.data2.dataset2.DatasetDefinitionRegistryFactory in project cdap by caskdata.

the class DataMigration method createRegisteredDatasetFramework.

/**
   * Sets up a {@link DatasetFramework} instance for standalone usage.  NOTE: should NOT be used by applications!!!
   */
public static DatasetFramework createRegisteredDatasetFramework(Injector injector) throws DatasetManagementException, IOException {
    DatasetDefinitionRegistryFactory registryFactory = injector.getInstance(DatasetDefinitionRegistryFactory.class);
    DatasetFramework datasetFramework = new InMemoryDatasetFramework(registryFactory);
    // TODO: this doesn't sound right. find out why its needed.
    datasetFramework.addModule(NamespaceId.SYSTEM.datasetModule("table"), new HBaseTableModule());
    datasetFramework.addModule(NamespaceId.SYSTEM.datasetModule("metricsTable"), new HBaseMetricsTableModule());
    datasetFramework.addModule(NamespaceId.SYSTEM.datasetModule("core"), new CoreDatasetsModule());
    datasetFramework.addModule(NamespaceId.SYSTEM.datasetModule("fileSet"), new FileSetModule());
    return datasetFramework;
}
Also used : DatasetFramework(co.cask.cdap.data2.dataset2.DatasetFramework) InMemoryDatasetFramework(co.cask.cdap.data2.dataset2.InMemoryDatasetFramework) DatasetDefinitionRegistryFactory(co.cask.cdap.data2.dataset2.DatasetDefinitionRegistryFactory) CoreDatasetsModule(co.cask.cdap.data2.dataset2.lib.table.CoreDatasetsModule) HBaseMetricsTableModule(co.cask.cdap.data2.dataset2.module.lib.hbase.HBaseMetricsTableModule) HBaseTableModule(co.cask.cdap.data2.dataset2.module.lib.hbase.HBaseTableModule) FileSetModule(co.cask.cdap.data2.dataset2.lib.file.FileSetModule) InMemoryDatasetFramework(co.cask.cdap.data2.dataset2.InMemoryDatasetFramework)

Aggregations

DatasetDefinitionRegistryFactory (co.cask.cdap.data2.dataset2.DatasetDefinitionRegistryFactory)1 DatasetFramework (co.cask.cdap.data2.dataset2.DatasetFramework)1 InMemoryDatasetFramework (co.cask.cdap.data2.dataset2.InMemoryDatasetFramework)1 FileSetModule (co.cask.cdap.data2.dataset2.lib.file.FileSetModule)1 CoreDatasetsModule (co.cask.cdap.data2.dataset2.lib.table.CoreDatasetsModule)1 HBaseMetricsTableModule (co.cask.cdap.data2.dataset2.module.lib.hbase.HBaseMetricsTableModule)1 HBaseTableModule (co.cask.cdap.data2.dataset2.module.lib.hbase.HBaseTableModule)1 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 DatasetDefinitionRegistry (io.cdap.cdap.api.dataset.module.DatasetDefinitionRegistry)1 ConfigModule (io.cdap.cdap.common.guice.ConfigModule)1 NamespaceAdminTestModule (io.cdap.cdap.common.guice.NamespaceAdminTestModule)1 NonCustomLocationUnitTestModule (io.cdap.cdap.common.guice.NonCustomLocationUnitTestModule)1 NamespaceAdmin (io.cdap.cdap.common.namespace.NamespaceAdmin)1 NamespacePathLocator (io.cdap.cdap.common.namespace.NamespacePathLocator)1 NamespaceQueryAdmin (io.cdap.cdap.common.namespace.NamespaceQueryAdmin)1 AuditTestModule (io.cdap.cdap.data2.audit.AuditTestModule)1 InMemoryAuditPublisher (io.cdap.cdap.data2.audit.InMemoryAuditPublisher)1 DefaultOwnerAdmin (io.cdap.cdap.security.impersonation.DefaultOwnerAdmin)1 InMemoryOwnerStore (io.cdap.cdap.security.impersonation.InMemoryOwnerStore)1