@Override public Scheduled schedule(Duration delay, Runnable callback) { return parent.schedule(delay, callback); }
@Override public Scheduled schedule(Duration initialDelay, Duration interval, Runnable callback) { return parent.schedule(initialDelay, interval, callback); }
@Override public Scheduled schedule(Duration delay, Runnable callback) { return parent.schedule(delay, callback); }
@Override public Scheduled schedule(Duration initialDelay, Duration interval, Runnable callback) { return parent.schedule(initialDelay, interval, callback); }
@Override public Scheduled schedule(Duration delay, Runnable callback) { Scheduled task = parent.schedule(delay, callback); tasks.add(task); return task; }
@Override public Scheduled schedule(Duration initialDelay, Duration interval, Runnable callback) { Scheduled task = parent.schedule(initialDelay, interval, callback); tasks.add(task); return task; }
@Override public Scheduled schedule(Duration initialDelay, Duration interval, Runnable callback) { Scheduled task = parent.schedule(initialDelay, interval, callback); tasks.add(task); return task; }
@Override public Scheduled schedule(Duration delay, Runnable callback) { Scheduled task = parent.schedule(delay, callback); tasks.add(task); return task; }
/** * Sets the current commit. */ private void setCurrent(Commit<? extends ValueCommands.ValueCommand<?>> commit) { timer = commit.operation().ttl() > 0 ? executor.schedule(Duration.ofMillis(commit.operation().ttl()), () -> { value = null; current.close(); current = null; }) : null; current = commit; }
/** * Sets the current commit. */ private void setCurrent(Commit<? extends ValueCommands.ValueCommand<?>> commit) { timer = commit.operation().ttl() > 0 ? executor.schedule(Duration.ofMillis(commit.operation().ttl()), () -> { value = null; current.close(); current = null; }) : null; current = commit; }
/** * Sets the current commit. */ private void setCurrent(Commit<? extends ValueCommands.ValueCommand<?>> commit) { timer = commit.operation().ttl() > 0 ? executor.schedule(Duration.ofMillis(commit.operation().ttl()), () -> { value = null; current.close(); current = null; }) : null; current = commit; }
/** * Sets the current commit. */ private void setCurrent(Commit<? extends ValueCommands.ValueCommand<?>> commit) { timer = commit.operation().ttl() > 0 ? executor.schedule(Duration.ofMillis(commit.operation().ttl()), () -> { value = null; current.close(); current = null; }) : null; current = commit; }
/** * Sets the current commit. */ private void setCurrent(Commit<? extends AtomicValueCommands.ValueCommand> commit) { timer = commit.operation().ttl() > 0 ? executor().schedule(Duration.ofMillis(commit.operation().ttl()), () -> { value = null; current.clean(); current = null; }) : null; current = commit; change(value); }
/** * Handles a schedule commit. */ public void schedule(Commit<GroupCommands.Schedule> commit) { try { if (!members.containsKey(commit.operation().member())) { throw new IllegalArgumentException("unknown member: " + commit.operation().member()); } executor.schedule(Duration.ofMillis(commit.operation().delay()), () -> { Commit<GroupCommands.Join> member = members.get(commit.operation().member()); if (member != null) { member.session().publish("execute", commit.operation().callback()); } commit.close(); }); } catch (Exception e){ commit.close(); throw e; } }
/** * Handles a schedule commit. */ public void schedule(Commit<GroupCommands.Schedule> commit) { try { if (!members.containsKey(commit.operation().member())) { throw new IllegalArgumentException("unknown member: " + commit.operation().member()); } executor.schedule(Duration.ofMillis(commit.operation().delay()), () -> { Commit<GroupCommands.Join> member = members.get(commit.operation().member()); if (member != null) { member.session().publish("execute", commit.operation().callback()); } commit.close(); }); } catch (Exception e){ commit.close(); throw e; } }
/** * Handles an add commit. */ public boolean add(Commit<SetCommands.Add> commit) { try { Value value = map.get(commit.operation().value()); if (value == null) { Scheduled timer = commit.operation().ttl() > 0 ? executor.schedule(Duration.ofMillis(commit.operation().ttl()), () -> { map.remove(commit.operation().value()).commit.close(); }) : null; map.put(commit.operation().value(), new Value(commit, timer)); } else { commit.close(); } } catch (Exception e) { commit.close(); throw e; } return false; }
/** * Handles a put if absent commit. */ public Object putIfAbsent(Commit<MapCommands.PutIfAbsent> commit) { try { Value value = map.get(commit.operation().key()); if (value == null) { Scheduled timer = commit.operation().ttl() > 0 ? executor.schedule(Duration.ofMillis(commit.operation().ttl()), () -> { map.remove(commit.operation().key()).commit.close(); }) : null; map.put(commit.operation().key(), new Value(commit, timer)); return null; } else { commit.close(); return value.commit.operation().value(); } } catch (Exception e) { commit.close(); throw e; } }
/** * Handles a replace commit. */ public Object replace(Commit<MapCommands.Replace> commit) { Value value = map.get(commit.operation().key()); if (value != null) { try { if (value.timer != null) value.timer.cancel(); Scheduled timer = commit.operation().ttl() > 0 ? executor.schedule(Duration.ofMillis(commit.operation().ttl()), () -> { map.remove(commit.operation().key()); commit.close(); }) : null; map.put(commit.operation().key(), new Value(commit, timer)); return value.commit.operation().value(); } finally { value.commit.close(); } } else { commit.close(); } return null; }
/** * Handles an add commit. */ public boolean add(Commit<SetCommands.Add> commit) { try { Value value = map.get(commit.operation().value()); if (value == null) { Scheduled timer = commit.operation().ttl() > 0 ? executor.schedule(Duration.ofMillis(commit.operation().ttl()), () -> { map.remove(commit.operation().value()).commit.close(); }) : null; map.put(commit.operation().value(), new Value(commit, timer)); notify(new ValueEvent<>(Events.ADD, commit.operation().value())); } else { commit.close(); } } catch (Exception e) { commit.close(); throw e; } return false; }
/** * Handles a replace if present commit. */ public boolean replaceIfPresent(Commit<MapCommands.ReplaceIfPresent> commit) { Value value = map.get(commit.operation().key()); if (value == null) { commit.close(); return false; } if ((value.commit.operation().value() == null && commit.operation().replace() == null) || (value.commit.operation().value() != null && value.commit.operation().value().equals(commit.operation().replace()))) { if (value.timer != null) value.timer.cancel(); Scheduled timer = commit.operation().ttl() > 0 ? executor.schedule(Duration.ofMillis(commit.operation().ttl()), () -> { map.remove(commit.operation().key()).commit.close(); }) : null; map.put(commit.operation().key(), new Value(commit, timer)); value.commit.close(); return true; } else { commit.close(); } return false; }