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.
*
*/
@InterfaceStability.Unstable
public interface RemoteLogMetadataManager extends Configurable, Closeable {
/**
* Stores RemoteLogSegmentMetadata for the given RemoteLogSegmentMetadata.
*
* @param remoteLogSegmentId
* @param remoteLogSegmentMetadata
* @throws IOException
*/
void putRemoteLogSegmentData(RemoteLogSegmentId remoteLogSegmentId, 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 metadata
* @return
* @throws IOException
*/
RemoteLogSegmentMetadata getRemoteLogSegmentMetadata(RemoteLogSegmentId metadata) 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;
/**
* Sets the earliest offset for the given topic partition.
*
* @param tp
* @throws IOException
*/
void setEarliestLogOffset(TopicPartition tp, long offset) 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<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 bcome followers on this broker.
*/
void onLeadershipChange(List<TopicPartition> leaderPartitions, List<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 onStopPartition(List<TopicPartition> partitions);
}
/**
* Metadata about the log segment stored in remote tier storage.
*/
public class RemoteLogSegmentMetadata {
/**
* Universally unique remote log segment id.
*/
private RemoteLogSegmentId remoteLogSegmentId;
/**
* Start offset of this segment.
*/
private long startOffset;
/**
* End offset of this segment.
*/
private long endOffset;
/**
* leader epoch of the broker.
*/
private int leaderEpoch;
/**
* whether that remote segment is created or not.
*/
private boolean created;
/**
* Any context returned by {@link RemoteLogStorageManager#copyLogSegment(RemoteLogSegmentId, LogSegmentData)} for
* the given remoteLogSegmentId
*/
private byte[] remoteLogSegmentContext;
...
}
|
...