public class StateManager extends Object
Modifier and Type | Class and Description |
---|---|
static class |
StateManager.LifecycleManagerVersionException |
Modifier and Type | Field and Description |
---|---|
static int |
LIFECYCLE_MANAGER_STATE_CURRENT_VERSION |
Constructor and Description |
---|
StateManager() |
Modifier and Type | Method and Description |
---|---|
static String |
convertToDateKey(Long timeInMs)
Utility method to convert the time in milliseconds to date in a common format defined by LifecycleManager.DATE_PATTERN
|
static void |
deleteAllStateFiles(StateManagerConfig config,
ThreadPoolExecutor executor)
Delete all the state files.
|
static LifecycleManagerState |
deserializeState(ByteBuffer buf)
Deserializes a ByteBuffer into LifecycleManagerState instance
|
static String |
generateNextObjectsListName(String name)
Convenience method to create the name for the next backup objects list, given the current list's name.
|
static BackupObjectsMetadata |
getDeletionList(StateManagerConfig config,
String date,
String namePrefix)
Gets the deletion list for a given date and namePrefix.
|
static LifecycleManagerState |
getState(StateManagerConfig config)
Gets the Lifecycle Manager state from object store.
|
static void |
loadDeletionList(StateManagerConfig config,
String date,
String namePrefix,
Map<String,Map<TopicIdPartition,List<LifecycleManager.BlobMetadata>>> dateToDeletableBlobs)
Get the serialized buffer containing list of blobs to be deleted on a given date and load the buffer in an in-memory
structure
|
static Map<String,String> |
loadLatestDeletionListNamesFrom(Date currentDate,
LifecycleManagerState state)
Loads the names of the latest deletion lists for current and future dates.
|
static void |
putBackedUpObjectsListBufToObjectStore(StateManagerConfig config,
ByteBuffer buf,
String date,
String namePrefix)
Put the backup objects list buffer at the object store
|
static void |
putStateBufToObjectStore(StateManagerConfig config,
ByteBuffer buf)
Puts the lifecycle manager state buffer at the object store
|
static ByteBuffer |
serializeBackupObjectsList(Map<TopicIdPartition,List<LifecycleManager.BlobMetadata>> tpIdToBlobs)
Serialize the backup objects list
|
static ByteBuffer |
serializeState(Long currTimeMs,
long[] endOffsets,
Map<NameAndId,Integer> retentionConfigs,
Map<NameAndId,LifecycleManager.ReductionInRetention> retentionChanges,
Map<String,String> dateToLatestListNames)
Serializes the lifecycle manager state data
|
public static final int LIFECYCLE_MANAGER_STATE_CURRENT_VERSION
public static LifecycleManagerState getState(StateManagerConfig config) throws InterruptedException, IOException, IllegalArgumentException, StateManager.LifecycleManagerVersionException
config
- StateManagerConfig required to access the object store and determine blob keyIOException
- if an IOException is encounteredIllegalArgumentException
- if the length of the serialized buffer contained in the first four bytes is negativeInterruptedException
StateManager.LifecycleManagerVersionException
public static void deleteAllStateFiles(StateManagerConfig config, ThreadPoolExecutor executor) throws InterruptedException
config
- instance of StateManagerConfigInterruptedException
public static LifecycleManagerState deserializeState(ByteBuffer buf) throws IOException
buf
- serialized ByteBufferIOException
public static void loadDeletionList(StateManagerConfig config, String date, String namePrefix, Map<String,Map<TopicIdPartition,List<LifecycleManager.BlobMetadata>>> dateToDeletableBlobs) throws InterruptedException, IOException
config
- StateManagerConfig required to access the object store and determine blob keydate
- date for which we need to load the list of blobs to be deletednamePrefix
- namePrefix of the blob containing the list of blobs to be deleted. If the blob name is
00000001.dateToDeletableBlobs
- date and TopicIdPartition sorted mapping of the list of blobs to be deletedInterruptedException
IOException
public static String generateNextObjectsListName(String name)
name
- name of the current backup object listpublic static BackupObjectsMetadata getDeletionList(StateManagerConfig config, String date, String namePrefix) throws InterruptedException, IOException, IllegalArgumentException, StateManager.LifecycleManagerVersionException
config
- StateManagerConfig required to access the object store and determine blob keydate
- for which we need to get the datanamePrefix
- of the blob to get. If the blob name is 00000001.IllegalArgumentException
- if the length of the serialized buffer contained in the first four bytes is negativeInterruptedException
IOException
StateManager.LifecycleManagerVersionException
public static ByteBuffer serializeState(Long currTimeMs, long[] endOffsets, Map<NameAndId,Integer> retentionConfigs, Map<NameAndId,LifecycleManager.ReductionInRetention> retentionChanges, Map<String,String> dateToLatestListNames)
currTimeMs
- time of the last run of lifecycle managerendOffsets
- endOffsets an array representing the tier partition offsetsretentionConfigs
- retentionConfigs mapping of topic name / id to the current retentionretentionChanges
- retentionChanges mapping of topic to any topic retention changesdateToLatestListNames
- dateToLatestListNames mapping between the date to the latest file namepublic static ByteBuffer serializeBackupObjectsList(Map<TopicIdPartition,List<LifecycleManager.BlobMetadata>> tpIdToBlobs)
tpIdToBlobs
- mapping of topic UUID to list of metadata information of backed up blobspublic static void putStateBufToObjectStore(StateManagerConfig config, ByteBuffer buf) throws InterruptedException
config
- StateManagerConfig required to access the object store and determine blob keybuf
- ByteBuffer containing the serialized lifecycle manager stateInterruptedException
public static void putBackedUpObjectsListBufToObjectStore(StateManagerConfig config, ByteBuffer buf, String date, String namePrefix) throws InterruptedException
config
- StateManagerConfig required to access the object store and determine blob keybuf
- ByteBuffer containing the serialized backup objects listdate
- String used to create the blob keynamePrefix
- String used to create the blob nameInterruptedException
public static String convertToDateKey(Long timeInMs)
public static Map<String,String> loadLatestDeletionListNamesFrom(Date currentDate, LifecycleManagerState state) throws ParseException
state
- LifecycleManagerStatecurrentDate
- date from which the latest list names are to be loadedParseException