THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||||
---|---|---|---|---|
| ||||
/** * This interface provides storing and fetching remote log segment metadata with strongly consistent semantics. * * When {@link #configure(Map)} is invoked on this instance, {@link #BROKER_ID}, {@link #CLUSTER_ID} properties are * passed which can be used by this instance if needed. These props can be used if there is a single storage used for * different clusters. For ex: MySQL storage can be used as metadata store for all the clusters across the org. * * todo-tier cleanup the abstractions in this interface. */ @InterfaceStability.Unstable public interface RemoteLogMetadataManager extends Configurable, Closeable { /** * */ String BROKER_ID = "broker.id"; /** * */ String CLUSTER_ID = "cluster.id"; /** * Stores RemoteLogSegmentMetadata with the given RemoteLogSegmentId. * * @param remoteLogSegmentMetadata * @throws IOException */ void putRemoteLogSegmentData(RemoteLogSegmentMetadata remoteLogSegmentMetadata) throws IOException; /** * Fetches RemoteLogSegmentId for the given topic partition which contains the given offset. * * @param topicPartition * @param offset * @return * @throws IOException */ RemoteLogSegmentId getRemoteLogSegmentId(TopicPartition topicPartition, long offset) throws IOException; /** * Fetches RemoteLogSegmentMetadata for the given RemoteLogSegmentId. * * @param remoteLogSegmentId * @return * @throws IOException */ RemoteLogSegmentMetadata getRemoteLogSegmentMetadata(RemoteLogSegmentId remoteLogSegmentId) throws IOException; /** * Earliest log offset if exists for the given topic partition in the remote storage. Return {@link Optional#empty()} * if there are no segments in the remote storage. * * @param tp * @return */ Optional<Long> earliestLogOffset(TopicPartition tp) throws IOException; /** * * @param tp * @return * @throws IOException */ Optional<Long> highestLogOffset(TopicPartition tp) throws IOException; /** * Deletes the log segment metadata for the given remoteLogSegmentId. * * @param remoteLogSegmentId * @throws IOException */ void deleteRemoteLogSegmentMetadata(RemoteLogSegmentId remoteLogSegmentId) throws IOException; /** * List the remote log segment files of the given topicPartition. * The RemoteLogManager of a follower uses this method to find out the remote data for the given topic partition. * * @return List of remote segments, sorted by baseOffset in ascending order. */ default List<RemoteLogSegmentMetadata> listRemoteLogSegments(TopicPartition topicPartition) { return listRemoteLogSegments(topicPartition, 0); } /** * @param topicPartition * @param minOffset * @return List of remote segments, sorted by baseOffset in ascending order. */ List<RemoteLogSegmentMetadata> listRemoteLogSegments(TopicPartition topicPartition, long minOffset); /** * This method is invoked only when there are changes in leadership of the topic partitions that this broker is * responsible for. * * @param leaderPartitions partitions that have become leaders on this broker. * @param followerPartitions partitions that have become followers on this broker. */ void onPartitionLeadershipChanges(Set<TopicPartition> leaderPartitions, Set<TopicPartition> followerPartitions); /** * This method is invoked only when the given topic partitions are stopped on this broker. This can happen when a * partition is emigrated to other broker or a partition is deleted. * * @param partitions */ void onStopPartitions(Set<TopicPartition> partitions); /** * Callback to receive once server is started so that this class can run tasks which should be run only when the * server is started. */ void onServerStarted(final String serverEndpoint); } /** * Metadata about the log segment stored in remote tier storage. */ public class RemoteLogSegmentMetadata implements Serializable { private static final long serialVersionUID = 1L; /** * Universally unique remote log segment id. */ private final RemoteLogSegmentId remoteLogSegmentId; /** * Start offset of this segment. */ private final long startOffset; /** * End offset of this segment. */ private final long endOffset; /** * Leader epoch of the broker. */ private final int leaderEpoch; /** * Maximum timestamp in the segment */ private final long maxTimestamp; /** * Epoch time at which the remote log segment is copied to the remote tier storage. */ private long createdTimestamp; /** * Size of the segment in bytes. */ private long segmentSizeInBytes; /** * It indicates that this is marked for deletion. */ private boolean markedForDeletion; /** * Any context returned by {@link RemoteStorageManager#copyLogSegment(RemoteLogSegmentId, LogSegmentData)} for * the given remoteLogSegmentId */ private final byte[] remoteLogSegmentContext; /** * @param remoteLogSegmentId Universally unique remote log segment id. * @param startOffset Start offset of this segment. * @param endOffset End offset of this segment. * @param maxTimestamp maximum timestamp in this segment * @param leaderEpoch Leader epoch of the broker. * @param createdTimestamp Epoch time at which the remote log segment is copied to the remote tier storage. * @param markedForDeletion The respective segment of remoteLogSegmentId is marked fro deletion. * @param remoteLogSegmentContext Any context returned by {@link RemoteStorageManager#copyLogSegment(RemoteLogSegmentId, LogSegmentData)} * @param segmentSizeInBytes size of this segment in bytes. */ public RemoteLogSegmentMetadata(RemoteLogSegmentId remoteLogSegmentId, long startOffset, long endOffset, long maxTimestamp, int leaderEpoch, long createdTimestamp, boolean markedForDeletion, byte[] remoteLogSegmentContext, long segmentSizeInBytes) { this.remoteLogSegmentId = remoteLogSegmentId; this.startOffset = startOffset; this.endOffset = endOffset; this.leaderEpoch = leaderEpoch; this.maxTimestamp = maxTimestamp; this.createdTimestamp = createdTimestamp; this.markedForDeletion = markedForDeletion; this.remoteLogSegmentContext = remoteLogSegmentContext; this.segmentSizeInBytes = segmentSizeInBytes; } ... } |
Proposed Changes
High-level design
...