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.
|
java.io.File |
dir()
The directory where the TierPartition is stored on disk.
|
long |
endOffset()
Return the uncommitted end offset spanned by the TierPartitionState.
|
java.util.Collection<TierObjectMetadata> |
fencedSegments() |
void |
flush()
flush data contained in this TierPartitionState to disk.
|
java.util.Optional<FileTierPartitionState.TierInMemorySegmentMetadata> |
immediatePreviousInMemoryMetadata(long targetStartOffset)
Get the in-memory metadata for the immediate previous segment (even beyond retention) to target startOffset
|
boolean |
isTieringEnabled() |
OffsetAndEpoch |
lastLocalMaterializedSrcOffsetAndEpoch()
Return the last materialized source offset and epoch
|
long |
materializationLag()
Return the current tier materialization lag.
|
java.util.concurrent.Future<TierObjectMetadata> |
materializeUpto(long targetOffset)
Sets up a listener for this tier partition state for use by the replica fetcher.
|
java.util.concurrent.CompletableFuture<java.util.Optional<TierObjectMetadata>> |
materializeUptoEpoch(int targetEpoch)
Sets up a listener for this tier partition state.
|
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.
|
java.util.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.
|
TierPartitionState.RestoreResult |
restoreState(TierPartitionForceRestore metadata,
java.nio.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.
|
java.util.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).
|
org.apache.kafka.common.utils.CloseableIterator<TierObjectMetadata> |
segments()
Get an iterator for all readable tiered segments.
|
org.apache.kafka.common.utils.CloseableIterator<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(java.util.UUID topicId)
Sets the TopicIdPartition for this TierPartitionState.
|
java.util.Optional<java.lang.Long> |
startOffset()
Determine start offset spanned by the TierPartitionState.
|
TierPartitionStatus |
status()
Return the current status of the TierPartitionState.
|
int |
tierEpoch()
Return the current tierEpoch.
|
java.util.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.
|
void |
trackMetadataInitialization(int targetEpoch,
java.util.function.Consumer<java.lang.Boolean> callback)
Tracks the completion of tier metadata initialization.
|
void |
updateDir(java.io.File dir)
Update the directory reference for the log and indices in this segment.
|
org.apache.kafka.common.TopicPartition topicPartition()
java.util.Optional<TopicIdPartition> topicIdPartition()
java.io.File dir()
java.util.Optional<java.lang.Long> startOffset() throws java.io.IOException
java.io.IOException
boolean setTopicId(java.util.UUID topicId) throws java.io.IOException
topicId
- The topic id to assignjava.io.IOException
java.lang.IllegalStateException
- on topic id mismatch, if it had already been set beforelong committedEndOffset() throws java.io.IOException
java.io.IOException
long endOffset() throws java.io.IOException
java.io.IOException
OffsetAndEpoch lastLocalMaterializedSrcOffsetAndEpoch()
java.io.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 endorg.apache.kafka.common.utils.CloseableIterator<TierObjectMetadata> segments()
org.apache.kafka.common.utils.CloseableIterator<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 endjava.util.List<FileTierPartitionState.TierInMemorySegmentMetadata> segmentInMemoryMetadataRange(long from, long to)
from
- Inclusive startOffset positionto
- Inclusive endOffset positionjava.util.Optional<FileTierPartitionState.TierInMemorySegmentMetadata> immediatePreviousInMemoryMetadata(long targetStartOffset)
targetStartOffset
- target startOffsetjava.util.Optional<TierObjectMetadata> metadata(long targetOffset) throws java.io.IOException
targetOffset
- the target offset to lookup the overlapping or next metadata for.java.io.IOException
- if disk error encounteredjava.util.Collection<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, java.nio.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 java.io.IOException
java.io.IOException
int tierEpoch() throws java.io.IOException
java.io.IOException
boolean isTieringEnabled()
boolean mayContainTieredData()
boolean maybeOpenChannelOnOffsetTieredException() throws java.io.IOException
java.io.IOException
boolean setTieringEnabled() throws java.io.IOException
java.io.IOException
void setTieringDisabled()
void flush() throws java.io.IOException
java.io.IOException
void beginCatchup()
void onCatchUpComplete()
java.util.concurrent.Future<TierObjectMetadata> materializeUpto(long targetOffset) throws java.io.IOException
targetOffset
- the offset awaiting materializationjava.io.IOException
java.util.concurrent.CompletableFuture<java.util.Optional<TierObjectMetadata>> materializeUptoEpoch(int targetEpoch) throws java.io.IOException
targetEpoch
- the leader epoch awaiting materializationjava.io.IOException
void trackMetadataInitialization(int targetEpoch, java.util.function.Consumer<java.lang.Boolean> callback) throws java.lang.IllegalStateException
targetEpoch
- completes the initialization once the tier metadata state reaches equal or greater than targetEpoch.callback
- callback to call on completion of initialization.java.lang.IllegalStateException
TierPartitionStatus status()
long materializationLag()
void updateDir(java.io.File dir)
dir
- The new directoryvoid delete() throws java.io.IOException
java.io.IOException
void close() throws java.io.IOException
java.io.IOException
void closeHandlers() throws java.io.IOException
java.io.IOException