Search in sources :

Example 1 with AccessType

use of co.cask.cdap.data2.metadata.lineage.AccessType in project cdap by caskdata.

the class RemoteLineageWriterHandler method addStreamAccess.

@POST
@Path("/addStreamAccess")
public void addStreamAccess(HttpRequest request, HttpResponder responder) throws Exception {
    Iterator<MethodArgument> arguments = parseArguments(request);
    ProgramRunId run = deserializeNext(arguments);
    StreamId stream = deserializeNext(arguments);
    AccessType accessType = deserializeNext(arguments);
    NamespacedEntityId component = deserializeNext(arguments);
    lineageWriter.addAccess(run, stream, accessType, component);
    responder.sendStatus(HttpResponseStatus.OK);
}
Also used : StreamId(co.cask.cdap.proto.id.StreamId) 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) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 2 with AccessType

use of co.cask.cdap.data2.metadata.lineage.AccessType 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)

Example 3 with AccessType

use of co.cask.cdap.data2.metadata.lineage.AccessType in project cdap by caskdata.

the class RemoteLineageWriterHandler method addDatasetAccess.

@POST
@Path("/addDatasetAccess")
public void addDatasetAccess(FullHttpRequest 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)

Example 4 with AccessType

use of co.cask.cdap.data2.metadata.lineage.AccessType in project cdap by caskdata.

the class RemoteLineageWriterHandler method addStreamAccess.

@POST
@Path("/addStreamAccess")
public void addStreamAccess(FullHttpRequest request, HttpResponder responder) throws Exception {
    Iterator<MethodArgument> arguments = parseArguments(request);
    ProgramRunId run = deserializeNext(arguments);
    StreamId stream = deserializeNext(arguments);
    AccessType accessType = deserializeNext(arguments);
    NamespacedEntityId component = deserializeNext(arguments);
    lineageWriter.addAccess(run, stream, accessType, component);
    responder.sendStatus(HttpResponseStatus.OK);
}
Also used : StreamId(co.cask.cdap.proto.id.StreamId) 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) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 5 with AccessType

use of co.cask.cdap.data2.metadata.lineage.AccessType in project cdap by caskdata.

the class LineageWriterDatasetFramework method getDataset.

@Nullable
@Override
public <T extends Dataset> T getDataset(final DatasetId datasetInstanceId, final Map<String, String> arguments, @Nullable final ClassLoader classLoader, final DatasetClassLoaderProvider classLoaderProvider, @Nullable final Iterable<? extends EntityId> owners, final AccessType accessType) throws DatasetManagementException, IOException {
    Principal principal = authenticationContext.getPrincipal();
    try {
        // For system, skip authorization and lineage (user program shouldn't allow to access system dataset CDAP-6649)
        // For non-system dataset, always perform authorization and lineage.
        AuthorizationEnforcer enforcer;
        DefaultDatasetRuntimeContext.DatasetAccessRecorder accessRecorder;
        if (!DatasetsUtil.isUserDataset(datasetInstanceId)) {
            enforcer = SYSTEM_NAMESPACE_ENFORCER;
            accessRecorder = SYSTEM_NAMESPACE_ACCESS_RECORDER;
        } else {
            enforcer = authorizationEnforcer;
            accessRecorder = new BasicDatasetAccessRecorder(datasetInstanceId, accessType, owners);
        }
        return DefaultDatasetRuntimeContext.execute(enforcer, accessRecorder, principal, datasetInstanceId, getConstructorDefaultAnnotation(accessType), new Callable<T>() {

            @Override
            public T call() throws Exception {
                return LineageWriterDatasetFramework.super.getDataset(datasetInstanceId, arguments, classLoader, classLoaderProvider, owners, accessType);
            }
        });
    } catch (IOException | DatasetManagementException | ServiceUnavailableException e) {
        throw e;
    } catch (Exception e) {
        throw new DatasetManagementException("Failed to create dataset instance: " + datasetInstanceId, e);
    }
}
Also used : AuthorizationEnforcer(co.cask.cdap.security.spi.authorization.AuthorizationEnforcer) IOException(java.io.IOException) ServiceUnavailableException(co.cask.cdap.common.ServiceUnavailableException) DefaultDatasetRuntimeContext(co.cask.cdap.data2.dataset2.DefaultDatasetRuntimeContext) ServiceUnavailableException(co.cask.cdap.common.ServiceUnavailableException) DatasetManagementException(co.cask.cdap.api.dataset.DatasetManagementException) IOException(java.io.IOException) DatasetManagementException(co.cask.cdap.api.dataset.DatasetManagementException) Principal(co.cask.cdap.proto.security.Principal) Nullable(javax.annotation.Nullable)

Aggregations

NamespacedEntityId (co.cask.cdap.proto.id.NamespacedEntityId)5 ProgramRunId (co.cask.cdap.proto.id.ProgramRunId)5 MethodArgument (co.cask.cdap.common.internal.remote.MethodArgument)4 AccessType (co.cask.cdap.data2.metadata.lineage.AccessType)4 POST (javax.ws.rs.POST)4 Path (javax.ws.rs.Path)4 DatasetId (co.cask.cdap.proto.id.DatasetId)3 StreamId (co.cask.cdap.proto.id.StreamId)3 DatasetManagementException (co.cask.cdap.api.dataset.DatasetManagementException)1 ServiceUnavailableException (co.cask.cdap.common.ServiceUnavailableException)1 DefaultDatasetRuntimeContext (co.cask.cdap.data2.dataset2.DefaultDatasetRuntimeContext)1 MDSKey (co.cask.cdap.data2.dataset2.lib.table.MDSKey)1 EntityId (co.cask.cdap.proto.id.EntityId)1 ProgramId (co.cask.cdap.proto.id.ProgramId)1 Principal (co.cask.cdap.proto.security.Principal)1 AuthorizationEnforcer (co.cask.cdap.security.spi.authorization.AuthorizationEnforcer)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Nullable (javax.annotation.Nullable)1 RunId (org.apache.twill.api.RunId)1