use of io.cdap.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());
}
use of io.cdap.cdap.data2.metadata.system.SystemMetadataWriter in project cdap by caskdata.
the class DatasetAdminService method writeSystemMetadata.
private void writeSystemMetadata(DatasetId datasetInstanceId, final DatasetSpecification spec, DatasetProperties props, final DatasetTypeMeta typeMeta, final DatasetType type, final DatasetContext context, boolean existing, UserGroupInformation ugi) throws IOException {
// add system metadata for user datasets only
if (DatasetsUtil.isUserDataset(datasetInstanceId)) {
Dataset dataset = null;
try {
try {
dataset = ImpersonationUtils.doAs(ugi, () -> type.getDataset(context, spec, DatasetDefinition.NO_ARGUMENTS));
} catch (Exception e) {
LOG.warn("Exception while instantiating Dataset {}", datasetInstanceId, e);
}
// Make sure to write whatever system metadata that can be derived
// even if the above instantiation throws exception
SystemMetadataWriter systemMetadataWriter;
if (existing) {
systemMetadataWriter = new DatasetSystemMetadataWriter(metadataStore, datasetInstanceId, props, dataset, typeMeta.getName(), spec.getDescription());
} else {
long createTime = System.currentTimeMillis();
systemMetadataWriter = new DatasetSystemMetadataWriter(metadataStore, datasetInstanceId, props, createTime, dataset, typeMeta.getName(), spec.getDescription());
}
systemMetadataWriter.write();
} finally {
if (dataset != null) {
dataset.close();
}
}
}
}
use of io.cdap.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);
}
use of io.cdap.cdap.data2.metadata.system.SystemMetadataWriter in project cdap by caskdata.
the class DatasetInstanceService method publishMetadata.
private void publishMetadata(DatasetId dataset, SystemMetadata metadata) {
if (metadata != null && !metadata.isEmpty()) {
SystemMetadataWriter metadataWriter = new DelegateSystemMetadataWriter(metadataServiceClient, dataset, metadata);
metadataWriter.write();
}
}
use of io.cdap.cdap.data2.metadata.system.SystemMetadataWriter in project cdap by cdapio.
the class DatasetInstanceService method publishMetadata.
private void publishMetadata(DatasetId dataset, SystemMetadata metadata) {
if (metadata != null && !metadata.isEmpty()) {
SystemMetadataWriter metadataWriter = new DelegateSystemMetadataWriter(metadataServiceClient, dataset, metadata);
metadataWriter.write();
}
}
Aggregations