@Override public void restore(BackupInput input) { parties = input.readObject(); barrierId = input.readLong(); broken = input.readBoolean(); this.waiters = Maps.newLinkedHashMap(); Map<SessionId, Long> waiters = input.readObject(); waiters.forEach((sessionId, timeout) -> { this.waiters.put(sessionId, new Waiter(timeout, timeout == 0 ? null : getScheduler().schedule(Duration.ofMillis(timeout - getWallClock().getTime().unixTimestamp()), () -> timeout(barrierId)))); }); }
@Override public void restore(BackupInput input) { if (input.readBoolean()) { lock = input.readObject(); } queue = input.readObject(); // After the snapshot is installed, we need to cancel any existing timers and schedule new ones based on the // state provided by the snapshot. timers.values().forEach(Scheduled::cancel); timers.clear(); for (LockHolder holder : queue) { if (holder.expire > 0) { timers.put(holder.index, getScheduler().schedule(Duration.ofMillis(holder.expire - getWallClock().getTime().unixTimestamp()), () -> { timers.remove(holder.index); queue.remove(holder); Session session = getSession(holder.session); if (session != null && session.getState().active()) { getSession(holder.session).accept(service -> service.failed(holder.id)); } })); } } }
@Override public void restore(BackupInput input) { parties = input.readObject(); barrierId = input.readLong(); broken = input.readBoolean(); this.waiters = Maps.newLinkedHashMap(); Map<SessionId, Long> waiters = input.readObject(); waiters.forEach((sessionId, timeout) -> { this.waiters.put(sessionId, new Waiter(timeout, timeout == 0 ? null : getScheduler().schedule(Duration.ofMillis(timeout - getWallClock().getTime().unixTimestamp()), () -> timeout(barrierId)))); }); }
@Override public void restore(BackupInput input) { if (input.readBoolean()) { lock = input.readObject(); } queue = input.readObject(); // After the snapshot is installed, we need to cancel any existing timers and schedule new ones based on the // state provided by the snapshot. timers.values().forEach(Scheduled::cancel); timers.clear(); for (LockHolder holder : queue) { if (holder.expire > 0) { timers.put(holder.index, getScheduler().schedule(Duration.ofMillis(holder.expire - getWallClock().getTime().unixTimestamp()), () -> { timers.remove(holder.index); queue.remove(holder); Session session = getSession(holder.session); if (session != null && session.getState().active()) { getSession(holder.session).accept(service -> service.failed(holder.id)); } })); } } }