Search in sources :

Example 1 with DatasetModule

use of co.cask.cdap.api.dataset.module.DatasetModule in project cdap by caskdata.

the class DatasetTypeService method deployExtensionModules.

private void deployExtensionModules() {
    // adding any defined extension modules to be available in dataset manager service
    for (Map.Entry<String, DatasetModule> module : extensionModules.entrySet()) {
        try {
            // NOTE: we assume extension modules are always in classpath, hence passing null for jar location
            // NOTE: we add extension modules in the system namespace
            DatasetModuleId theModule = NamespaceId.SYSTEM.datasetModule(module.getKey());
            typeManager.addModule(theModule, module.getValue().getClass().getName(), null, false);
            grantAllPrivilegesOnModule(theModule, authenticationContext.getPrincipal());
        } catch (DatasetModuleConflictException e) {
            // perfectly fine: we need to add the modules only the very first time service is started
            LOG.debug("Not adding {} extension module: it already exists", module.getKey());
        } catch (Throwable th) {
            LOG.error("Failed to add {} extension module. Aborting.", module.getKey(), th);
            throw Throwables.propagate(th);
        }
    }
}
Also used : DatasetModuleId(co.cask.cdap.proto.id.DatasetModuleId) DatasetModuleConflictException(co.cask.cdap.data2.datafabric.dataset.type.DatasetModuleConflictException) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) LinkedHashMap(java.util.LinkedHashMap) DatasetModule(co.cask.cdap.api.dataset.module.DatasetModule)

Example 2 with DatasetModule

use of co.cask.cdap.api.dataset.module.DatasetModule in project cdap by caskdata.

the class DatasetModulesDeployer method loadAndDeployModule.

private void loadAndDeployModule(ClassLoader artifactClassLoader, String className, Location jarLocation, String moduleName, NamespaceId namespaceId) throws ClassNotFoundException, IllegalAccessException, InstantiationException, DatasetManagementException {
    // note: using app class loader to load module class
    @SuppressWarnings("unchecked") Class<Dataset> clazz = (Class<Dataset>) artifactClassLoader.loadClass(className);
    try {
        // note: we can deploy module or create module from Dataset class
        // note: it seems dangerous to instantiate dataset module here, but this will be fine when we move deploy into
        //       isolated user's environment (e.g. separate yarn container)
        DatasetModuleId moduleId = namespaceId.datasetModule(moduleName);
        DatasetModule module;
        if (DatasetModule.class.isAssignableFrom(clazz)) {
            module = (DatasetModule) clazz.newInstance();
        } else if (Dataset.class.isAssignableFrom(clazz)) {
            if (systemDatasetFramework.hasSystemType(clazz.getName())) {
                return;
            }
            DatasetTypeId typeId = namespaceId.datasetType(clazz.getName());
            if (datasetFramework.hasType(typeId) && !allowDatasetUncheckedUpgrade) {
                return;
            }
            module = new SingleTypeModule(clazz);
        } else {
            throw new IllegalArgumentException(String.format("Cannot use class %s to add dataset module: it must be of type DatasetModule or Dataset", clazz.getName()));
        }
        LOG.info("Adding module: {}", clazz.getName());
        datasetFramework.addModule(moduleId, module, jarLocation);
    } catch (ModuleConflictException e) {
        LOG.info("Conflict while deploying module {}: {}", moduleName, e.getMessage());
        throw e;
    }
}
Also used : DatasetModuleId(co.cask.cdap.proto.id.DatasetModuleId) DatasetTypeId(co.cask.cdap.proto.id.DatasetTypeId) ModuleConflictException(co.cask.cdap.data2.dataset2.ModuleConflictException) Dataset(co.cask.cdap.api.dataset.Dataset) SingleTypeModule(co.cask.cdap.data2.dataset2.SingleTypeModule) DatasetModule(co.cask.cdap.api.dataset.module.DatasetModule)

Example 3 with DatasetModule

use of co.cask.cdap.api.dataset.module.DatasetModule in project cdap by caskdata.

the class SystemDatasetRuntimeModule method getStandaloneModules.

@Override
public Module getStandaloneModules() {
    return new AbstractModule() {

        @Override
        protected void configure() {
            MapBinder<String, DatasetModule> mapBinder = MapBinder.newMapBinder(binder(), String.class, DatasetModule.class, Constants.Dataset.Manager.DefaultDatasetModules.class);
            // NOTE: order is important due to dependencies between modules
            mapBinder.addBinding("orderedTable-leveldb").toInstance(new LevelDBTableModule());
            mapBinder.addBinding("metricsTable-leveldb").toInstance(new LevelDBMetricsTableModule());
            bindDefaultModules(mapBinder);
        }
    };
}
Also used : LevelDBMetricsTableModule(co.cask.cdap.data2.dataset2.module.lib.leveldb.LevelDBMetricsTableModule) Constants(co.cask.cdap.common.conf.Constants) LevelDBTableModule(co.cask.cdap.data2.dataset2.module.lib.leveldb.LevelDBTableModule) HBaseQueueDatasetModule(co.cask.cdap.data2.transaction.queue.hbase.HBaseQueueDatasetModule) LineageDatasetModule(co.cask.cdap.data2.metadata.lineage.LineageDatasetModule) ExternalDatasetModule(co.cask.cdap.data2.dataset2.lib.external.ExternalDatasetModule) UsageDatasetModule(co.cask.cdap.data2.registry.UsageDatasetModule) MetadataDatasetModule(co.cask.cdap.data2.metadata.dataset.MetadataDatasetModule) DatasetModule(co.cask.cdap.api.dataset.module.DatasetModule) AbstractModule(com.google.inject.AbstractModule)

