Class BaseDbLockHandlerImpl

    • Field Detail

      • KEEPALIVE_SECONDS

        protected static final int KEEPALIVE_SECONDS
        Interval in seconds which nodes should update the db_lock row
        See Also:
        Constant Field Values
      • VALID_SECONDS

        protected static final int VALID_SECONDS
        (seconds since the last keepalive) - this constant is the interval to sleep until the next check (when there was a valid row in db_lock)
        See Also:
        Constant Field Values
    • Constructor Detail

      • BaseDbLockHandlerImpl

        public BaseDbLockHandlerImpl​(JdbcTemplate jdbcTemplate)
    • Method Detail

      • lock

        public final void lock​(String hostId,
                               DbLock dbLock)
        Description copied from interface: DbLockHandler
        Locks the database, by either inserting or updating the existing row in db_lock table, and schedules a timer to update the table every few seconds
        Specified by:
        lock in interface DbLockHandler
      • sleepUntilTryingAgain

        public final void sleepUntilTryingAgain​(DbLock dbLock)
        Description copied from interface: DbLockHandler
        Sleeps for a few seconds before attempting to check again if the db is locked
        Specified by:
        sleepUntilTryingAgain in interface DbLockHandler
      • throwAlreadyLocked

        public final void throwAlreadyLocked​(DbLock dbLock)
        Description copied from interface: DbLockHandler
        Throws an appropriate error indicating the current db is already locked
        Specified by:
        throwAlreadyLocked in interface DbLockHandler
      • create

        protected abstract void create​(String hostId)
      • doRead

        protected abstract DbLock doRead()
      • keepalive

        protected abstract void keepalive()
      • shutdown

        protected void shutdown()
      • update

        protected abstract boolean update​(String hostId,
                                          int version)