Search in sources :

Example 21 with MetadataStore

use of co.cask.cdap.data2.metadata.store.MetadataStore in project cdap by caskdata.

the class ArtifactRepository method writeSystemMetadata.

private void writeSystemMetadata(co.cask.cdap.proto.id.ArtifactId artifactId, ArtifactInfo artifactInfo) {
    // add system metadata for artifacts
    ArtifactSystemMetadataWriter writer = new ArtifactSystemMetadataWriter(metadataStore, artifactId, artifactInfo);
    writer.write();
}
Also used : ArtifactSystemMetadataWriter(co.cask.cdap.data2.metadata.system.ArtifactSystemMetadataWriter)

Example 22 with MetadataStore

use of co.cask.cdap.data2.metadata.store.MetadataStore 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

MetadataStore (co.cask.cdap.data2.metadata.store.MetadataStore)10 LineageStore (co.cask.cdap.data2.metadata.lineage.LineageStore)8 SystemMetadataWriter (co.cask.cdap.data2.metadata.system.SystemMetadataWriter)8 Test (org.junit.Test)8 Store (co.cask.cdap.app.store.Store)7 Lineage (co.cask.cdap.data2.metadata.lineage.Lineage)7 Relation (co.cask.cdap.data2.metadata.lineage.Relation)7 ProgramSystemMetadataWriter (co.cask.cdap.data2.metadata.system.ProgramSystemMetadataWriter)7 AppSystemMetadataWriter (co.cask.cdap.data2.metadata.system.AppSystemMetadataWriter)6 ArtifactSystemMetadataWriter (co.cask.cdap.data2.metadata.system.ArtifactSystemMetadataWriter)6 DatasetSystemMetadataWriter (co.cask.cdap.data2.metadata.system.DatasetSystemMetadataWriter)6 StreamSystemMetadataWriter (co.cask.cdap.data2.metadata.system.StreamSystemMetadataWriter)6 ViewSystemMetadataWriter (co.cask.cdap.data2.metadata.system.ViewSystemMetadataWriter)6 ProgramRunId (co.cask.cdap.proto.id.ProgramRunId)4 NotFoundException (co.cask.cdap.common.NotFoundException)3 DatasetId (co.cask.cdap.proto.id.DatasetId)3 ProgramId (co.cask.cdap.proto.id.ProgramId)3 IOException (java.io.IOException)3 ProgramSpecification (co.cask.cdap.api.ProgramSpecification)2 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)2