Search in sources :

Example 1 with MetadataException

use of io.cdap.cdap.api.metadata.MetadataException in project cdap by caskdata.

the class RemoteMetadataReader method getMetadata.

@Override
public Map<MetadataScope, Metadata> getMetadata(MetadataEntity metadataEntity) throws MetadataException {
    Map<MetadataScope, Metadata> scopeMetadata = new HashMap<>();
    Set<MetadataRecord> metadata;
    try {
        metadata = metadataClient.getMetadata(metadataEntity);
    } catch (ServiceUnavailableException e) {
        throw e;
    } catch (Exception e) {
        throw new MetadataException(e);
    }
    metadata.forEach(record -> scopeMetadata.put(record.getScope(), new Metadata(record.getProperties(), record.getTags())));
    LOG.trace("Returning metadata record {} for {}", scopeMetadata, metadataEntity);
    return scopeMetadata;
}
Also used : HashMap(java.util.HashMap) Metadata(io.cdap.cdap.api.metadata.Metadata) ServiceUnavailableException(io.cdap.cdap.common.ServiceUnavailableException) MetadataRecord(io.cdap.cdap.common.metadata.MetadataRecord) MetadataException(io.cdap.cdap.api.metadata.MetadataException) ServiceUnavailableException(io.cdap.cdap.common.ServiceUnavailableException) MetadataException(io.cdap.cdap.api.metadata.MetadataException) MetadataScope(io.cdap.cdap.api.metadata.MetadataScope)

Aggregations

Metadata (io.cdap.cdap.api.metadata.Metadata)1 MetadataException (io.cdap.cdap.api.metadata.MetadataException)1 MetadataScope (io.cdap.cdap.api.metadata.MetadataScope)1 ServiceUnavailableException (io.cdap.cdap.common.ServiceUnavailableException)1 MetadataRecord (io.cdap.cdap.common.metadata.MetadataRecord)1 HashMap (java.util.HashMap)1