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);
}
}
}
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;
}
}
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);
}
};
}
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);
}
};
}
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());
}
};
}
Aggregations