Example 4 with DatasetModule

use of co.cask.cdap.api.dataset.module.DatasetModule in project cdap by caskdata.

the class SystemDatasetRuntimeModule method getInMemoryModules.

@Override
public Module getInMemoryModules() {
    return new AbstractModule() {

        @Override
        protected void configure() {
            MapBinder<String, DatasetModule> mapBinder = MapBinder.newMapBinder(binder(), String.class, DatasetModule.class, Constants.Dataset.Manager.DefaultDatasetModules.class);
            // NOTE: order is important due to dependencies between modules
            mapBinder.addBinding("orderedTable-memory").toInstance(new InMemoryTableModule());
            mapBinder.addBinding("metricsTable-memory").toInstance(new InMemoryMetricsTableModule());
            bindDefaultModules(mapBinder);
        }
    };
}
Also used : InMemoryTableModule(co.cask.cdap.data2.dataset2.module.lib.inmemory.InMemoryTableModule) InMemoryMetricsTableModule(co.cask.cdap.data2.dataset2.module.lib.inmemory.InMemoryMetricsTableModule) Constants(co.cask.cdap.common.conf.Constants) HBaseQueueDatasetModule(co.cask.cdap.data2.transaction.queue.hbase.HBaseQueueDatasetModule) LineageDatasetModule(co.cask.cdap.data2.metadata.lineage.LineageDatasetModule) ExternalDatasetModule(co.cask.cdap.data2.dataset2.lib.external.ExternalDatasetModule) UsageDatasetModule(co.cask.cdap.data2.registry.UsageDatasetModule) MetadataDatasetModule(co.cask.cdap.data2.metadata.dataset.MetadataDatasetModule) DatasetModule(co.cask.cdap.api.dataset.module.DatasetModule) AbstractModule(com.google.inject.AbstractModule)

Example 5 with DatasetModule

use of co.cask.cdap.api.dataset.module.DatasetModule in project cdap by caskdata.

the class SystemDatasetRuntimeModule method getDistributedModules.

@Override
public Module getDistributedModules() {
    return new AbstractModule() {

        @Override
        protected void configure() {
            MapBinder<String, DatasetModule> mapBinder = MapBinder.newMapBinder(binder(), String.class, DatasetModule.class, Constants.Dataset.Manager.DefaultDatasetModules.class);
            // NOTE: order is important due to dependencies between modules
            mapBinder.addBinding("orderedTable-hbase").toProvider(OrderedTableModuleProvider.class).in(Singleton.class);
            mapBinder.addBinding("metricsTable-hbase").toInstance(new HBaseMetricsTableModule());
            bindDefaultModules(mapBinder);
            mapBinder.addBinding("queueDataset").toInstance(new HBaseQueueDatasetModule());
        }
    };
}
Also used : HBaseMetricsTableModule(co.cask.cdap.data2.dataset2.module.lib.hbase.HBaseMetricsTableModule) Constants(co.cask.cdap.common.conf.Constants) HBaseQueueDatasetModule(co.cask.cdap.data2.transaction.queue.hbase.HBaseQueueDatasetModule) HBaseQueueDatasetModule(co.cask.cdap.data2.transaction.queue.hbase.HBaseQueueDatasetModule) LineageDatasetModule(co.cask.cdap.data2.metadata.lineage.LineageDatasetModule) ExternalDatasetModule(co.cask.cdap.data2.dataset2.lib.external.ExternalDatasetModule) UsageDatasetModule(co.cask.cdap.data2.registry.UsageDatasetModule) MetadataDatasetModule(co.cask.cdap.data2.metadata.dataset.MetadataDatasetModule) DatasetModule(co.cask.cdap.api.dataset.module.DatasetModule) AbstractModule(com.google.inject.AbstractModule)

Aggregations

DatasetModule (co.cask.cdap.api.dataset.module.DatasetModule)12 AbstractModule (com.google.inject.AbstractModule)6 DatasetModuleId (co.cask.cdap.proto.id.DatasetModuleId)4 Constants (co.cask.cdap.common.conf.Constants)3 ConfigModule (co.cask.cdap.common.guice.ConfigModule)3 ExternalDatasetModule (co.cask.cdap.data2.dataset2.lib.external.ExternalDatasetModule)3 MetadataDatasetModule (co.cask.cdap.data2.metadata.dataset.MetadataDatasetModule)3 LineageDatasetModule (co.cask.cdap.data2.metadata.lineage.LineageDatasetModule)3 UsageDatasetModule (co.cask.cdap.data2.registry.UsageDatasetModule)3 HBaseQueueDatasetModule (co.cask.cdap.data2.transaction.queue.hbase.HBaseQueueDatasetModule)3 MetricsCollectionService (co.cask.cdap.api.metrics.MetricsCollectionService)2 DiscoveryRuntimeModule (co.cask.cdap.common.guice.DiscoveryRuntimeModule)2 NoOpMetricsCollectionService (co.cask.cdap.common.metrics.NoOpMetricsCollectionService)2 SystemDatasetInstantiatorFactory (co.cask.cdap.data.dataset.SystemDatasetInstantiatorFactory)2 DynamicTransactionExecutorFactory (co.cask.cdap.data.runtime.DynamicTransactionExecutorFactory)2 DatasetInstanceManager (co.cask.cdap.data2.datafabric.dataset.instance.DatasetInstanceManager)2 DatasetAdminOpHTTPHandler (co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetAdminOpHTTPHandler)2 DatasetAdminService (co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetAdminService)2 DatasetOpExecutor (co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutor)2 DatasetOpExecutorService (co.cask.cdap.data2.datafabric.dataset.service.executor.DatasetOpExecutorService)2