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();
}
}
}
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;
}
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();
}
Aggregations