Interface MetadataStorageActionHandler<EntryType,​StatusType,​LogType,​LockType>


  • public interface MetadataStorageActionHandler<EntryType,​StatusType,​LogType,​LockType>
    • 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 id
        timestamp - timestamp this entry was created
        dataSource - datasource associated with this entry
        entry - object representing this entry
        active - active or inactive flag
        status - status object associated wit this object, can be null
        type - entry type
        groupId - 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 id
        active - active
        status - 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
      • addLock

        boolean addLock​(String entryId,
                        LockType lock)
        Add a lock to the given entry
        Parameters:
        entryId - entry id
        lock - 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 id
        oldLockId - lock to be replaced
        newLock - 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 id
        log - 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