use of io.cdap.cdap.data2.metadata.system.DatasetSystemMetadataProvider in project cdap by caskdata.
the class DatasetAdminService method computeSystemMetadata.
private SystemMetadata computeSystemMetadata(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
DatasetSystemMetadataProvider metadataProvider;
if (existing) {
metadataProvider = new DatasetSystemMetadataProvider(datasetInstanceId, props, dataset, typeMeta.getName(), spec.getDescription());
} else {
long createTime = System.currentTimeMillis();
metadataProvider = new DatasetSystemMetadataProvider(datasetInstanceId, props, createTime, dataset, typeMeta.getName(), spec.getDescription());
}
return new SystemMetadata(metadataProvider.getSystemPropertiesToAdd(), metadataProvider.getSystemTagsToAdd(), metadataProvider.getSchemaToAdd());
} finally {
if (dataset != null) {
dataset.close();
}
}
}
return SystemMetadata.EMPTY;
}
Aggregations