use of com.twitter.distributedlog.zk.ZKVersionedSetOp in project distributedlog by twitter.
the class ZKLogSegmentMetadataStore method storeMaxTxnId.
@Override
public void storeMaxTxnId(Transaction<Object> txn, String path, Versioned<Long> transactionId, Transaction.OpListener<Version> listener) {
Version version = transactionId.getVersion();
assert (version instanceof ZkVersion);
ZkVersion zkVersion = (ZkVersion) version;
byte[] data = DLUtils.serializeTransactionId(transactionId.getValue());
Op setDataOp = Op.setData(path, data, zkVersion.getZnodeVersion());
ZKOp zkOp = new ZKVersionedSetOp(setDataOp, listener);
txn.addOp(zkOp);
}
use of com.twitter.distributedlog.zk.ZKVersionedSetOp in project distributedlog by twitter.
the class ZKLogSegmentMetadataStore method storeMaxLogSegmentSequenceNumber.
// max sequence number and max transaction id
@Override
public void storeMaxLogSegmentSequenceNumber(Transaction<Object> txn, String path, Versioned<Long> lssn, Transaction.OpListener<Version> listener) {
Version version = lssn.getVersion();
assert (version instanceof ZkVersion);
ZkVersion zkVersion = (ZkVersion) version;
byte[] data = DLUtils.serializeLogSegmentSequenceNumber(lssn.getValue());
Op setDataOp = Op.setData(path, data, zkVersion.getZnodeVersion());
ZKOp zkOp = new ZKVersionedSetOp(setDataOp, listener);
txn.addOp(zkOp);
}
use of com.twitter.distributedlog.zk.ZKVersionedSetOp in project distributedlog by twitter.
the class SimpleLedgerAllocator method completeAllocation.
private synchronized void completeAllocation(LedgerHandle lh) {
allocatedLh = lh;
if (null == tryObtainTxn) {
return;
}
org.apache.zookeeper.Op zkSetDataOp = org.apache.zookeeper.Op.setData(allocatePath, DistributedLogConstants.EMPTY_BYTES, version.getZnodeVersion());
ZKVersionedSetOp commitOp = new ZKVersionedSetOp(zkSetDataOp, this);
tryObtainTxn.addOp(commitOp);
setPhase(Phase.HANDING_OVER);
FutureUtils.setValue(allocatePromise, lh);
}
use of com.twitter.distributedlog.zk.ZKVersionedSetOp in project distributedlog by twitter.
the class BKLogWriteHandler method storeMaxTxId.
// Transactional operations for MaxTxId
void storeMaxTxId(final ZKTransaction txn, final MaxTxId maxTxId, final long txId) {
byte[] data = maxTxId.couldStore(txId);
if (null != data) {
Op zkOp = Op.setData(maxTxId.getZkPath(), data, -1);
txn.addOp(new ZKVersionedSetOp(zkOp, new Transaction.OpListener<Version>() {
@Override
public void onCommit(Version version) {
maxTxId.setMaxTxId(txId);
}
@Override
public void onAbort(Throwable t) {
}
}));
}
}
use of com.twitter.distributedlog.zk.ZKVersionedSetOp in project distributedlog by twitter.
the class BKLogWriteHandler method storeMaxSequenceNumber.
// Transactional operations for MaxLogSegmentSequenceNo
void storeMaxSequenceNumber(final Transaction txn, final MaxLogSegmentSequenceNo maxSeqNo, final long seqNo, final boolean isInprogress) {
byte[] data = DLUtils.serializeLogSegmentSequenceNumber(seqNo);
Op zkOp = Op.setData(logMetadata.getLogSegmentsPath(), data, maxSeqNo.getZkVersion());
txn.addOp(new ZKVersionedSetOp(zkOp, new Transaction.OpListener<Version>() {
@Override
public void onCommit(Version version) {
if (validateLogSegmentSequenceNumber) {
synchronized (inprogressLSSNs) {
if (isInprogress) {
inprogressLSSNs.add(seqNo);
} else {
inprogressLSSNs.removeFirst();
}
}
}
maxSeqNo.update((ZkVersion) version, seqNo);
}
@Override
public void onAbort(Throwable t) {
// no-op
}
}));
}
Aggregations