Search in sources :

Example 6 with SystemMetadataWriter

use of co.cask.cdap.data2.metadata.system.SystemMetadataWriter in project cdap by caskdata.

the class ExistingEntitySystemMetadataWriter method writeSystemMetadataForArtifacts.

private void writeSystemMetadataForArtifacts(NamespaceId namespace) throws IOException {
    for (ArtifactDetail artifactDetail : artifactStore.getArtifacts(namespace)) {
        co.cask.cdap.api.artifact.ArtifactId artifact = artifactDetail.getDescriptor().getArtifactId();
        ArtifactInfo artifactInfo = new ArtifactInfo(artifact, artifactDetail.getMeta().getClasses(), artifactDetail.getMeta().getProperties());
        ArtifactId artifactId = namespace.artifact(artifact.getName(), artifact.getVersion().getVersion());
        SystemMetadataWriter writer = new ArtifactSystemMetadataWriter(metadataStore, artifactId, artifactInfo);
        writer.write();
    }
}
Also used : ArtifactInfo(co.cask.cdap.api.artifact.ArtifactInfo) ArtifactId(co.cask.cdap.proto.id.ArtifactId) DatasetSystemMetadataWriter(co.cask.cdap.data2.metadata.system.DatasetSystemMetadataWriter) ProgramSystemMetadataWriter(co.cask.cdap.data2.metadata.system.ProgramSystemMetadataWriter) ViewSystemMetadataWriter(co.cask.cdap.data2.metadata.system.ViewSystemMetadataWriter) SystemMetadataWriter(co.cask.cdap.data2.metadata.system.SystemMetadataWriter) AppSystemMetadataWriter(co.cask.cdap.data2.metadata.system.AppSystemMetadataWriter) ArtifactSystemMetadataWriter(co.cask.cdap.data2.metadata.system.ArtifactSystemMetadataWriter) StreamSystemMetadataWriter(co.cask.cdap.data2.metadata.system.StreamSystemMetadataWriter) ArtifactSystemMetadataWriter(co.cask.cdap.data2.metadata.system.ArtifactSystemMetadataWriter) ArtifactDetail(co.cask.cdap.internal.app.runtime.artifact.ArtifactDetail)

Example 7 with SystemMetadataWriter

use of co.cask.cdap.data2.metadata.system.SystemMetadataWriter in project cdap by caskdata.

the class FileStreamAdmin method updateProperties.

private StreamProperties updateProperties(StreamId streamId, StreamProperties properties) throws Exception {
    StreamConfig config = getConfig(streamId);
    StreamConfig.Builder builder = StreamConfig.builder(config);
    if (properties.getTTL() != null) {
        builder.setTTL(properties.getTTL());
    }
    if (properties.getFormat() != null) {
        builder.setFormatSpec(properties.getFormat());
    }
    if (properties.getNotificationThresholdMB() != null) {
        builder.setNotificationThreshold(properties.getNotificationThresholdMB());
    }
    // update stream description
    String description = properties.getDescription();
    if (description != null) {
        streamMetaStore.addStream(streamId, description);
    }
    final StreamConfig newConfig = builder.build();
    impersonator.doAs(streamId, new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            writeConfig(newConfig);
            return null;
        }
    });
    // Update system metadata for stream
    SystemMetadataWriter systemMetadataWriter = new StreamSystemMetadataWriter(metadataStore, streamId, newConfig, description);
    systemMetadataWriter.write();
    return new StreamProperties(config.getTTL(), config.getFormat(), config.getNotificationThresholdMB());
}
Also used : StreamSystemMetadataWriter(co.cask.cdap.data2.metadata.system.StreamSystemMetadataWriter) SystemMetadataWriter(co.cask.cdap.data2.metadata.system.SystemMetadataWriter) StreamSystemMetadataWriter(co.cask.cdap.data2.metadata.system.StreamSystemMetadataWriter) StreamProperties(co.cask.cdap.proto.StreamProperties) CoordinatorStreamProperties(co.cask.cdap.data.stream.CoordinatorStreamProperties) NotificationFeedException(co.cask.cdap.notifications.feeds.NotificationFeedException) FileNotFoundException(java.io.FileNotFoundException) UnauthorizedException(co.cask.cdap.security.spi.authorization.UnauthorizedException) IOException(java.io.IOException) NotFoundException(co.cask.cdap.common.NotFoundException) StreamNotFoundException(co.cask.cdap.common.StreamNotFoundException)

Example 8 with SystemMetadataWriter

use of co.cask.cdap.data2.metadata.system.SystemMetadataWriter in project cdap by caskdata.

the class SystemMetadataWriterStage method process.

