Search in sources :

Example 1 with ZKVersionedSetOp

use of org.apache.distributedlog.zk.ZKVersionedSetOp in project bookkeeper by apache.

the class ZKLogSegmentMetadataStore method storeMaxLogSegmentSequenceNumber.

// max sequence number and max transaction id
@Override
public void storeMaxLogSegmentSequenceNumber(Transaction<Object> txn, LogMetadata logMetadata, Versioned<Long> lssn, Transaction.OpListener<Version> listener) {
    Version version = lssn.getVersion();
    assert (version instanceof LongVersion);
    LongVersion zkVersion = (LongVersion) version;
    byte[] data = DLUtils.serializeLogSegmentSequenceNumber(lssn.getValue());
    Op setDataOp = Op.setData(logMetadata.getLogSegmentsPath(), data, (int) zkVersion.getLongVersion());
    ZKOp zkOp = new ZKVersionedSetOp(setDataOp, listener);
    txn.addOp(zkOp);
}
Also used : ZKOp(org.apache.distributedlog.zk.ZKOp) Op(org.apache.zookeeper.Op) DefaultZKOp(org.apache.distributedlog.zk.DefaultZKOp) ZKVersionedSetOp(org.apache.distributedlog.zk.ZKVersionedSetOp) LongVersion(org.apache.bookkeeper.versioning.LongVersion) Version(org.apache.bookkeeper.versioning.Version) LongVersion(org.apache.bookkeeper.versioning.LongVersion) ZKOp(org.apache.distributedlog.zk.ZKOp) DefaultZKOp(org.apache.distributedlog.zk.DefaultZKOp) ZKVersionedSetOp(org.apache.distributedlog.zk.ZKVersionedSetOp)

Example 2 with ZKVersionedSetOp

use of org.apache.distributedlog.zk.ZKVersionedSetOp in project bookkeeper by apache.

the class ZKLogSegmentMetadataStore method storeMaxTxnId.

@Override
public void storeMaxTxnId(Transaction<Object> txn, LogMetadataForWriter logMetadata, Versioned<Long> transactionId, Transaction.OpListener<Version> listener) {
    Version version = transactionId.getVersion();
    assert (version instanceof LongVersion);
    LongVersion zkVersion = (LongVersion) version;
    byte[] data = DLUtils.serializeTransactionId(transactionId.getValue());
    Op setDataOp = Op.setData(logMetadata.getMaxTxIdPath(), data, (int) zkVersion.getLongVersion());
    ZKOp zkOp = new ZKVersionedSetOp(setDataOp, listener);
    txn.addOp(zkOp);
}
Also used : ZKOp(org.apache.distributedlog.zk.ZKOp) Op(org.apache.zookeeper.Op) DefaultZKOp(org.apache.distributedlog.zk.DefaultZKOp) ZKVersionedSetOp(org.apache.distributedlog.zk.ZKVersionedSetOp) LongVersion(org.apache.bookkeeper.versioning.LongVersion) Version(org.apache.bookkeeper.versioning.Version) LongVersion(org.apache.bookkeeper.versioning.LongVersion) ZKOp(org.apache.distributedlog.zk.ZKOp) DefaultZKOp(org.apache.distributedlog.zk.DefaultZKOp) ZKVersionedSetOp(org.apache.distributedlog.zk.ZKVersionedSetOp)

Example 3 with ZKVersionedSetOp

use of org.apache.distributedlog.zk.ZKVersionedSetOp in project bookkeeper by apache.

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, (int) version.getLongVersion());
    ZKVersionedSetOp commitOp = new ZKVersionedSetOp(zkSetDataOp, this);
    tryObtainTxn.addOp(commitOp);
    setPhase(Phase.HANDING_OVER);
    allocatePromise.complete(lh);
}
Also used : ZKVersionedSetOp(org.apache.distributedlog.zk.ZKVersionedSetOp)

Aggregations

ZKVersionedSetOp (org.apache.distributedlog.zk.ZKVersionedSetOp)3 LongVersion (org.apache.bookkeeper.versioning.LongVersion)2 Version (org.apache.bookkeeper.versioning.Version)2 DefaultZKOp (org.apache.distributedlog.zk.DefaultZKOp)2 ZKOp (org.apache.distributedlog.zk.ZKOp)2 Op (org.apache.zookeeper.Op)2