Package cn.boboweike.carrot.storage
Class ThreadSafePartitionedStorageProvider
- java.lang.Object
-
- cn.boboweike.carrot.storage.ThreadSafePartitionedStorageProvider
-
- All Implemented Interfaces:
PartitionedStorageProvider
public class ThreadSafePartitionedStorageProvider extends Object implements PartitionedStorageProvider
-
-
Field Summary
-
Fields inherited from interface cn.boboweike.carrot.storage.PartitionedStorageProvider
BATCH_SIZE, DEFAULT_NUM_OF_PARTITIONS, PARTITION_HINT_KEY, PARTITION_PREFIX
-
-
Constructor Summary
Constructors Constructor Description ThreadSafePartitionedStorageProvider(PartitionedStorageProvider storageProvider)
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cn.boboweike.carrot.storage.PartitionedStorageProvider
getTaskById
-
-
-
-
Constructor Detail
-
ThreadSafePartitionedStorageProvider
public ThreadSafePartitionedStorageProvider(PartitionedStorageProvider storageProvider)
-
-
Method Detail
-
getName
public String getName()
- Specified by:
getNamein interfacePartitionedStorageProvider
-
getTotalNumOfPartitions
public int getTotalNumOfPartitions()
- Specified by:
getTotalNumOfPartitionsin interfacePartitionedStorageProvider
-
lockByPartition
public boolean lockByPartition(Integer partition, int durationInSeconds, String lockedBy)
- Specified by:
lockByPartitionin interfacePartitionedStorageProvider
-
extendLockByPartition
public boolean extendLockByPartition(Integer partition, int durationInSeconds, String lockedBy)
- Specified by:
extendLockByPartitionin interfacePartitionedStorageProvider
-
unlockByPartition
public boolean unlockByPartition(Integer partition)
- Specified by:
unlockByPartitionin interfacePartitionedStorageProvider
-
setTaskMapper
public void setTaskMapper(TaskMapper taskMapper)
- Specified by:
setTaskMapperin interfacePartitionedStorageProvider
-
setPartitioner
public void setPartitioner(Partitioner partitioner)
- Specified by:
setPartitionerin interfacePartitionedStorageProvider
-
setUpStorageProvider
public void setUpStorageProvider(StorageProviderUtils.DatabaseOptions databaseOptions)
Description copied from interface:PartitionedStorageProviderThis method allows to reinitialize the StorageProvider. It can be used if you are using Flyway or Liquibase to setup your database manually. By default, this method is automatically called on construction of the StorageProvider- Specified by:
setUpStorageProviderin interfacePartitionedStorageProvider- Parameters:
databaseOptions- defines whether to set up the StorageProvider or validate whether the StorageProvider is set up correctly.
-
addTaskStorageOnChangeListener
public void addTaskStorageOnChangeListener(StorageProviderChangeListener listener)
- Specified by:
addTaskStorageOnChangeListenerin interfacePartitionedStorageProvider
-
removeTaskStorageOnChangeListener
public void removeTaskStorageOnChangeListener(StorageProviderChangeListener listener)
- Specified by:
removeTaskStorageOnChangeListenerin interfacePartitionedStorageProvider
-
announceBackgroundTaskServer
public void announceBackgroundTaskServer(BackgroundTaskServerStatus serverStatus)
- Specified by:
announceBackgroundTaskServerin interfacePartitionedStorageProvider
-
signalBackgroundTaskServerAlive
public boolean signalBackgroundTaskServerAlive(BackgroundTaskServerStatus serverStatus)
- Specified by:
signalBackgroundTaskServerAlivein interfacePartitionedStorageProvider
-
signalBackgroundTaskServerStopped
public void signalBackgroundTaskServerStopped(BackgroundTaskServerStatus serverStatus)
- Specified by:
signalBackgroundTaskServerStoppedin interfacePartitionedStorageProvider
-
getBackgroundTaskServers
public List<BackgroundTaskServerStatus> getBackgroundTaskServers()
- Specified by:
getBackgroundTaskServersin interfacePartitionedStorageProvider
-
getLongestRunningBackgroundTaskServerId
public UUID getLongestRunningBackgroundTaskServerId()
- Specified by:
getLongestRunningBackgroundTaskServerIdin interfacePartitionedStorageProvider
-
removeTimedOutBackgroundTaskServers
public int removeTimedOutBackgroundTaskServers(Instant heartbeatOlderThan)
- Specified by:
removeTimedOutBackgroundTaskServersin interfacePartitionedStorageProvider
-
saveMetadata
public void saveMetadata(CarrotMetadata metadata)
- Specified by:
saveMetadatain interfacePartitionedStorageProvider
-
getMetadata
public List<CarrotMetadata> getMetadata(String key)
- Specified by:
getMetadatain interfacePartitionedStorageProvider
-
getMetadata
public CarrotMetadata getMetadata(String name, String owner)
- Specified by:
getMetadatain interfacePartitionedStorageProvider
-
deleteMetadata
public void deleteMetadata(String name)
- Specified by:
deleteMetadatain interfacePartitionedStorageProvider
-
save
public Task save(Task task)
- Specified by:
savein interfacePartitionedStorageProvider
-
saveByPartition
public Task saveByPartition(Task task, Integer partition)
- Specified by:
saveByPartitionin interfacePartitionedStorageProvider
-
deletePermanentlyByPartition
public int deletePermanentlyByPartition(UUID id, Integer partition)
- Specified by:
deletePermanentlyByPartitionin interfacePartitionedStorageProvider
-
getTaskById
public Task getTaskById(UUID id)
- Specified by:
getTaskByIdin interfacePartitionedStorageProvider
-
save
public List<Task> save(List<Task> tasks)
- Specified by:
savein interfacePartitionedStorageProvider
-
saveByPartition
public List<Task> saveByPartition(List<Task> tasks, Integer partition)
- Specified by:
saveByPartitionin interfacePartitionedStorageProvider
-
getTasksByPartition
public List<Task> getTasksByPartition(StateName state, Instant updatedBefore, PageRequest pageRequest, Integer partition)
- Specified by:
getTasksByPartitionin interfacePartitionedStorageProvider
-
getScheduledTasksByPartition
public List<Task> getScheduledTasksByPartition(Instant scheduledBefore, PageRequest pageRequest, Integer partition)
- Specified by:
getScheduledTasksByPartitionin interfacePartitionedStorageProvider
-
getTasksByPartition
public List<Task> getTasksByPartition(StateName state, PageRequest pageRequest, Integer partition)
- Specified by:
getTasksByPartitionin interfacePartitionedStorageProvider
-
getTaskPageByPartition
public Page<Task> getTaskPageByPartition(StateName state, PageRequest pageRequest, Integer partition)
- Specified by:
getTaskPageByPartitionin interfacePartitionedStorageProvider
-
deleteTasksPermanentlyByPartition
public int deleteTasksPermanentlyByPartition(StateName state, Instant updatedBefore, Integer partition)
- Specified by:
deleteTasksPermanentlyByPartitionin interfacePartitionedStorageProvider
-
getDistinctTaskSignatures
public Set<String> getDistinctTaskSignatures(StateName... states)
- Specified by:
getDistinctTaskSignaturesin interfacePartitionedStorageProvider
-
existsByPartition
public boolean existsByPartition(TaskDetails taskDetails, Integer partition, StateName... states)
- Specified by:
existsByPartitionin interfacePartitionedStorageProvider
-
recurringTaskExistsByPartition
public boolean recurringTaskExistsByPartition(String recurringTaskId, Integer partition, StateName... states)
- Specified by:
recurringTaskExistsByPartitionin interfacePartitionedStorageProvider
-
saveRecurringTask
public RecurringTask saveRecurringTask(RecurringTask recurringTask)
- Specified by:
saveRecurringTaskin interfacePartitionedStorageProvider
-
getRecurringTasksByPartition
public List<RecurringTask> getRecurringTasksByPartition(Integer partition)
- Specified by:
getRecurringTasksByPartitionin interfacePartitionedStorageProvider
-
getRecurringTasks
public List<RecurringTask> getRecurringTasks()
- Specified by:
getRecurringTasksin interfacePartitionedStorageProvider
-
countRecurringTasksByPartition
public long countRecurringTasksByPartition(Integer partition)
- Specified by:
countRecurringTasksByPartitionin interfacePartitionedStorageProvider
-
deleteRecurringTask
public int deleteRecurringTask(String id)
- Specified by:
deleteRecurringTaskin interfacePartitionedStorageProvider
-
getTaskStatsData
public TaskStatsData getTaskStatsData()
- Specified by:
getTaskStatsDatain interfacePartitionedStorageProvider
-
publishTotalAmountOfSucceededTasks
public void publishTotalAmountOfSucceededTasks(int amount)
- Specified by:
publishTotalAmountOfSucceededTasksin interfacePartitionedStorageProvider
-
close
public void close()
- Specified by:
closein interfacePartitionedStorageProvider
-
getStorageProvider
public PartitionedStorageProvider getStorageProvider()
-
-