Search in sources :

Example 1 with AccessType

use of io.cdap.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 io.cdap.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 io.cdap.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 io.cdap.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 io.cdap.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.
        AccessEnforcer enforcer;
        DefaultDatasetRuntimeContext.DatasetAccessRecorder accessRecorder;
        if (!DatasetsUtil.isUserDataset(datasetInstanceId)) {
            enforcer = SYSTEM_NAMESPACE_ENFORCER;
            accessRecorder = SYSTEM_NAMESPACE_ACCESS_RECORDER;
        } else {
            enforcer = accessEnforcer;
            accessRecorder = new BasicDatasetAccessRecorder(datasetInstanceId, accessType, owners);
        }
        return DefaultDatasetRuntimeContext.execute(enforcer, accessRecorder, principal, datasetInstanceId, getConstructorDefaultAnnotation(accessType), () -> 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 : DatasetManagementException(io.cdap.cdap.api.dataset.DatasetManagementException) AccessEnforcer(io.cdap.cdap.security.spi.authorization.AccessEnforcer) IOException(java.io.IOException) ServiceUnavailableException(io.cdap.cdap.common.ServiceUnavailableException) DefaultDatasetRuntimeContext(io.cdap.cdap.data2.dataset2.DefaultDatasetRuntimeContext) Principal(io.cdap.cdap.proto.security.Principal) ServiceUnavailableException(io.cdap.cdap.common.ServiceUnavailableException) DatasetManagementException(io.cdap.cdap.api.dataset.DatasetManagementException) IOException(java.io.IOException) Nullable(javax.annotation.Nullable)

Aggregations

MethodArgument (co.cask.cdap.common.internal.remote.MethodArgument)4 AccessType (co.cask.cdap.data2.metadata.lineage.AccessType)4 NamespacedEntityId (co.cask.cdap.proto.id.NamespacedEntityId)4 ProgramRunId (co.cask.cdap.proto.id.ProgramRunId)4 POST (javax.ws.rs.POST)4 Path (javax.ws.rs.Path)4 DatasetId (co.cask.cdap.proto.id.DatasetId)2 StreamId (co.cask.cdap.proto.id.StreamId)2 DatasetManagementException (io.cdap.cdap.api.dataset.DatasetManagementException)1 ServiceUnavailableException (io.cdap.cdap.common.ServiceUnavailableException)1 DefaultDatasetRuntimeContext (io.cdap.cdap.data2.dataset2.DefaultDatasetRuntimeContext)1 Principal (io.cdap.cdap.proto.security.Principal)1 AccessEnforcer (io.cdap.cdap.security.spi.authorization.AccessEnforcer)1 IOException (java.io.IOException)1 Nullable (javax.annotation.Nullable)1