Search in sources :

Example 1 with RemoteLogSegmentMetadataRecord

use of org.apache.kafka.server.log.remote.metadata.storage.generated.RemoteLogSegmentMetadataRecord in project kafka by apache.

the class RemoteLogSegmentMetadataTransform method fromApiMessageAndVersion.

@Override
public RemoteLogSegmentMetadata fromApiMessageAndVersion(ApiMessageAndVersion apiMessageAndVersion) {
    RemoteLogSegmentMetadataRecord record = (RemoteLogSegmentMetadataRecord) apiMessageAndVersion.message();
    RemoteLogSegmentId remoteLogSegmentId = buildRemoteLogSegmentId(record.remoteLogSegmentId());
    Map<Integer, Long> segmentLeaderEpochs = new HashMap<>();
    for (RemoteLogSegmentMetadataRecord.SegmentLeaderEpochEntry segmentLeaderEpoch : record.segmentLeaderEpochs()) {
        segmentLeaderEpochs.put(segmentLeaderEpoch.leaderEpoch(), segmentLeaderEpoch.offset());
    }
    RemoteLogSegmentMetadata remoteLogSegmentMetadata = new RemoteLogSegmentMetadata(remoteLogSegmentId, record.startOffset(), record.endOffset(), record.maxTimestampMs(), record.brokerId(), record.eventTimestampMs(), record.segmentSizeInBytes(), segmentLeaderEpochs);
    RemoteLogSegmentMetadataUpdate rlsmUpdate = new RemoteLogSegmentMetadataUpdate(remoteLogSegmentId, record.eventTimestampMs(), RemoteLogSegmentState.forId(record.remoteLogSegmentState()), record.brokerId());
    return remoteLogSegmentMetadata.createWithUpdates(rlsmUpdate);
}
Also used : HashMap(java.util.HashMap) RemoteLogSegmentMetadataUpdate(org.apache.kafka.server.log.remote.storage.RemoteLogSegmentMetadataUpdate) RemoteLogSegmentMetadataRecord(org.apache.kafka.server.log.remote.metadata.storage.generated.RemoteLogSegmentMetadataRecord) RemoteLogSegmentId(org.apache.kafka.server.log.remote.storage.RemoteLogSegmentId) RemoteLogSegmentMetadata(org.apache.kafka.server.log.remote.storage.RemoteLogSegmentMetadata)

Aggregations

HashMap (java.util.HashMap)1 RemoteLogSegmentMetadataRecord (org.apache.kafka.server.log.remote.metadata.storage.generated.RemoteLogSegmentMetadataRecord)1 RemoteLogSegmentId (org.apache.kafka.server.log.remote.storage.RemoteLogSegmentId)1 RemoteLogSegmentMetadata (org.apache.kafka.server.log.remote.storage.RemoteLogSegmentMetadata)1 RemoteLogSegmentMetadataUpdate (org.apache.kafka.server.log.remote.storage.RemoteLogSegmentMetadataUpdate)1