Search in sources :

Example 1 with ViewSystemMetadataWriter

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

the class ExistingEntitySystemMetadataWriter method writeSystemMetadataForStreams.

private void writeSystemMetadataForStreams(NamespaceId namespace) throws Exception {
    for (StreamSpecification streamSpec : store.getAllStreams(namespace)) {
        StreamId streamId = namespace.stream(streamSpec.getName());
        SystemMetadataWriter writer = new StreamSystemMetadataWriter(metadataStore, streamId, streamAdmin.getConfig(streamId), streamSpec.getDescription());
        writer.write();
        for (StreamViewId view : streamAdmin.listViews(streamId)) {
            writer = new ViewSystemMetadataWriter(metadataStore, view, viewAdmin.get(view), true);
            writer.write();
        }
    }
}
Also used : StreamSystemMetadataWriter(co.cask.cdap.data2.metadata.system.StreamSystemMetadataWriter) StreamId(co.cask.cdap.proto.id.StreamId) ViewSystemMetadataWriter(co.cask.cdap.data2.metadata.system.ViewSystemMetadataWriter) StreamSpecification(co.cask.cdap.api.data.stream.StreamSpecification) 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) StreamViewId(co.cask.cdap.proto.id.StreamViewId)

Example 2 with ViewSystemMetadataWriter

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

Example 3 with ViewSystemMetadataWriter

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

the class ViewSystemMetadataWriterTest method getViewMetadataSchema.

private String getViewMetadataSchema(String format, @Nullable Schema schema) {
    StreamViewId viewId = NamespaceId.DEFAULT.stream("mystream").view("myview");
    FormatSpecification formatSpec = new FormatSpecification(format, schema);
    ViewSpecification viewSpec = new ViewSpecification(formatSpec);
    NoOpMetadataStore metadataStore = new NoOpMetadataStore();
    ViewSystemMetadataWriter writer = new ViewSystemMetadataWriter(metadataStore, viewId, viewSpec, false);
    return writer.getSchemaToAdd();
}
Also used : NoOpMetadataStore(co.cask.cdap.data2.metadata.store.NoOpMetadataStore) FormatSpecification(co.cask.cdap.api.data.format.FormatSpecification) ViewSpecification(co.cask.cdap.proto.ViewSpecification) StreamViewId(co.cask.cdap.proto.id.StreamViewId)

Aggregations

ViewSystemMetadataWriter (co.cask.cdap.data2.metadata.system.ViewSystemMetadataWriter)2 ViewSpecification (co.cask.cdap.proto.ViewSpecification)2 StreamViewId (co.cask.cdap.proto.id.StreamViewId)2 FormatSpecification (co.cask.cdap.api.data.format.FormatSpecification)1 StreamSpecification (co.cask.cdap.api.data.stream.StreamSpecification)1 NotFoundException (co.cask.cdap.common.NotFoundException)1 NoOpMetadataStore (co.cask.cdap.data2.metadata.store.NoOpMetadataStore)1 AppSystemMetadataWriter (co.cask.cdap.data2.metadata.system.AppSystemMetadataWriter)1 ArtifactSystemMetadataWriter (co.cask.cdap.data2.metadata.system.ArtifactSystemMetadataWriter)1 DatasetSystemMetadataWriter (co.cask.cdap.data2.metadata.system.DatasetSystemMetadataWriter)1 ProgramSystemMetadataWriter (co.cask.cdap.data2.metadata.system.ProgramSystemMetadataWriter)1 StreamSystemMetadataWriter (co.cask.cdap.data2.metadata.system.StreamSystemMetadataWriter)1 SystemMetadataWriter (co.cask.cdap.data2.metadata.system.SystemMetadataWriter)1 StreamId (co.cask.cdap.proto.id.StreamId)1