Package org.apache.druid.metadata
Interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
-
public interface MetadataStorageActionHandler<EntryType,StatusType,LogType,LockType>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
addLock(String entryId, LockType lock)
Add a lock to the given entryboolean
addLog(String entryId, LogType log)
Add a log to the entry with the given id.com.google.common.base.Optional<EntryType>
getEntry(String entryId)
Retrieves the entry with the given id.Long
getLockId(String entryId, LockType lock)
Returns the lock id for the given entry and the lock.Map<Long,LockType>
getLocks(String entryId)
Returns the locks for the given entryList<LogType>
getLogs(String entryId)
Returns the logs for the entry with the given id.com.google.common.base.Optional<StatusType>
getStatus(String entryId)
Retrieve the status for the entry with the given id.TaskInfo<EntryType,StatusType>
getTaskInfo(String entryId)
List<TaskInfo<EntryType,StatusType>>
getTaskInfos(Map<TaskLookup.TaskLookupType,TaskLookup> taskLookups, String datasource)
Returns a list ofTaskInfo
from metadata store that matches to the given filters.default List<TaskInfo<EntryType,StatusType>>
getTaskInfos(TaskLookup taskLookup, String datasource)
List<TaskInfo<TaskIdentifier,StatusType>>
getTaskStatusList(Map<TaskLookup.TaskLookupType,TaskLookup> taskLookups, String datasource)
Returns the statuses of the specified tasks.void
insert(@NotNull String id, @NotNull org.joda.time.DateTime timestamp, @NotNull String dataSource, EntryType entry, boolean active, StatusType status, @NotNull String type, @NotNull String groupId)
Creates a new entry.void
populateTaskTypeAndGroupIdAsync()
Utility to migrate existing tasks to the new schema by populating type and groupId asynchronouslyvoid
removeLock(long lockId)
Remove the lock with the given lock id.void
removeTasksOlderThan(long timestamp)
Remove the tasks created older than the given timestamp.boolean
replaceLock(String entryId, long oldLockId, LockType newLock)
Replace an existing lock with a new lock.boolean
setStatus(String entryId, boolean active, StatusType status)
Sets or updates the status for any active entry with the given id.
-
-
-
Method Detail
-
insert
void insert(@NotNull @NotNull String id, @NotNull @NotNull org.joda.time.DateTime timestamp, @NotNull @NotNull String dataSource, @NotNull EntryType entry, boolean active, @Nullable StatusType status, @NotNull @NotNull String type, @NotNull @NotNull String groupId) throws EntryExistsException
Creates a new entry.- Parameters:
id
- entry idtimestamp
- timestamp this entry was createddataSource
- datasource associated with this entryentry
- object representing this entryactive
- active or inactive flagstatus
- status object associated wit this object, can be nulltype
- entry typegroupId
- entry group id- Throws:
EntryExistsException
-
setStatus
boolean setStatus(String entryId, boolean active, StatusType status)
Sets or updates the status for any active entry with the given id. Once an entry has been set inactive, its status cannot be updated anymore.- Parameters:
entryId
- entry idactive
- activestatus
- status- Returns:
- true if the status was updated, false if the entry did not exist of if the entry was inactive
-
getEntry
com.google.common.base.Optional<EntryType> getEntry(String entryId)
Retrieves the entry with the given id.- Parameters:
entryId
- entry id- Returns:
- optional entry, absent if the given id does not exist
-
getStatus
com.google.common.base.Optional<StatusType> getStatus(String entryId)
Retrieve the status for the entry with the given id.- Parameters:
entryId
- entry id- Returns:
- optional status, absent if entry does not exist or status is not set
-
getTaskInfo
@Nullable TaskInfo<EntryType,StatusType> getTaskInfo(String entryId)
-
getTaskInfos
List<TaskInfo<EntryType,StatusType>> getTaskInfos(Map<TaskLookup.TaskLookupType,TaskLookup> taskLookups, @Nullable String datasource)
Returns a list ofTaskInfo
from metadata store that matches to the given filters. IftaskLookups
includesTaskLookup.TaskLookupType.ACTIVE
, it returns all active tasks in the metadata store. IftaskLookups
includesTaskLookup.TaskLookupType.COMPLETE
, it returns all complete tasks in the metadata store. For complete tasks, additional filters inCompleteTaskLookup
can be applied. All lookups should be processed atomically if there are more than one lookup is given.- Parameters:
taskLookups
- task lookup type and filters.datasource
- datasource filter
-
getTaskStatusList
List<TaskInfo<TaskIdentifier,StatusType>> getTaskStatusList(Map<TaskLookup.TaskLookupType,TaskLookup> taskLookups, @Nullable String datasource)
Returns the statuses of the specified tasks. IftaskLookups
includesTaskLookup.TaskLookupType.ACTIVE
, it returns all active tasks in the metadata store. IftaskLookups
includesTaskLookup.TaskLookupType.COMPLETE
, it returns all complete tasks in the metadata store. For complete tasks, additional filters inCompleteTaskLookup
can be applied. All lookups should be processed atomically if more than one lookup is given.- Parameters:
taskLookups
- task lookup type and filters.datasource
- datasource filter
-
getTaskInfos
default List<TaskInfo<EntryType,StatusType>> getTaskInfos(TaskLookup taskLookup, @Nullable String datasource)
-
addLock
boolean addLock(String entryId, LockType lock)
Add a lock to the given entry- Parameters:
entryId
- entry idlock
- lock to add- Returns:
- true if the lock was added
-
replaceLock
boolean replaceLock(String entryId, long oldLockId, LockType newLock)
Replace an existing lock with a new lock.- Parameters:
entryId
- entry idoldLockId
- lock to be replacednewLock
- lock to be added- Returns:
- true if the lock is replaced
-
removeLock
void removeLock(long lockId)
Remove the lock with the given lock id.- Parameters:
lockId
- lock id
-
removeTasksOlderThan
void removeTasksOlderThan(long timestamp)
Remove the tasks created older than the given timestamp.- Parameters:
timestamp
- timestamp in milliseconds
-
addLog
boolean addLog(String entryId, LogType log)
Add a log to the entry with the given id.- Parameters:
entryId
- entry idlog
- log to add- Returns:
- true if the log was added
-
getLogs
List<LogType> getLogs(String entryId)
Returns the logs for the entry with the given id.- Parameters:
entryId
- entry id- Returns:
- list of logs
-
getLocks
Map<Long,LockType> getLocks(String entryId)
Returns the locks for the given entry- Parameters:
entryId
- entry id- Returns:
- map of lockId to lock
-
getLockId
@Nullable Long getLockId(String entryId, LockType lock)
Returns the lock id for the given entry and the lock.- Returns:
- lock id if found. Otherwise null.
-
populateTaskTypeAndGroupIdAsync
void populateTaskTypeAndGroupIdAsync()
Utility to migrate existing tasks to the new schema by populating type and groupId asynchronously
-
-