集群 集群锁 com.fr.scheduler.tool.FineSchedulerPropertiesBuilder properties.put("com.fr.third.v2.org.quartz.jobStore.lockHandler.class", "com.fr.scheduler.cluster.FineSemaphore"); public interface Semaphore { /* * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * Interface. * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /** * Grants a lock on the identified resource to the calling thread (blocking * until it is available). ** @param conn Database connection used to establish lock. Can be null if * <code>{@link #requiresConnection()}</code> returns false. ** @return true if the lock was obtained. */ boolean obtainLock(Connection conn, String lockName) throws LockException; /** * Release the lock on the identified resource if it is held by the calling * thread. */ void releaseLock(String lockName) throws LockException; /** * Whether this Semaphore implementation requires a database connection for * its lock management operations. ** @see #obtainLock(Connection, String) * @see #releaseLock(String) */ boolean requiresConnection(); } 直接通过 Quartz 提供的 Semaphore 接口,进行集群锁的锁定。