use of co.cask.cdap.proto.DatasetModuleMeta in project cdap by caskdata.
the class DatasetTypeService method listModules.
/**
* Returns all {@link DatasetModuleMeta dataset modules} in the specified {@link NamespaceId namespace}.
*/
List<DatasetModuleMeta> listModules(final NamespaceId namespaceId) throws Exception {
ensureNamespaceExists(namespaceId);
// Sorting by name for convenience
List<DatasetModuleMeta> allModules = Lists.newArrayList(typeManager.getModules(namespaceId));
Collections.sort(allModules, new Comparator<DatasetModuleMeta>() {
@Override
public int compare(DatasetModuleMeta o1, DatasetModuleMeta o2) {
return o1.getName().compareTo(o2.getName());
}
});
Principal principal = authenticationContext.getPrincipal();
final Predicate<EntityId> authFilter = authorizationEnforcer.createFilter(principal);
Iterable<DatasetModuleMeta> authorizedDatasetModules = Iterables.filter(allModules, new com.google.common.base.Predicate<DatasetModuleMeta>() {
@Override
public boolean apply(DatasetModuleMeta datasetModuleMeta) {
return authFilter.apply(namespaceId.datasetModule(datasetModuleMeta.getName()));
}
});
return Lists.newArrayList(authorizedDatasetModules);
}
use of co.cask.cdap.proto.DatasetModuleMeta 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.proto.DatasetModuleMeta in project cdap by caskdata.
the class GenerateClientUsageExample method datasetModuleClient.
public void datasetModuleClient() throws Exception {
// Construct the client used to interact with CDAP
DatasetModuleClient datasetModuleClient = new DatasetModuleClient(clientConfig);
// Add a dataset module
File moduleJarFile = createAppJarFile(SomeDatasetModule.class);
DatasetModuleId datasetModuleId = NamespaceId.DEFAULT.datasetModule("someDatasetModule");
datasetModuleClient.add(datasetModuleId, SomeDatasetModule.class.getName(), moduleJarFile);
// Fetch the dataset module information
DatasetModuleMeta datasetModuleMeta = datasetModuleClient.get(datasetModuleId);
// Delete all dataset modules
datasetModuleClient.deleteAll(NamespaceId.DEFAULT);
}
use of co.cask.cdap.proto.DatasetModuleMeta in project cdap by caskdata.
the class ListDatasetTypesCommand method perform.
@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
List<DatasetTypeMeta> datasetTypeMetas = datasetTypeClient.list(cliConfig.getCurrentNamespace());
Table table = Table.builder().setHeader("name", "modules").setRows(datasetTypeMetas, new RowMaker<DatasetTypeMeta>() {
@Override
public List<?> makeRow(DatasetTypeMeta object) {
List<String> modulesStrings = Lists.newArrayList();
for (DatasetModuleMeta module : object.getModules()) {
modulesStrings.add(module.getName());
}
return Lists.newArrayList(object.getName(), Joiner.on(", ").join(modulesStrings));
}
}).build();
cliConfig.getTableRenderer().render(cliConfig, output, table);
}
use of co.cask.cdap.proto.DatasetModuleMeta in project cdap by caskdata.
the class DatasetTypeHandlerTest method testBundledJarModule.
// Tests that a module can be deployed from a jar that is embedded in a bundle jar. This verifies class loading.
@Test
public void testBundledJarModule() throws Exception {
// Get jar of TestModule1
Location module1Jar = createModuleJar(TestModule1.class);
// Create bundle jar with TestModule2 and TestModule1 inside it, request for deploy is made for Module1.
Assert.assertEquals(200, deployModuleBundled("module1", TestModule1.class.getName(), TestModule2.class, module1Jar));
Assert.assertEquals(HttpStatus.SC_OK, deleteModules().getResponseCode());
List<DatasetModuleMeta> modules = getModules().getResponseObject();
Assert.assertEquals(0, modules.size());
}
Aggregations