@Override
public void process(ApplicationWithPrograms input) throws Exception {
    // add system metadata for apps
    ApplicationId appId = input.getApplicationId();
    ApplicationSpecification appSpec = input.getSpecification();
    // only update creation time if this is a new app
    Map<String, String> properties = metadataStore.getProperties(MetadataScope.SYSTEM, appId);
    SystemMetadataWriter appSystemMetadataWriter = new AppSystemMetadataWriter(metadataStore, appId, appSpec, !properties.isEmpty());
    appSystemMetadataWriter.write();
    // add system metadata for programs
    writeProgramSystemMetadata(appId, ProgramType.FLOW, appSpec.getFlows().values());
    writeProgramSystemMetadata(appId, ProgramType.MAPREDUCE, appSpec.getMapReduce().values());
    writeProgramSystemMetadata(appId, ProgramType.SERVICE, appSpec.getServices().values());
    writeProgramSystemMetadata(appId, ProgramType.SPARK, appSpec.getSpark().values());
    writeProgramSystemMetadata(appId, ProgramType.WORKER, appSpec.getWorkers().values());
    writeProgramSystemMetadata(appId, ProgramType.WORKFLOW, appSpec.getWorkflows().values());
    // Emit input to the next stage
    emit(input);
}
Also used : ApplicationSpecification(co.cask.cdap.api.app.ApplicationSpecification) SystemMetadataWriter(co.cask.cdap.data2.metadata.system.SystemMetadataWriter) AppSystemMetadataWriter(co.cask.cdap.data2.metadata.system.AppSystemMetadataWriter) ProgramSystemMetadataWriter(co.cask.cdap.data2.metadata.system.ProgramSystemMetadataWriter) ApplicationId(co.cask.cdap.proto.id.ApplicationId) AppSystemMetadataWriter(co.cask.cdap.data2.metadata.system.AppSystemMetadataWriter)

Example 9 with SystemMetadataWriter

use of co.cask.cdap.data2.metadata.system.SystemMetadataWriter in project cdap by caskdata.

the class ViewAdmin method createOrUpdate.

public boolean createOrUpdate(StreamViewId viewId, ViewSpecification spec) throws Exception {
    try {
        ViewSpecification previousSpec = store.get(viewId);
        if (spec.getTableName() == null) {
            // use the previous table name
            spec = new ViewSpecification(spec.getFormat(), previousSpec.getTableName());
        } else if (!spec.getTableName().equals(previousSpec.getTableName())) {
            throw new IllegalArgumentException(String.format("Cannot change table name for view %s", viewId));
        }
        explore.disableExploreStream(viewId.getParent(), previousSpec.getTableName());
    } catch (NotFoundException e) {
    // pass through
    }
    if (spec.getTableName() == null) {
        spec = new ViewSpecification(spec.getFormat(), naming.getTableName(viewId));
    }
    explore.enableExploreStream(viewId.getParent(), spec.getTableName(), spec.getFormat());
    boolean result = store.createOrUpdate(viewId, spec);
    ViewSystemMetadataWriter systemMetadataWriter = new ViewSystemMetadataWriter(metadataStore, viewId, spec, !result);
    systemMetadataWriter.write();
    return result;
}
Also used : ViewSystemMetadataWriter(co.cask.cdap.data2.metadata.system.ViewSystemMetadataWriter) ViewSpecification(co.cask.cdap.proto.ViewSpecification) NotFoundException(co.cask.cdap.common.NotFoundException)

Aggregations

SystemMetadataWriter (co.cask.cdap.data2.metadata.system.SystemMetadataWriter)8 AppSystemMetadataWriter (co.cask.cdap.data2.metadata.system.AppSystemMetadataWriter)6 DatasetSystemMetadataWriter (co.cask.cdap.data2.metadata.system.DatasetSystemMetadataWriter)6 ProgramSystemMetadataWriter (co.cask.cdap.data2.metadata.system.ProgramSystemMetadataWriter)6 StreamSystemMetadataWriter (co.cask.cdap.data2.metadata.system.StreamSystemMetadataWriter)6 ViewSystemMetadataWriter (co.cask.cdap.data2.metadata.system.ViewSystemMetadataWriter)6 ArtifactSystemMetadataWriter (co.cask.cdap.data2.metadata.system.ArtifactSystemMetadataWriter)5 NotFoundException (co.cask.cdap.common.NotFoundException)3 IOException (java.io.IOException)3 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)2 Dataset (co.cask.cdap.api.dataset.Dataset)2 DatasetManagementException (co.cask.cdap.api.dataset.DatasetManagementException)2 ApplicationId (co.cask.cdap.proto.id.ApplicationId)2 Callable (java.util.concurrent.Callable)2 ProgramSpecification (co.cask.cdap.api.ProgramSpecification)1 ArtifactInfo (co.cask.cdap.api.artifact.ArtifactInfo)1 StreamSpecification (co.cask.cdap.api.data.stream.StreamSpecification)1 DatasetProperties (co.cask.cdap.api.dataset.DatasetProperties)1 IncompatibleUpdateException (co.cask.cdap.api.dataset.IncompatibleUpdateException)1 BadRequestException (co.cask.cdap.common.BadRequestException)1