use of io.cdap.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);
}
use of io.cdap.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 io.cdap.cdap.client.DatasetClient in project cdap by caskdata.
the class AppFabricTestBase method initializeAndStartServices.
protected static void initializeAndStartServices(CConfiguration cConf, Module overrides) throws Exception {
injector = Guice.createInjector(Modules.override(new AppFabricTestModule(cConf, null)).with(overrides));
int connectionTimeout = cConf.getInt(Constants.HTTP_CLIENT_CONNECTION_TIMEOUT_MS);
int readTimeout = cConf.getInt(Constants.HTTP_CLIENT_READ_TIMEOUT_MS);
httpRequestConfig = new HttpRequestConfig(connectionTimeout, readTimeout, false);
messagingService = injector.getInstance(MessagingService.class);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
// Define all StructuredTable before starting any services that need StructuredTable
StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
metadataStorage = injector.getInstance(MetadataStorage.class);
metadataStorage.createIndex();
dsOpService = injector.getInstance(DatasetOpExecutorService.class);
dsOpService.startAndWait();
datasetService = injector.getInstance(DatasetService.class);
datasetService.startAndWait();
appFabricServer = injector.getInstance(AppFabricServer.class);
appFabricServer.startAndWait();
DiscoveryServiceClient discoveryClient = injector.getInstance(DiscoveryServiceClient.class);
appFabricEndpointStrategy = new RandomEndpointStrategy(() -> discoveryClient.discover(Constants.Service.APP_FABRIC_HTTP));
txClient = injector.getInstance(TransactionSystemClient.class);
metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
metricsCollectionService.startAndWait();
serviceStore = injector.getInstance(ServiceStore.class);
serviceStore.startAndWait();
metadataService = injector.getInstance(MetadataService.class);
metadataService.startAndWait();
metadataSubscriberService = injector.getInstance(MetadataSubscriberService.class);
metadataSubscriberService.startAndWait();
logQueryService = injector.getInstance(LogQueryService.class);
logQueryService.startAndWait();
locationFactory = getInjector().getInstance(LocationFactory.class);
datasetClient = new DatasetClient(getClientConfig(discoveryClient, Constants.Service.DATASET_MANAGER));
remoteClientFactory = new RemoteClientFactory(discoveryClient, new DefaultInternalAuthenticator(new AuthenticationTestContext()));
metadataClient = new MetadataClient(getClientConfig(discoveryClient, Constants.Service.METADATA_SERVICE));
metadataServiceClient = new DefaultMetadataServiceClient(remoteClientFactory);
metricStore = injector.getInstance(MetricStore.class);
Scheduler programScheduler = injector.getInstance(Scheduler.class);
// Wait for the scheduler to be functional.
if (programScheduler instanceof CoreSchedulerService) {
try {
((CoreSchedulerService) programScheduler).waitUntilFunctional(10, TimeUnit.SECONDS);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
createNamespaces();
}
use of io.cdap.cdap.client.DatasetClient in project cdap by caskdata.
the class SupportBundleTestBase method initializeAndStartServices.
protected static void initializeAndStartServices(CConfiguration cConf, Module overrides) throws Exception {
injector = Guice.createInjector(Modules.override(new AppFabricTestModule(cConf, null)).with(overrides));
int connectionTimeout = cConf.getInt(Constants.HTTP_CLIENT_CONNECTION_TIMEOUT_MS);
int readTimeout = cConf.getInt(Constants.HTTP_CLIENT_READ_TIMEOUT_MS);
httpRequestConfig = new HttpRequestConfig(connectionTimeout, readTimeout, false);
messagingService = injector.getInstance(MessagingService.class);
if (messagingService instanceof Service) {
((Service) messagingService).startAndWait();
}
txManager = injector.getInstance(TransactionManager.class);
txManager.startAndWait();
// Define all StructuredTable before starting any services that need StructuredTable
StoreDefinition.createAllTables(injector.getInstance(StructuredTableAdmin.class));
metadataStorage = injector.getInstance(MetadataStorage.class);
metadataStorage.createIndex();
dsOpService = injector.getInstance(DatasetOpExecutorService.class);
dsOpService.startAndWait();
datasetService = injector.getInstance(DatasetService.class);
datasetService.startAndWait();
appFabricServer = injector.getInstance(AppFabricServer.class);
appFabricServer.startAndWait();
DiscoveryServiceClient discoveryClient = injector.getInstance(DiscoveryServiceClient.class);
appFabricEndpointStrategy = new RandomEndpointStrategy(() -> discoveryClient.discover(Constants.Service.APP_FABRIC_HTTP));
metricsCollectionService = injector.getInstance(MetricsCollectionService.class);
metricsCollectionService.startAndWait();
serviceStore = injector.getInstance(ServiceStore.class);
serviceStore.startAndWait();
metadataService = injector.getInstance(MetadataService.class);
metadataService.startAndWait();
metadataSubscriberService = injector.getInstance(MetadataSubscriberService.class);
metadataSubscriberService.startAndWait();
logQueryService = injector.getInstance(LogQueryService.class);
logQueryService.startAndWait();
locationFactory = getInjector().getInstance(LocationFactory.class);
datasetClient = new DatasetClient(getClientConfig(discoveryClient, Constants.Service.DATASET_MANAGER));
remoteClientFactory = new RemoteClientFactory(discoveryClient, new DefaultInternalAuthenticator(new AuthenticationTestContext()));
metadataClient = new MetadataClient(getClientConfig(discoveryClient, Constants.Service.METADATA_SERVICE));
appFabricHealthCheckService = injector.getInstance(HealthCheckService.class);
appFabricHealthCheckService.helper(Constants.AppFabricHealthCheck.APP_FABRIC_HEALTH_CHECK_SERVICE, cConf, Constants.Service.MASTER_SERVICES_BIND_ADDRESS);
appFabricHealthCheckService.startAndWait();
supportBundleInternalService = injector.getInstance(SupportBundleInternalService.class);
supportBundleInternalService.startAndWait();
Scheduler programScheduler = injector.getInstance(Scheduler.class);
// Wait for the scheduler to be functional.
if (programScheduler instanceof CoreSchedulerService) {
try {
((CoreSchedulerService) programScheduler).waitUntilFunctional(10, TimeUnit.SECONDS);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Aggregations