本文整理汇总了Java中org.apache.zookeeper.Op.setData方法的典型用法代码示例。如果您正苦于以下问题:Java Op.setData方法的具体用法?Java Op.setData怎么用?Java Op.setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.zookeeper.Op
的用法示例。
在下文中一共展示了Op.setData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toZooKeeperOp
import org.apache.zookeeper.Op; //导入方法依赖的package包/类
/**
* Convert from ZKUtilOp to ZKOp
*/
private static Op toZooKeeperOp(ZooKeeperWatcher zkw, ZKUtilOp op)
throws UnsupportedOperationException {
if(op == null) return null;
if (op instanceof CreateAndFailSilent) {
CreateAndFailSilent cafs = (CreateAndFailSilent)op;
return Op.create(cafs.getPath(), cafs.getData(), createACL(zkw, cafs.getPath()),
CreateMode.PERSISTENT);
} else if (op instanceof DeleteNodeFailSilent) {
DeleteNodeFailSilent dnfs = (DeleteNodeFailSilent)op;
return Op.delete(dnfs.getPath(), -1);
} else if (op instanceof SetData) {
SetData sd = (SetData)op;
return Op.setData(sd.getPath(), sd.getData(), -1);
} else {
throw new UnsupportedOperationException("Unexpected ZKUtilOp type: "
+ op.getClass().getName());
}
}
示例2: storeMaxTxId
import org.apache.zookeeper.Op; //导入方法依赖的package包/类
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) {
}
}));
}
}
示例3: storeMaxSequenceNumber
import org.apache.zookeeper.Op; //导入方法依赖的package包/类
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
}
}));
}
示例4: storeMaxLogSegmentSequenceNumber
import org.apache.zookeeper.Op; //导入方法依赖的package包/类
@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);
}
示例5: storeMaxTxnId
import org.apache.zookeeper.Op; //导入方法依赖的package包/类
@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);
}
示例6: updateLogSegment
import org.apache.zookeeper.Op; //导入方法依赖的package包/类
@Override
public void updateLogSegment(Transaction<Object> txn, LogSegmentMetadata segment) {
byte[] finalisedData = segment.getFinalisedData().getBytes(UTF_8);
Op updateOp = Op.setData(segment.getZkPath(), finalisedData, -1);
txn.addOp(DefaultZKOp.of(updateOp));
}