use of co.cask.cdap.proto.id.DatasetId in project cdap by caskdata.
the class UsageHandler method getDatasetAppUsage.
@GET
@Path("/namespaces/{namespace-id}/data/datasets/{dataset-id}/programs")
public void getDatasetAppUsage(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("dataset-id") String datasetId) {
final DatasetId id = new DatasetId(namespaceId, datasetId);
Set<ProgramId> ids = registry.getPrograms(id);
responder.sendJson(HttpResponseStatus.OK, BackwardCompatibility.IdProgram.transform(ids));
}
use of co.cask.cdap.proto.id.DatasetId in project cdap by caskdata.
the class WorkflowHttpHandler method deleteWorkflowLocalDatasets.
@DELETE
@Path("/apps/{app-id}/workflows/{workflow-id}/runs/{run-id}/localdatasets")
public void deleteWorkflowLocalDatasets(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String applicationId, @PathParam("workflow-id") String workflowId, @PathParam("run-id") String runId) throws NotFoundException {
WorkflowSpecification workflowSpec = getWorkflowSpecForValidRun(namespaceId, applicationId, workflowId, runId);
Set<String> errorOnDelete = new HashSet<>();
for (Map.Entry<String, DatasetCreationSpec> localDatasetEntry : workflowSpec.getLocalDatasetSpecs().entrySet()) {
String mappedDatasetName = localDatasetEntry.getKey() + "." + runId;
// try best to delete the local datasets.
try {
datasetFramework.deleteInstance(new DatasetId(namespaceId, mappedDatasetName));
} catch (InstanceNotFoundException e) {
// Dataset instance is already deleted. so its no-op.
} catch (Throwable t) {
errorOnDelete.add(mappedDatasetName);
LOG.error("Failed to delete the Workflow local dataset {}. Reason - {}", mappedDatasetName, t.getMessage());
}
}
if (errorOnDelete.isEmpty()) {
responder.sendStatus(HttpResponseStatus.OK);
return;
}
String errorMessage = "Failed to delete Workflow local datasets - " + Joiner.on(",").join(errorOnDelete);
throw new RuntimeException(errorMessage);
}
use of co.cask.cdap.proto.id.DatasetId in project cdap by caskdata.
the class RemoteLineageWriterHandler method addDatasetAccess.
@POST
@Path("/addDatasetAccess")
public void addDatasetAccess(HttpRequest request, HttpResponder responder) throws Exception {
Iterator<MethodArgument> arguments = parseArguments(request);
ProgramRunId run = deserializeNext(arguments);
DatasetId datasetInstance = deserializeNext(arguments);
AccessType accessType = deserializeNext(arguments);
NamespacedEntityId component = deserializeNext(arguments);
lineageWriter.addAccess(run, datasetInstance, accessType, component);
responder.sendStatus(HttpResponseStatus.OK);
}
use of co.cask.cdap.proto.id.DatasetId in project cdap by caskdata.
the class RemoteUsageRegistryHandler method registerDataset.
@POST
@Path("/registerDataset")
public void registerDataset(HttpRequest request, HttpResponder responder) throws Exception {
Iterator<MethodArgument> arguments = parseArguments(request);
ProgramId programId = deserializeNext(arguments);
DatasetId datasetInstance = deserializeNext(arguments);
usageRegistry.register(programId, datasetInstance);
responder.sendStatus(HttpResponseStatus.OK);
}
use of co.cask.cdap.proto.id.DatasetId in project cdap by caskdata.
the class WorkflowDriver method createLocalDatasets.
private void createLocalDatasets() throws IOException, DatasetManagementException {
String principal = programOptions.getArguments().getOption(ProgramOptionConstants.PRINCIPAL);
final KerberosPrincipalId principalId = principal == null ? null : new KerberosPrincipalId(principal);
for (final Map.Entry<String, String> entry : datasetFramework.getDatasetNameMapping().entrySet()) {
final String localInstanceName = entry.getValue();
final DatasetId instanceId = new DatasetId(workflowRunId.getNamespace(), localInstanceName);
final DatasetCreationSpec instanceSpec = workflowSpec.getLocalDatasetSpecs().get(entry.getKey());
LOG.debug("Adding Workflow local dataset instance: {}", localInstanceName);
try {
Retries.callWithRetries(new Retries.Callable<Void, Exception>() {
@Override
public Void call() throws Exception {
datasetFramework.addInstance(instanceSpec.getTypeName(), instanceId, addLocalDatasetProperty(instanceSpec.getProperties()), principalId);
return null;
}
}, RetryStrategies.fixDelay(Constants.Retry.LOCAL_DATASET_OPERATION_RETRY_DELAY_SECONDS, TimeUnit.SECONDS));
} catch (IOException | DatasetManagementException e) {
throw e;
} catch (Exception e) {
// this should never happen
throw new IllegalStateException(e);
}
}
}
Aggregations