Skip to content

Commit

Permalink
Remove the delete() function which uses the old approach
Browse files Browse the repository at this point in the history
  • Loading branch information
justinsb committed Dec 13, 2013
1 parent 49c3275 commit e971df5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Expand Up @@ -15,7 +15,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cloudata.keyvalue.KeyValueProto.KvAction;
import com.cloudata.keyvalue.KeyValueProto.KvEntry;
import com.cloudata.keyvalue.btree.operation.DeleteOperation;
import com.cloudata.keyvalue.btree.operation.IncrementOperation;
Expand Down Expand Up @@ -65,13 +64,6 @@ public Object doAction(KvEntry entry) throws InterruptedException, RaftException
return raft.commit(entry.toByteArray());
}

public Object delete(long storeId, byte[] key) throws RaftException, InterruptedException {
KvEntry entry = KvEntry.newBuilder().setStoreId(storeId).setKey(ByteString.copyFrom(key))
.setAction(KvAction.DELETE).build();

return raft.commit(entry.toByteArray());
}

@Override
public Object applyOperation(@Nonnull ByteBuffer op) {
// TODO: We need to prevent repetition during replay
Expand Down
Expand Up @@ -109,7 +109,10 @@ public Response delete(@PathParam("key") String key) throws IOException {
try {
byte[] k = BaseEncoding.base16().decode(key);

stateMachine.delete(storeId, k);
KvEntry entry = KvEntry.newBuilder().setStoreId(storeId).setKey(ByteString.copyFrom(k))
.setAction(KvAction.DELETE).build();

stateMachine.doAction(entry);

return Response.noContent().build();
} catch (InterruptedException e) {
Expand Down

0 comments on commit e971df5

Please sign in to comment.