use of com.ibm.etcd.api.CompareOrBuilder in project etcd-java by IBM.
the class RangeCache method doPut.
protected ListenableFuture<TxnResponse> doPut(ByteString key, ByteString value, boolean getOnFail, long lease, CompareOrBuilder... conditions) {
TxnRequest.Builder tb = TxnRequest.newBuilder();
if (conditions != null && conditions.length > 0) {
for (CompareOrBuilder comp : conditions) {
if (comp instanceof Compare)
tb.addCompare((Compare) comp);
else
tb.addCompare((Compare.Builder) comp);
}
} else
getOnFail = false;
RequestOp.Builder bld = RequestOp.newBuilder();
RequestOp getOp = getOnFail || value != null ? getReq(bld, key) : null;
if (value != null)
tb.addSuccess(putReq(bld, key, value, lease)).addSuccess(getOp);
else
tb.addSuccess(deleteReq(bld, key));
if (getOnFail)
tb.addFailure(getOp);
return kvClient.txn(tb.build());
}
Aggregations