use of co.cask.cdap.proto.id.DatasetId in project cdap by caskdata.
the class UsageHandlerTestRun method testMapReduceUsage.
@Test
public void testMapReduceUsage() throws Exception {
final ApplicationId app = NamespaceId.DEFAULT.app(AllProgramsApp.NAME);
final ProgramId program = app.mr(AllProgramsApp.NoOpMR.NAME);
final StreamId stream = NamespaceId.DEFAULT.stream(AllProgramsApp.STREAM_NAME);
final DatasetId dataset = NamespaceId.DEFAULT.dataset(AllProgramsApp.DATASET_NAME);
Assert.assertEquals(0, getAppStreamUsage(app).size());
Assert.assertEquals(0, getProgramStreamUsage(program).size());
Assert.assertEquals(0, getStreamProgramUsage(stream).size());
Assert.assertEquals(0, getAppDatasetUsage(app).size());
Assert.assertEquals(0, getDatasetProgramUsage(dataset).size());
deployApp(AllProgramsApp.class);
// now that we only support dynamic dataset instantiation in initialize (and not in configure as before),
// we must run the mapreduce program to register its usage
startProgram(program);
waitState(program, ProgramStatus.STOPPED);
try {
Assert.assertTrue(getAppStreamUsage(app).contains(stream));
Assert.assertTrue(getProgramStreamUsage(program).contains(stream));
Assert.assertTrue(getStreamProgramUsage(stream).contains(program));
Assert.assertTrue(getProgramDatasetUsage(program).contains(dataset));
Assert.assertTrue(getAppDatasetUsage(app).contains(dataset));
Assert.assertTrue(getDatasetProgramUsage(dataset).contains(program));
} finally {
deleteApp(app);
Assert.assertEquals(0, getAppStreamUsage(app).size());
Assert.assertEquals(0, getProgramStreamUsage(program).size());
Assert.assertEquals(0, getStreamProgramUsage(stream).size());
Assert.assertEquals(0, getAppDatasetUsage(app).size());
Assert.assertEquals(0, getDatasetProgramUsage(dataset).size());
}
}
use of co.cask.cdap.proto.id.DatasetId in project cdap by caskdata.
the class UsageHandlerTestRun method testWorkerUsage.
@Test
public void testWorkerUsage() throws Exception {
final ApplicationId app = NamespaceId.DEFAULT.app(AllProgramsApp.NAME);
final ProgramId program = app.worker(AllProgramsApp.NoOpWorker.NAME);
final StreamId stream = NamespaceId.DEFAULT.stream(AllProgramsApp.STREAM_NAME);
final DatasetId dataset = NamespaceId.DEFAULT.dataset(AllProgramsApp.DATASET_NAME);
Assert.assertEquals(0, getAppStreamUsage(app).size());
Assert.assertEquals(0, getProgramStreamUsage(program).size());
Assert.assertEquals(0, getStreamProgramUsage(stream).size());
Assert.assertEquals(0, getAppDatasetUsage(app).size());
Assert.assertEquals(0, getDatasetProgramUsage(dataset).size());
deployApp(AllProgramsApp.class);
try {
startProgram(program);
// Wait for the worker to run and then stop.
waitState(program, ProgramStatus.RUNNING);
waitState(program, ProgramStatus.STOPPED);
Assert.assertTrue(getAppStreamUsage(app).contains(stream));
Assert.assertTrue(getProgramStreamUsage(program).contains(stream));
Assert.assertTrue(getStreamProgramUsage(stream).contains(program));
Assert.assertTrue(getProgramDatasetUsage(program).contains(dataset));
Assert.assertTrue(getAppDatasetUsage(app).contains(dataset));
Assert.assertTrue(getDatasetProgramUsage(dataset).contains(program));
} finally {
deleteApp(app);
Assert.assertEquals(0, getAppStreamUsage(app).size());
Assert.assertEquals(0, getProgramStreamUsage(program).size());
Assert.assertEquals(0, getStreamProgramUsage(stream).size());
Assert.assertEquals(0, getAppDatasetUsage(app).size());
Assert.assertEquals(0, getDatasetProgramUsage(dataset).size());
}
}
use of co.cask.cdap.proto.id.DatasetId in project cdap by caskdata.
the class UsageHandlerTestRun method testServiceUsage.
@Test
public void testServiceUsage() throws Exception {
final ApplicationId app = NamespaceId.DEFAULT.app(AllProgramsApp.NAME);
final ProgramId program = app.service(AllProgramsApp.NoOpService.NAME);
final DatasetId dataset = NamespaceId.DEFAULT.dataset(AllProgramsApp.DATASET_NAME);
Assert.assertEquals(0, getAppDatasetUsage(app).size());
Assert.assertEquals(0, getDatasetProgramUsage(dataset).size());
deployApp(AllProgramsApp.class);
try {
Assert.assertTrue(getProgramDatasetUsage(program).contains(dataset));
Assert.assertTrue(getAppDatasetUsage(app).contains(dataset));
Assert.assertTrue(getDatasetProgramUsage(dataset).contains(program));
} finally {
deleteApp(app);
Assert.assertEquals(0, getAppDatasetUsage(app).size());
Assert.assertEquals(0, getDatasetProgramUsage(dataset).size());
}
}
use of co.cask.cdap.proto.id.DatasetId in project cdap by caskdata.
the class PartitionedFileSetAdmin method truncate.
@Override
public void truncate() throws IOException {
super.truncate();
// should fix this.
if (FileSetProperties.isExploreEnabled(spec.getProperties())) {
ExploreFacade exploreFacade = exploreFacadeProvider.get();
if (exploreFacade != null) {
DatasetId instanceId = new DatasetId(context.getNamespaceId(), spec.getName());
try {
exploreFacade.disableExploreDataset(instanceId, spec);
exploreFacade.enableExploreDataset(instanceId, spec, true);
} catch (Exception e) {
throw new DataSetException(String.format("Unable to reset explore on dataset %s", instanceId), e);
}
}
}
}
use of co.cask.cdap.proto.id.DatasetId in project cdap by caskdata.
the class DatasetServiceAuthorizationTest method testNotFound.
@Test
public void testNotFound() throws Exception {
String namespace = NamespaceId.DEFAULT.getNamespace();
final DatasetId nonExistingInstance = NamespaceId.DEFAULT.dataset("notfound");
final DatasetModuleId nonExistingModule = NamespaceId.DEFAULT.datasetModule("notfound");
final DatasetTypeId nonExistingType = NamespaceId.DEFAULT.datasetType("notfound");
Assert.assertNull(dsFramework.getDatasetSpec(nonExistingInstance));
Assert.assertFalse(dsFramework.hasInstance(nonExistingInstance));
assertNotFound(new DatasetOperationExecutor() {
@Override
public void execute() throws Exception {
dsFramework.updateInstance(nonExistingInstance, DatasetProperties.EMPTY);
}
}, String.format("Expected %s to not exist", nonExistingInstance));
assertNotFound(new DatasetOperationExecutor() {
@Override
public void execute() throws Exception {
dsFramework.deleteInstance(nonExistingInstance);
}
}, String.format("Expected %s to not exist", nonExistingInstance));
assertNotFound(new DatasetOperationExecutor() {
@Override
public void execute() throws Exception {
dsFramework.truncateInstance(nonExistingInstance);
}
}, String.format("Expected %s to not exist", nonExistingInstance));
assertNotFound(new DatasetOperationExecutor() {
@Override
public void execute() throws Exception {
dsFramework.deleteModule(nonExistingModule);
}
}, String.format("Expected %s to not exist", nonExistingModule));
Assert.assertNull(String.format("Expected %s to not exist", nonExistingType), dsFramework.getTypeInfo(nonExistingType));
}
Aggregations