@Test public void shouldSubmitSetCommandWhenSetIsCalled() throws Exception { String key = "KEY"; String value = "VALUE"; SetValue setValue = new SetValue(); setValue.setNewValue(value); when(raftAgent.submitCommand(any(KayVeeCommand.class))).thenReturn(SettableFuture.<Void>create()); initializeAndStartDistributedStore(); ListenableFuture<KeyValue> setFuture = distributedStore.set(key, setValue); assertThat(setFuture.isDone(), equalTo(false)); ArgumentCaptor<Command> captor = ArgumentCaptor.forClass(Command.class); verify(raftAgent).submitCommand(captor.capture()); KayVeeCommand.SETCommand setCommand = (KayVeeCommand.SETCommand) captor.getValue(); assertThat(setCommand.getKey(), equalTo(key)); assertThat(setCommand.getNewValue(), equalTo(value)); stopDistributedStore(); }
public ListenableFuture<KeyValue> set(String key, SetValue setValue) { checkThatDistributedStoreIsActive(); KayVeeCommand.SETCommand setCommand = new KayVeeCommand.SETCommand(getCommandId(), key, setValue.getNewValue()); return issueCommandToCluster(setCommand); }
DistributedStore implements Managed, RaftListener { public ListenableFuture<KeyValue> set(String key, SetValue setValue) { checkThatDistributedStoreIsActive(); KayVeeCommand.SETCommand setCommand = new KayVeeCommand.SETCommand(getCommandId(), key, setValue.getNewValue()); return issueCommandToCluster(setCommand); } }
DistributedStore implements Managed, RaftListener { public ListenableFuture<KeyValue> set(String key, SetValue setValue) { checkThatDistributedStoreIsActive(); KayVeeCommand.SETCommand setCommand = new KayVeeCommand.SETCommand(getCommandId(), key, setValue.getNewValue()); return issueCommandToCluster(setCommand); } DistributedStore(LocalStore localStore); }
DistributedStore implements Managed, RaftListener { public ListenableFuture<KeyValue> set(String key, SetValue setValue) { checkThatDistributedStoreIsActive(); KayVeeCommand.SETCommand setCommand = new KayVeeCommand.SETCommand(getCommandId(), key, setValue.getNewValue()); return issueCommandToCluster(setCommand); } DistributedStore(LocalStore localStore); void setRaftAgent(RaftAgent raftAgent); synchronized void initialize(); @Override synchronized void start(); @Override synchronized void stop(); @Override void onLeadershipChange(@Nullable String leader); @Override void writeSnapshot(SnapshotWriter snapshotWriter); @Override void applyCommitted(Committed committed); ListenableFuture<Void> nop(); ListenableFuture<KeyValue> get(String key); ListenableFuture<Collection<KeyValue>> getAll(); ListenableFuture<KeyValue> set(String key, SetValue setValue); ListenableFuture<KeyValue> compareAndSet(String key, SetValue setValue); ListenableFuture<Void> delete(String key); }
DistributedStore implements Managed, RaftListener { public ListenableFuture<KeyValue> set(String key, SetValue setValue) { checkThatDistributedStoreIsActive(); KayVeeCommand.SETCommand setCommand = new KayVeeCommand.SETCommand(getCommandId(), key, setValue.getNewValue()); return issueCommandToCluster(setCommand); } DistributedStore(LocalStore localStore); void setRaftAgent(RaftAgent raftAgent); synchronized void initialize(); @Override synchronized void start(); @Override synchronized void stop(); @Override void onLeadershipChange(@Nullable String leader); @Override void writeSnapshot(SnapshotWriter snapshotWriter); @Override void applyCommitted(Committed committed); ListenableFuture<Void> nop(); ListenableFuture<KeyValue> get(String key); ListenableFuture<Collection<KeyValue>> getAll(); ListenableFuture<KeyValue> set(String key, SetValue setValue); ListenableFuture<KeyValue> compareAndSet(String key, SetValue setValue); ListenableFuture<Void> delete(String key);  }