/** * @return true if the last registration update was done less than lifetime seconds ago. */ public boolean isAlive() { return isAlive(0); }
@Override public void run() { try { Collection<Registration> allRegs = new ArrayList<>(); try { lock.readLock().lock(); allRegs.addAll(regsByEp.values()); } finally { lock.readLock().unlock(); } for (Registration reg : allRegs) { if (!reg.isAlive()) { // force de-registration Deregistration removedRegistration = removeRegistration(reg.getId()); expirationListener.registrationExpired(removedRegistration.getRegistration(), removedRegistration.getObservations()); } } } catch (Exception e) { LOG.warn("Unexpected Exception while registration cleaning", e); } } }
@Override public void run() { try (Jedis j = pool.getResource()) { Set<byte[]> endpointsExpired = j.zrangeByScore(EXP_EP, Double.NEGATIVE_INFINITY, System.currentTimeMillis(), 0, cleanLimit); for (byte[] endpoint : endpointsExpired) { Registration r = deserializeReg(j.get(toEndpointKey(endpoint))); if (!r.isAlive(gracePeriod)) { Deregistration dereg = removeRegistration(j, r.getId(), true); if (dereg != null) expirationListener.registrationExpired(dereg.getRegistration(), dereg.getObservations()); } } } catch (Exception e) { LOG.warn("Unexpected Exception while registration cleaning", e); } } }
@Override public void run() { try (Jedis j = pool.getResource()) { Set<byte[]> endpointsExpired = j.zrangeByScore(EXP_EP, Double.NEGATIVE_INFINITY, System.currentTimeMillis(), 0, cleanLimit); for (byte[] endpoint : endpointsExpired) { Registration r = deserializeReg(j.get(toEndpointKey(endpoint))); if (!r.isAlive(gracePeriod)) { Deregistration dereg = removeRegistration(j, r.getId(), true); if (dereg != null) expirationListener.registrationExpired(dereg.getRegistration(), dereg.getObservations()); } } } catch (Exception e) { LOG.warn("Unexpected Exception while registration cleaning", e); } } }
if (!removeOnlyIfNotAlive || !r.isAlive(gracePeriod)) { long nbRemoved = j.del(toRegIdKey(r.getId())); if (nbRemoved > 0) {
if (!removeOnlyIfNotAlive || !r.isAlive(gracePeriod)) { long nbRemoved = j.del(toRegIdKey(r.getId())); if (nbRemoved > 0) {