public interface TierPartitionState
Modifier and Type | Interface and Description |
---|---|
static class |
TierPartitionState.AppendResult
The result of an attempt to append a tier metadata entry.
|
static class |
TierPartitionState.RestoreResult
The result of an attempt to restore a TierPartitionState via a PartitionForceRestore event
|
Modifier and Type | Method and Description |
---|---|
TierPartitionState.AppendResult |
append(AbstractTierMetadata tierMetadata,
OffsetAndEpoch sourceOffsetAndEpoch)
Appends abstract metadata to the tier partition.
|
void |
beginCatchup()
Begin catchup phase for tier partition state.
|
void |
close()
Close TierPartition, flushing to disk.
|
void |
closeHandlers() |
long |
committedEndOffset()
Return the end offset spanned by the TierPartitionState that has been committed to disk.
|
void |
delete()
Delete this TierPartitionState from local storage.
|
File |
dir()
The directory where the TierPartition is stored on disk.
|
long |
endOffset()
Return the uncommitted end offset spanned by the TierPartitionState.
|
Collection<TierObjectMetadata> |
fencedSegments() |
boolean |
flush()
Flush data contained in this TierPartitionState to disk.
|
kafka.common.FollowerRestorePoint |
followerRestorePoint(long targetStartOffset)
Get the TierObjectMetadata for the immediate previous segment (even beyond retention) to the target startOffset.
|
boolean |
isTieringEnabled() |
OffsetAndEpoch |
lastLocalMaterializedSrcOffsetAndEpoch()
Return the last materialized source offset and epoch
|
long |
materializationLag()
Return the current tier materialization lag.
|
CompletableFuture<Optional<TierObjectMetadata>> |
materializeUptoLeaderEpoch(int targetEpoch)
Sets up a listener for this tier partition state.
|
CompletableFuture<TierObjectMetadata> |
materializeUptoObjectIdAndRestoreEpoch(long upperBoundEndOffset,
UUID targetObjectId,
int targetRestoreEpoch)
Sets up a listener for this tier partition stae for use by the replica fetcher.
|
CompletableFuture<TierObjectMetadata> |
materializeUptoOffset(long targetOffset)
Sets up a listener for this tier partition state for use by the replica fetcher.
|
boolean |
maybeOpenChannelOnOffsetTieredException()
Called when a replica receives OFFSET_TIERED exception while replicating from leader.
|
boolean |
mayContainTieredData()
Indicates if a partition may have some tiered data, essentially whether tiered storage is currently enabled or was enabled
earlier for this partition.
|
Optional<TierObjectMetadata> |
metadata(long targetOffset)
Lookup the TierObjectMetadata which will contain data for a target offset.
|
int |
numSegments()
Scan the ObjectMetadata (segment) entries in this tier partition, and return the count.
|
int |
numSegments(long from,
long to)
Count of the number of segments lying within a range
|
void |
onCatchUpComplete()
Mark catchup completed for tier partition state.
|
Optional<FileTierPartitionState.TierInMemorySegmentMetadata> |
previousMetadataBeforeOffset(long targetStartOffset)
Get the in-memory metadata for the immediate previous segment (even beyond retention) to target startOffset
|
TierPartitionState.RestoreResult |
restoreState(TierPartitionForceRestore metadata,
ByteBuffer targetState,
TierPartitionStatus targetStatus,
OffsetAndEpoch sourceOffsetAndEpoch)
Performs a TierPartitionState restore, swapping the current state file
from buffer and replacing any internal state with the contents of the new TierPartitionState,
setting the TierPartitionStatus of the state to status.
|
List<FileTierPartitionState.TierInMemorySegmentMetadata> |
segmentInMemoryMetadataRange(long from,
long to)
List of all the segment (minimal) metadata whose startOffset is in the range (even if they are beyond retention).
|
Iterator<TierObjectMetadata> |
segments()
Get an iterator for all readable tiered segments.
|
Iterator<TierObjectMetadata> |
segments(long from,
long to)
Get an iterator for all readable tiered segments in a given range.
|
void |
setTieringDisabled()
Reset the tier(ing) enabled flag at TierPartitionState.
|
boolean |
setTieringEnabled()
Called when tiering is enabled for this tier topic partition.
|
boolean |
setTopicId(UUID topicId)
Sets the TopicIdPartition for this TierPartitionState.
|
Optional<Long> |
startOffset()
Determine start offset spanned by the TierPartitionState.
|
TierPartitionStatus |
status()
Return the current status of the TierPartitionState.
|
int |
tierEpoch()
Return the current tierEpoch.
|
Optional<TopicIdPartition> |
topicIdPartition()
Optional TopicIdPartition corresponding to this TierPartition
If one has not been set, returns empty
|
org.apache.kafka.common.TopicPartition |
topicPartition()
The topic-partition corresponding to this TierPartition.
|
long |
totalSize()
Sum the size of all segment spanned by this TierPartitionState.
|
CompletableFuture<Boolean> |
trackMetadataInitialization(int targetLeaderEpoch)
Tracks the completion of tier metadata initialization.
|
void |
updateDir(File dir)
Update the directory reference for the log and indices in this segment.
|
org.apache.kafka.common.TopicPartition topicPartition()
Optional<TopicIdPartition> topicIdPartition()
File dir()
Optional<Long> startOffset() throws IOException
IOException
boolean setTopicId(UUID topicId) throws IOException
topicId
- The topic id to assignIOException
IllegalStateException
- on topic id mismatch, if it had already been set beforelong committedEndOffset() throws IOException
IOException
long endOffset() throws IOException
IOException
OffsetAndEpoch lastLocalMaterializedSrcOffsetAndEpoch()
IOException
int numSegments()
int numSegments(long from, long to)
from
- Start of the range, include segment which contains "from" (inclusive)to
- End of the range, upper bound exclusive offset to include or the end of the log if "to" is past the endIterator<TierObjectMetadata> segments()
Iterator<TierObjectMetadata> segments(long from, long to)
from
- Start of the range, include segment which contains "from" (inclusive)to
- End of the range, upper bound exclusive offset to include or the end of the log if "to" is past the endList<FileTierPartitionState.TierInMemorySegmentMetadata> segmentInMemoryMetadataRange(long from, long to)
from
- Inclusive startOffset positionto
- Inclusive endOffset positionOptional<FileTierPartitionState.TierInMemorySegmentMetadata> previousMetadataBeforeOffset(long targetStartOffset)
targetStartOffset
- target startOffsetkafka.common.FollowerRestorePoint followerRestorePoint(long targetStartOffset)
targetStartOffset
- target startOffsetOptional<TierObjectMetadata> metadata(long targetOffset) throws IOException
targetOffset
- the target offset to lookup the overlapping or next metadata for.IOException
- if disk error encounteredCollection<TierObjectMetadata> fencedSegments()
TierPartitionState.AppendResult append(AbstractTierMetadata tierMetadata, OffsetAndEpoch sourceOffsetAndEpoch)
tierMetadata
- AbstractTierMetadata entry to be appended to the tier partition log.sourceOffsetAndEpoch
- Offset and epoch corresponding to this metadata entryTierPartitionState.RestoreResult restoreState(TierPartitionForceRestore metadata, ByteBuffer targetState, TierPartitionStatus targetStatus, OffsetAndEpoch sourceOffsetAndEpoch)
metadata
- the TierPartitionForceRestore metadata including the coordinates and
metadata about the state to be restored.targetState
- ByteBuffer containing the contents of the TierPartitionState to restoretargetStatus
- the status that the TierPartitionState will be transitioned to upon
successful restorationsourceOffsetAndEpoch
- Offset and epoch corresponding to this metadata entrylong totalSize() throws IOException
IOException
int tierEpoch() throws IOException
IOException
boolean isTieringEnabled()
boolean mayContainTieredData()
boolean maybeOpenChannelOnOffsetTieredException() throws IOException
IOException
boolean setTieringEnabled() throws IOException
IOException
void setTieringDisabled()
boolean flush() throws IOException
IOException
- if the flush operation failedvoid beginCatchup()
void onCatchUpComplete()
CompletableFuture<TierObjectMetadata> materializeUptoOffset(long targetOffset) throws IOException
targetOffset
- the offset awaiting materializationIOException
CompletableFuture<TierObjectMetadata> materializeUptoObjectIdAndRestoreEpoch(long upperBoundEndOffset, UUID targetObjectId, int targetRestoreEpoch) throws IOException
IOException
CompletableFuture<Optional<TierObjectMetadata>> materializeUptoLeaderEpoch(int targetEpoch) throws IOException
targetEpoch
- the leader epoch awaiting materializationIOException
CompletableFuture<Boolean> trackMetadataInitialization(int targetLeaderEpoch) throws IOException
targetLeaderEpoch
- completes the initialization once the tier metadata state reaches equal or greater than targetEpoch.IOException
TierPartitionStatus status()
long materializationLag()
void updateDir(File dir)
dir
- The new directoryvoid delete() throws IOException
IOException
void close() throws IOException
IOException
void closeHandlers() throws IOException
IOException