use of io.pravega.segmentstore.storage.metadata.StorageMetadata in project pravega by pravega.
the class SltsMetadataSerializer method handleStorageMetadataValue.
/**
* Convert {@link StorageMetadata} into string of fields and values to be appended it into the given StringBuilder.
*
* @param builder The given StringBuilder.
* @param metadata The StorageMetadata instance.
*/
private void handleStorageMetadataValue(StringBuilder builder, StorageMetadata metadata) {
if (metadata instanceof ChunkMetadata) {
appendField(builder, METADATA_TYPE, CHUNK_METADATA);
ChunkMetadata chunkMetadata = (ChunkMetadata) metadata;
CHUNK_METADATA_FIELD_MAP.forEach((name, f) -> appendField(builder, name, String.valueOf(f.apply(chunkMetadata))));
} else if (metadata instanceof SegmentMetadata) {
appendField(builder, METADATA_TYPE, SEGMENT_METADATA);
SegmentMetadata segmentMetadata = (SegmentMetadata) metadata;
SEGMENT_METADATA_FIELD_MAP.forEach((name, f) -> appendField(builder, name, String.valueOf(f.apply(segmentMetadata))));
} else if (metadata instanceof ReadIndexBlockMetadata) {
appendField(builder, METADATA_TYPE, READ_INDEX_BLOCK_METADATA);
ReadIndexBlockMetadata readIndexBlockMetadata = (ReadIndexBlockMetadata) metadata;
READ_INDEX_BLOCK_METADATA_FIELD_MAP.forEach((name, f) -> appendField(builder, name, String.valueOf(f.apply(readIndexBlockMetadata))));
}
}
Aggregations