use of co.cask.cdap.proto.id.DatasetId in project cdap by caskdata.
the class MetricsDataMigrator method getOrCreateMetricsTable.
private MetricsTable getOrCreateMetricsTable(String tableName, DatasetProperties empty) throws DataMigrationException {
MetricsTable table = null;
// for default namespace, we have to provide the complete table name.
tableName = "system." + tableName;
// metrics tables are in the system namespace
DatasetId metricsDatasetInstanceId = NamespaceId.DEFAULT.dataset(tableName);
try {
table = DatasetsUtil.getOrCreateDataset(dsFramework, metricsDatasetInstanceId, MetricsTable.class.getName(), empty, null);
} catch (DatasetManagementException | ServiceUnavailableException e) {
String msg = String.format("Cannot access or create table %s.", tableName) + " " + e.getMessage();
LOG.warn(msg);
throw new DataMigrationException(msg);
} catch (IOException e) {
String msg = String.format("Exception while creating table %s", tableName);
LOG.error(msg, e);
throw new DataMigrationException(msg);
}
return table;
}
use of co.cask.cdap.proto.id.DatasetId in project cdap by caskdata.
the class ExploreExecutorHttpHandler method dropPartition.
// this should really be a DELETE request. However, the partition key must be passed in the body
// of the request, and that does not work with many HTTP clients, including Java's URLConnection.
@POST
@Path("datasets/{dataset}/deletePartition")
public void dropPartition(final HttpRequest request, final HttpResponder responder, @PathParam("namespace-id") String namespace, @PathParam("dataset") String datasetName, @HeaderParam(Constants.Security.Headers.PROGRAM_ID) String programId) throws Exception {
final DatasetId datasetId = new DatasetId(namespace, datasetName);
propagateUserId(request);
impersonator.doAs(getEntityToImpersonate(datasetId, programId), new Callable<Void>() {
@Override
public Void call() throws Exception {
doDropPartition(request, responder, datasetId);
return null;
}
});
}
use of co.cask.cdap.proto.id.DatasetId in project cdap by caskdata.
the class ExploreExecutorHttpHandler method addPartition.
@POST
@Path("datasets/{dataset}/partitions")
public void addPartition(final HttpRequest request, final HttpResponder responder, @PathParam("namespace-id") String namespace, @PathParam("dataset") String datasetName, @HeaderParam(Constants.Security.Headers.PROGRAM_ID) String programId) throws Exception {
final DatasetId datasetId = new DatasetId(namespace, datasetName);
propagateUserId(request);
impersonator.doAs(getEntityToImpersonate(datasetId, programId), new Callable<Void>() {
@Override
public Void call() throws Exception {
doAddPartition(request, responder, datasetId);
return null;
}
});
}
use of co.cask.cdap.proto.id.DatasetId in project cdap by caskdata.
the class AuthorizerTest method testHierarchy.
@Test
// TODO: Enable when hierarchy is supported
@Ignore
public void testHierarchy() throws Exception {
Authorizer authorizer = get();
DatasetId dataset = namespace.dataset("bar");
verifyAuthFailure(namespace, user, Action.READ);
authorizer.grant(namespace, user, Collections.singleton(Action.READ));
authorizer.enforce(dataset, user, Action.READ);
authorizer.grant(dataset, user, Collections.singleton(Action.WRITE));
verifyAuthFailure(namespace, user, Action.WRITE);
authorizer.revoke(namespace, user, Collections.singleton(Action.READ));
authorizer.revoke(dataset);
verifyAuthFailure(namespace, user, Action.READ);
}
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);
}
Aggregations