Class BlobSnapshotManager
java.lang.Object
com.linkedin.davinci.blobtransfer.BlobSnapshotManager
This class will manage the snapshot creation, for batch store and hybrid store.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
-
Constructor Summary
ConstructorsConstructorDescriptionBlobSnapshotManager
(StorageEngineRepository storageEngineRepository, StorageMetadataService storageMetadataService) The constructor for the BlobSnapshotManager, with default max concurrent users and snapshot retention timeBlobSnapshotManager
(StorageEngineRepository storageEngineRepository, StorageMetadataService storageMetadataService, int maxConcurrentUsers, int snapshotRetentionTimeInMin, BlobTransferUtils.BlobTransferTableFormat transferTableFormat, int snapshotCleanupIntervalInMins) Constructor for the BlobSnapshotManager -
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanupOutOfRetentionSnapshot
(String topicName, int partitionId) A regular cleanup task to clean up the snapshot folder which is out of retention time.void
cleanupSnapshot
(String kafkaVersionTopic, int partitionId) Cleanup the snapshot for a particular partitionvoid
createSnapshot
(String kafkaVersionTopic, int partitionId) Create a snapshot for a particular partitionvoid
decreaseConcurrentUserCount
(BlobTransferPayload blobTransferRequest) Decrease the count of hosts using the snapshotGet the current snapshot format, which is a config value.protected int
getConcurrentSnapshotUsers
(String topicName, int partitionId) getTransferMetadata
(BlobTransferPayload payload, AtomicBoolean successCountedAsActiveCurrentUser) Get the transfer metadata for a particular payload 1.getTransferredSnapshotMetadata
(String topicName, int partitionId) Get the snapshot metadata for a particular topic and partitionprepareMetadata
(BlobTransferPayload blobTransferRequest) Prepare the metadata for a blob transfer requestvoid
removeTrackingValues
(String topicName, int partitionId) Remove tracking values for a topic-partition when the snapshot is cleaned upvoid
shutdown()
-
Field Details
-
DEFAULT_MAX_CONCURRENT_USERS
public static final int DEFAULT_MAX_CONCURRENT_USERS- See Also:
-
DEFAULT_SNAPSHOT_CLEANUP_INTERVAL_IN_MINS
public static final int DEFAULT_SNAPSHOT_CLEANUP_INTERVAL_IN_MINS- See Also:
-
-
Constructor Details
-
BlobSnapshotManager
public BlobSnapshotManager(StorageEngineRepository storageEngineRepository, StorageMetadataService storageMetadataService, int maxConcurrentUsers, int snapshotRetentionTimeInMin, BlobTransferUtils.BlobTransferTableFormat transferTableFormat, int snapshotCleanupIntervalInMins) Constructor for the BlobSnapshotManager -
BlobSnapshotManager
public BlobSnapshotManager(StorageEngineRepository storageEngineRepository, StorageMetadataService storageMetadataService) The constructor for the BlobSnapshotManager, with default max concurrent users and snapshot retention time
-
-
Method Details
-
getTransferMetadata
public BlobTransferPartitionMetadata getTransferMetadata(BlobTransferPayload payload, AtomicBoolean successCountedAsActiveCurrentUser) throws VeniceException Get the transfer metadata for a particular payload 1. throttle the request if many concurrent users. 2. check snapshot staleness 2.1. if stale: 2.1.1. if it does not have active users: recreate the snapshot and metadata, then return the metadata 2.1.2. if it has active users: no need to recreate the snapshot, throw an exception to let the client move to next candidate. 2.2. if not stale, directly return the metadata- Parameters:
payload
- the blob transfer payloadsuccessCountedAsActiveCurrentUser
- Indicates whether this request has been successfully counted as an active user. Typically, we should increment the active concurrent user count at the beginning of receiving request on the server handler side. However, since we need to check the count of active users before recreating a snapshot for ensuring no active users are present, we move the increment logic to here. We also need to decrement the active user count when the request is completed or fails at the server side handler. This flag (successCountedCurrentUser) lets us know if this request was counted as an active user, so we can accurately decrement the count later.- Returns:
- the need transfer metadata to client
- Throws:
VeniceException
-
decreaseConcurrentUserCount
Decrease the count of hosts using the snapshot -
getConcurrentSnapshotUsers
-
createSnapshot
Create a snapshot for a particular partition -
cleanupSnapshot
Cleanup the snapshot for a particular partition- Parameters:
kafkaVersionTopic
- the topic namepartitionId
- the partition id
-
getTransferredSnapshotMetadata
public BlobTransferPartitionMetadata getTransferredSnapshotMetadata(String topicName, int partitionId) Get the snapshot metadata for a particular topic and partition- Parameters:
topicName
- the topic namepartitionId
- the partition id- Returns:
- the snapshot metadata
-
prepareMetadata
Prepare the metadata for a blob transfer request- Parameters:
blobTransferRequest
- the blob transfer request- Returns:
- the metadata for the blob transfer request
-
getBlobTransferTableFormat
Get the current snapshot format, which is a config value.- Returns:
- the transfer table format, BLOCK_BASED_TABLE or PLAIN_TABLE.
-
removeTrackingValues
Remove tracking values for a topic-partition when the snapshot is cleaned up -
cleanupOutOfRetentionSnapshot
A regular cleanup task to clean up the snapshot folder which is out of retention time. -
shutdown
public void shutdown()
-