use of io.cdap.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 io.cdap.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());
}
use of io.cdap.cdap.proto.DatasetModuleMeta in project cdap by caskdata.
the class DatasetTypeHandlerTest method verifyAll.
private void verifyAll(Set<DatasetModuleMeta> expectedModules, Map<String, List<String>> typeDependencies) throws IOException {
Set<DatasetModuleMeta> actualModules = new HashSet<>(getModules().getResponseObject());
Assert.assertEquals(expectedModules, actualModules);
for (DatasetModuleMeta expectedModule : expectedModules) {
ObjectResponse<DatasetModuleMeta> response = getModule(expectedModule.getName());
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
Assert.assertEquals(expectedModule, response.getResponseObject());
for (String type : expectedModule.getTypes()) {
ObjectResponse<DatasetTypeMeta> typeResponse = getType(type);
Assert.assertEquals(HttpStatus.SC_OK, typeResponse.getResponseCode());
verify(typeResponse.getResponseObject(), type, typeDependencies.get(type));
}
}
List<DatasetTypeMeta> actualTypes = getTypes().getResponseObject();
Assert.assertEquals(actualTypes.size(), typeDependencies.size());
Assert.assertTrue(Iterables.elementsEqual(typeDependencies.keySet(), actualTypes.stream().map(input -> input == null ? null : input.getName()).collect(Collectors.toList())));
for (DatasetTypeMeta typeMeta : actualTypes) {
verify(typeMeta, typeMeta.getName(), typeDependencies.get(typeMeta.getName()));
}
}
use of io.cdap.cdap.proto.DatasetModuleMeta in project cdap by caskdata.
the class DefaultDatasetTypeService method delete.
/**
* Deletes the specified {@link DatasetModuleId}
*/
@Override
public void delete(DatasetModuleId datasetModuleId) throws Exception {
NamespaceId namespaceId = datasetModuleId.getParent();
if (NamespaceId.SYSTEM.equals(namespaceId)) {
throw new UnsupportedOperationException(String.format("Cannot delete module '%s' from '%s' namespace.", datasetModuleId.getModule(), datasetModuleId.getNamespace()));
}
ensureNamespaceExists(namespaceId);
DatasetModuleMeta moduleMeta = typeManager.getModule(datasetModuleId);
if (moduleMeta == null) {
throw new DatasetModuleNotFoundException(datasetModuleId);
}
try {
typeManager.deleteModule(datasetModuleId);
} catch (DatasetModuleConflictException e) {
throw new DatasetModuleCannotBeDeletedException(datasetModuleId, e.getMessage());
}
}
use of io.cdap.cdap.proto.DatasetModuleMeta in project cdap by caskdata.
the class DefaultDatasetTypeService method deleteSystemModules.
private void deleteSystemModules() {
TransactionRunners.run(transactionRunner, context -> {
DatasetTypeTable datasetTypeTable = DatasetTypeTable.create(context);
Collection<DatasetModuleMeta> allDatasets = datasetTypeTable.getModules(NamespaceId.SYSTEM);
for (DatasetModuleMeta ds : allDatasets) {
if (ds.getJarLocationPath() == null) {
LOG.debug("Deleting system dataset module: {}", ds.toString());
DatasetModuleId moduleId = NamespaceId.SYSTEM.datasetModule(ds.getName());
datasetTypeTable.deleteModule(moduleId);
}
}
});
}
Aggregations