static ScheduledLeaseLock of(ScheduledExecutorService scheduledExecutorService, ArtemisExecutor executor, String lockName, LeaseLock lock, long renewPeriodMillis, IOCriticalErrorListener ioCriticalErrorListener) { return new ActiveMQScheduledLeaseLock(scheduledExecutorService, executor, lockName, lock, renewPeriodMillis, ioCriticalErrorListener); }
@Override public synchronized void stop() { if (!isStarted()) { return; } super.stop(); }
@Override public void run() { final long lastRenewStart = this.lastLockRenewStart; final long renewStart = System.nanoTime(); try { if (!this.lock.renew()) { ioCriticalErrorListener.onIOException(new IllegalStateException(lockName + " lock can't be renewed"), "Critical error while on " + lockName + " renew", null); } } catch (Throwable t) { ioCriticalErrorListener.onIOException(t, "Critical error while on " + lockName + " renew", null); throw t; } //logic to detect slowness of DB and/or the scheduled executor service detectAndReportRenewSlowness(lockName, lastRenewStart, renewStart, renewPeriodMillis, lock.expirationMillis()); this.lastLockRenewStart = renewStart; }
@Override public synchronized void start() { if (isStarted()) { return; } this.lastLockRenewStart = System.nanoTime(); super.start(); }