use of co.cask.cdap.api.dataset.module.DatasetDefinitionRegistry 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().getModule(), new TransactionInMemoryModule(), new NamespaceClientRuntimeModule().getInMemoryModules(), new AuditModule().getInMemoryModules(), 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);
namespacedLocationFactory = injector.getInstance(NamespacedLocationFactory.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);
namespaceAdmin.create(new NamespaceMeta.Builder().setName(NAMESPACE_ID).build());
}
use of co.cask.cdap.api.dataset.module.DatasetDefinitionRegistry in project cdap by caskdata.
the class InMemoryDatasetFramework method deleteModule.
@Override
public void deleteModule(DatasetModuleId moduleId) {
// TODO (CDAP-6297): check if existing datasets or modules use this module
writeLock.lock();
try {
moduleClasses.remove(moduleId.getParent(), moduleId);
LinkedHashSet<String> availableModuleClasses = getAvailableModuleClasses(moduleId.getParent());
// this will cleanup types
DatasetDefinitionRegistry registry = createRegistry(availableModuleClasses, registries.getClass().getClassLoader());
registries.put(moduleId.getParent(), registry);
} finally {
writeLock.unlock();
}
}
use of co.cask.cdap.api.dataset.module.DatasetDefinitionRegistry in project cdap by caskdata.
the class InMemoryDatasetFramework method addModule.
@Override
public void addModule(DatasetModuleId moduleId, DatasetModule module) throws ModuleConflictException {
// TODO (CDAP-6297): check if existing modules overlap, or if this removes a type other modules depend on
writeLock.lock();
try {
DatasetDefinitionRegistry registry = registries.get(moduleId.getParent());
if (registry == null) {
registry = registryFactory.create();
registries.put(moduleId.getParent(), registry);
}
TypesTrackingRegistry trackingRegistry = new TypesTrackingRegistry(registry);
module.register(trackingRegistry);
String moduleClassName = DatasetModules.getDatasetModuleClass(module).getName();
moduleClasses.put(moduleId.getParent(), moduleId, moduleClassName);
List<String> types = trackingRegistry.getTypes();
nonDefaultTypes.putAll(moduleId.getParent(), types);
for (String type : types) {
this.types.put(moduleId.getParent().datasetType(type), new DatasetTypeMeta(type, Collections.singletonList(new DatasetModuleMeta(moduleId.getEntityName(), moduleClassName, null, types, Collections.<String>emptyList()))));
}
} finally {
writeLock.unlock();
}
}
use of co.cask.cdap.api.dataset.module.DatasetDefinitionRegistry in project cdap by caskdata.
the class InMemoryDatasetFramework method getDefinitionForType.
@Nullable
@VisibleForTesting
DatasetDefinition getDefinitionForType(NamespaceId namespaceId, String datasetType) {
DatasetDefinitionRegistry registry = registries.get(namespaceId);
if (registry != null && registry.hasType(datasetType)) {
return registry.get(datasetType);
}
registry = registries.get(NamespaceId.SYSTEM);
if (registry != null && registry.hasType(datasetType)) {
return registry.get(datasetType);
}
return null;
}
Aggregations