Search in sources :

Example 1 with DatasetId

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;
}
Also used : DatasetManagementException(co.cask.cdap.api.dataset.DatasetManagementException) MetricsTable(co.cask.cdap.data2.dataset2.lib.table.MetricsTable) ServiceUnavailableException(co.cask.cdap.common.ServiceUnavailableException) IOException(java.io.IOException) DatasetId(co.cask.cdap.proto.id.DatasetId)

Example 2 with DatasetId

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;
        }
    });
}
Also used : BadRequestException(co.cask.cdap.common.BadRequestException) ExploreException(co.cask.cdap.explore.service.ExploreException) SQLException(java.sql.SQLException) DatasetManagementException(co.cask.cdap.api.dataset.DatasetManagementException) JsonSyntaxException(com.google.gson.JsonSyntaxException) UnsupportedTypeException(co.cask.cdap.api.data.schema.UnsupportedTypeException) IOException(java.io.IOException) DatasetId(co.cask.cdap.proto.id.DatasetId) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 3 with DatasetId

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;
        }
    });
}
Also used : BadRequestException(co.cask.cdap.common.BadRequestException) ExploreException(co.cask.cdap.explore.service.ExploreException) SQLException(java.sql.SQLException) DatasetManagementException(co.cask.cdap.api.dataset.DatasetManagementException) JsonSyntaxException(com.google.gson.JsonSyntaxException) UnsupportedTypeException(co.cask.cdap.api.data.schema.UnsupportedTypeException) IOException(java.io.IOException) DatasetId(co.cask.cdap.proto.id.DatasetId) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 4 with DatasetId

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);
}
Also used : DatasetId(co.cask.cdap.proto.id.DatasetId) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with DatasetId

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);
}
Also used : NamespacedEntityId(co.cask.cdap.proto.id.NamespacedEntityId) MethodArgument(co.cask.cdap.common.internal.remote.MethodArgument) ProgramRunId(co.cask.cdap.proto.id.ProgramRunId) AccessType(co.cask.cdap.data2.metadata.lineage.AccessType) DatasetId(co.cask.cdap.proto.id.DatasetId) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

DatasetId (co.cask.cdap.proto.id.DatasetId)219 Test (org.junit.Test)107 Path (javax.ws.rs.Path)47 ProgramId (co.cask.cdap.proto.id.ProgramId)39 NamespaceId (co.cask.cdap.proto.id.NamespaceId)34 StreamId (co.cask.cdap.proto.id.StreamId)34 TransactionExecutor (org.apache.tephra.TransactionExecutor)30 POST (javax.ws.rs.POST)29 IOException (java.io.IOException)25 ApplicationId (co.cask.cdap.proto.id.ApplicationId)23 DatasetManagementException (co.cask.cdap.api.dataset.DatasetManagementException)22 DatasetSpecification (co.cask.cdap.api.dataset.DatasetSpecification)21 PartitionedFileSet (co.cask.cdap.api.dataset.lib.PartitionedFileSet)17 NamespaceMeta (co.cask.cdap.proto.NamespaceMeta)16 QueryResult (co.cask.cdap.proto.QueryResult)16 Table (co.cask.cdap.api.dataset.table.Table)15 Map (java.util.Map)15 BadRequestException (co.cask.cdap.common.BadRequestException)14 ColumnDesc (co.cask.cdap.proto.ColumnDesc)14 TransactionFailureException (org.apache.tephra.TransactionFailureException)14