@Override @SuppressWarnings("unchecked") public Class<T> type() { return (Class<T>) parent.operation().getClass(); }
@Override @SuppressWarnings("unchecked") public Class<T> type() { return (Class<T>) parent.operation().getClass(); }
/** * Returns the message value. */ public Object message() { return commit.operation().message(); }
/** * Handles a set property commit. */ public void setProperty(Commit<GroupCommands.SetProperty> commit) { Map<String, Commit<GroupCommands.SetProperty>> properties = this.properties.get(commit.operation().member()); if (properties == null) { properties = new HashMap<>(); this.properties.put(commit.operation().member(), properties); } properties.put(commit.operation().property(), commit); }
/** * Executes a resource command. */ @SuppressWarnings("unchecked") private Object executeCommand(Commit<ResourceCommand> commit) { Function<Commit<?>, ?> function = callbacks.get(commit.operation().operation().getClass()); if (function != null) { return function.apply(new ResourceCommit(commit)); } throw new IllegalStateException("unknown operation type: " + commit.operation().operation().getClass()); }
/** * Executes a resource query. */ @SuppressWarnings("unchecked") private Object executeQuery(Commit<ResourceQuery> commit) { Function<Commit<?>, ?> function = callbacks.get(commit.operation().operation().getClass()); if (function != null) { return function.apply(new ResourceCommit(commit)); } throw new IllegalStateException("unknown operation type: " + commit.operation().operation().getClass()); }
/** * Executes a resource query. */ @SuppressWarnings("unchecked") private Object executeQuery(Commit<ResourceQuery> commit) { Function<Commit<?>, ?> function = callbacks.get(commit.operation().operation().getClass()); if (function != null) { return function.apply(new ResourceCommit(commit)); } throw new IllegalStateException("unknown operation type: " + commit.operation().operation().getClass()); }
/** * Handles a set commit. */ @Override public void set(Commit<ValueCommands.Set<Long>> commit) { try { value.set(commit.operation().value()); } finally { commit.close(); } }
/** * Handles a contains key commit. */ public boolean containsKey(Commit<MapCommands.ContainsKey> commit) { try { return map.containsKey(commit.operation().key()); } finally { commit.close(); } }
/** * Gets the value. */ private Object get(Commit<GetQuery> commit) { try { return value != null ? value.operation().value() : null; } finally { commit.close(); } }
public long remove(Commit<Remove> commit) { try { Commit<Put> removed = map.remove(commit.operation().key); if (removed != null) { removed.close(); } return commit.index(); } finally { commit.close(); } }
public long put(Commit<Put> commit) { try { Commit<Put> old = map.put(commit.operation().key, commit); if (old != null) { old.close(); } return commit.index(); } catch (Exception e) { commit.close(); throw e; } }
public long put(Commit<Put> commit) { try { Commit<Put> old = map.put(commit.operation().key, commit); if (old != null) { old.close(); } return commit.index(); } catch (Exception e) { commit.close(); throw e; } }
public long remove(Commit<Remove> commit) { try { Commit<Put> removed = map.remove(commit.operation().key); if (removed != null) { removed.close(); } return commit.index(); } finally { commit.close(); } }
/** * Handles a get and set commit. */ public Object getAndSet(Commit<AtomicValueCommands.GetAndSet> commit) { Object result = value; value = commit.operation().value(); cleanCurrent(); setCurrent(commit); return result; }
/** * Applies a set commit. */ public void set(Commit<ValueCommands.Set<T>> commit) { cleanCurrent(); value = commit.operation().value(); setCurrent(commit); }
/** * Handles a get and set commit. */ public T getAndSet(Commit<ValueCommands.GetAndSet<T>> commit) { T oldValue = value; value = commit.operation().value(); cleanCurrent(); setCurrent(commit); notify(new DistributedValue.ChangeEvent<>(oldValue, value)); return oldValue; }