Search in sources :

Example 1 with StorageMetadata

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))));
    }
}
Also used : ChunkMetadata(io.pravega.segmentstore.storage.metadata.ChunkMetadata) SegmentMetadata(io.pravega.segmentstore.storage.metadata.SegmentMetadata) Serializer(io.pravega.client.stream.Serializer) ChunkMetadata(io.pravega.segmentstore.storage.metadata.ChunkMetadata) SegmentMetadata(io.pravega.segmentstore.storage.metadata.SegmentMetadata) StorageMetadata(io.pravega.segmentstore.storage.metadata.StorageMetadata) ByteArraySegment(io.pravega.common.util.ByteArraySegment) ImmutableMap(com.google.common.collect.ImmutableMap) TransactionData(io.pravega.segmentstore.storage.metadata.BaseMetadataStore.TransactionData) ReadIndexBlockMetadata(io.pravega.segmentstore.storage.metadata.ReadIndexBlockMetadata) Map(java.util.Map) IOException(java.io.IOException) Function(java.util.function.Function) ByteBuffer(java.nio.ByteBuffer) ReadIndexBlockMetadata(io.pravega.segmentstore.storage.metadata.ReadIndexBlockMetadata)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 Serializer (io.pravega.client.stream.Serializer)1 ByteArraySegment (io.pravega.common.util.ByteArraySegment)1 TransactionData (io.pravega.segmentstore.storage.metadata.BaseMetadataStore.TransactionData)1 ChunkMetadata (io.pravega.segmentstore.storage.metadata.ChunkMetadata)1 ReadIndexBlockMetadata (io.pravega.segmentstore.storage.metadata.ReadIndexBlockMetadata)1 SegmentMetadata (io.pravega.segmentstore.storage.metadata.SegmentMetadata)1 StorageMetadata (io.pravega.segmentstore.storage.metadata.StorageMetadata)1 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 Map (java.util.Map)1 Function (java.util.function.Function)1