use of co.cask.cdap.client.DatasetClient in project cdap by caskdata.
the class AppFabricTestBase method initializeAndStartServices.
protected static void initializeAndStartServices(CConfiguration cConf, @Nullable SConfiguration sConf) throws Exception {
injector = Guice.createInjector(Modules.override(new AppFabricTestModule(cConf, sConf)).with(new AbstractModule() {
@Override
protected void configure() {
// needed because we set Kerberos to true in DefaultNamespaceAdminTest
bind(UGIProvider.class).to(CurrentUGIProvider.class);
}
}));
messagingService = injector.getInstance(MessagingService.class);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
dsOpService = injector.getInstance(DatasetOpExecutor.class);
dsOpService.startAndWait();
remoteSysOpService = injector.getInstance(RemoteSystemOperationsService.class);
remoteSysOpService.startAndWait();
datasetService = injector.getInstance(DatasetService.class);
datasetService.startAndWait();
appFabricServer = injector.getInstance(AppFabricServer.class);
appFabricServer.startAndWait();
DiscoveryServiceClient discoveryClient = injector.getInstance(DiscoveryServiceClient.class);
ServiceDiscovered appFabricHttpDiscovered = discoveryClient.discover(Constants.Service.APP_FABRIC_HTTP);
EndpointStrategy endpointStrategy = new RandomEndpointStrategy(appFabricHttpDiscovered);
port = endpointStrategy.pick(1, TimeUnit.SECONDS).getSocketAddress().getPort();
txClient = injector.getInstance(TransactionSystemClient.class);
metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
metricsCollectionService.startAndWait();
metricsService = injector.getInstance(MetricsQueryService.class);
metricsService.startAndWait();
streamService = injector.getInstance(StreamService.class);
streamService.startAndWait();
serviceStore = injector.getInstance(ServiceStore.class);
serviceStore.startAndWait();
metadataService = injector.getInstance(MetadataService.class);
metadataService.startAndWait();
locationFactory = getInjector().getInstance(LocationFactory.class);
streamClient = new StreamClient(getClientConfig(discoveryClient, Constants.Service.STREAMS));
datasetClient = new DatasetClient(getClientConfig(discoveryClient, Constants.Service.DATASET_MANAGER));
createNamespaces();
}
use of co.cask.cdap.client.DatasetClient in project cdap by caskdata.
the class IntegrationTestBase method assertNoUserDatasets.
private void assertNoUserDatasets(NamespaceId namespace) throws Exception {
DatasetClient datasetClient = getDatasetClient();
List<DatasetSpecificationSummary> datasets = datasetClient.list(namespace);
Iterable<DatasetSpecificationSummary> userDatasets = Iterables.filter(datasets, new Predicate<DatasetSpecificationSummary>() {
@Override
public boolean apply(DatasetSpecificationSummary input) {
return isUserDataset(input);
}
});
Iterable<String> userDatasetNames = Iterables.transform(userDatasets, new Function<DatasetSpecificationSummary, String>() {
@Override
public String apply(DatasetSpecificationSummary input) {
return input.getName();
}
});
Assert.assertFalse("Must have no user datasets, but found the following user datasets: " + Joiner.on(", ").join(userDatasetNames), userDatasets.iterator().hasNext());
}
use of co.cask.cdap.client.DatasetClient in project cdap by caskdata.
the class GenerateClientUsageExample method datasetClient.
public void datasetClient() throws Exception {
// Construct the client used to interact with CDAP
DatasetClient datasetClient = new DatasetClient(clientConfig);
// Fetch the list of datasets
List<DatasetSpecificationSummary> datasets = datasetClient.list(NamespaceId.DEFAULT);
// Create a dataset
DatasetId datasetId = NamespaceId.DEFAULT.dataset("someDataset");
datasetClient.create(datasetId, "someDatasetType");
// Truncate a dataset
datasetClient.truncate(datasetId);
// Delete a dataset
datasetClient.delete(datasetId);
}
Aggregations