@Override public void onMessage(CharSequence channel, String id) { redisson.getAtomicLong(workersCounterName + ":" + id).getAndAdd(workers); redisson.getSemaphore(workersSemaphoreName + ":" + id).release(); } });
@Override public void onMessage(CharSequence channel, String id) { redisson.getAtomicLong(workersCounterName + ":" + id).getAndAdd(workers); redisson.getSemaphore(workersSemaphoreName + ":" + id).release(); } });
@Override public int countActiveWorkers() { String id = generateRequestId(); int subscribers = (int) workersTopic.publish(id); if (subscribers == 0) { return 0; } RSemaphore semaphore = redisson.getSemaphore(workersSemaphoreName + ":" + id); try { semaphore.tryAcquire(subscribers, 10, TimeUnit.MINUTES); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } RAtomicLong atomicLong = redisson.getAtomicLong(workersCounterName + ":" + id); long result = atomicLong.get(); redisson.getKeys().delete(semaphore, atomicLong); return (int) result; }
@Override public int countActiveWorkers() { String id = generateRequestId(); int subscribers = (int) workersTopic.publish(id); if (subscribers == 0) { return 0; } RSemaphore semaphore = redisson.getSemaphore(workersSemaphoreName + ":" + id); try { semaphore.tryAcquire(subscribers, 10, TimeUnit.MINUTES); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } RAtomicLong atomicLong = redisson.getAtomicLong(workersCounterName + ":" + id); long result = atomicLong.get(); redisson.getKeys().delete(semaphore, atomicLong); return (int) result; }
@Override public void onMessage(CharSequence channel, String id) { redisson.getAtomicLong(workersCounterName + ":" + id).getAndAdd(workers); redisson.getSemaphore(workersSemaphoreName + ":" + id).release(); } });
@Override public int countActiveWorkers() { String id = generateRequestId(); int subscribers = (int) workersTopic.publish(id); if (subscribers == 0) { return 0; } RSemaphore semaphore = redisson.getSemaphore(workersSemaphoreName + ":" + id); try { semaphore.tryAcquire(subscribers, 10, TimeUnit.MINUTES); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } RAtomicLong atomicLong = redisson.getAtomicLong(workersCounterName + ":" + id); long result = atomicLong.get(); redisson.getKeys().delete(semaphore, atomicLong); return (int) result; }