gpt4 book ai didi

org.apache.bookkeeper.meta.ZkVersion.getZnodeVersion()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:15:27 26 4
gpt4 key购买 nike

本文整理了Java中org.apache.bookkeeper.meta.ZkVersion.getZnodeVersion()方法的一些代码示例,展示了ZkVersion.getZnodeVersion()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkVersion.getZnodeVersion()方法的具体详情如下:
包路径:org.apache.bookkeeper.meta.ZkVersion
类名称:ZkVersion
方法名:getZnodeVersion

ZkVersion.getZnodeVersion介绍

暂无

代码示例

代码示例来源:origin: twitter/distributedlog

synchronized int getZkVersion() {
  return ((ZkVersion) version).getZnodeVersion();
}

代码示例来源:origin: twitter/distributedlog

/**
 * Delete the given <i>path</i> from zookeeper.
 *
 * @param zk
 *          zookeeper client
 * @param path
 *          path to delete
 * @param version
 *          version used to set data
 * @return future representing the version after this operation.
 */
public static Future<Void> zkDelete(ZooKeeper zk, String path, ZkVersion version) {
  final Promise<Void> promise = new Promise<Void>();
  zk.delete(path, version.getZnodeVersion(), new AsyncCallback.VoidCallback() {
    @Override
    public void processResult(int rc, String path, Object ctx) {
      if (KeeperException.Code.OK.intValue() == rc) {
        promise.updateIfEmpty(new Return<Void>(null));
        return;
      }
      promise.updateIfEmpty(new Throw<Void>(
          KeeperException.create(KeeperException.Code.get(rc))));
      return;
    }
  }, null);
  return promise;
}

代码示例来源:origin: twitter/distributedlog

/**
 * Set <code>data</code> to zookeeper <code>path</code>.
 *
 * @param zk
 *          zookeeper client
 * @param path
 *          path to set data
 * @param data
 *          data to set
 * @param version
 *          version used to set data
 * @return future representing the version after this operation.
 */
public static Future<ZkVersion> zkSetData(ZooKeeper zk, String path, byte[] data, ZkVersion version) {
  final Promise<ZkVersion> promise = new Promise<ZkVersion>();
  zk.setData(path, data, version.getZnodeVersion(), new AsyncCallback.StatCallback() {
    @Override
    public void processResult(int rc, String path, Object ctx, Stat stat) {
      if (KeeperException.Code.OK.intValue() == rc) {
        promise.updateIfEmpty(new Return<ZkVersion>(new ZkVersion(stat.getVersion())));
        return;
      }
      promise.updateIfEmpty(new Throw<ZkVersion>(
          KeeperException.create(KeeperException.Code.get(rc))));
      return;
    }
  }, null);
  return promise;
}

代码示例来源:origin: twitter/distributedlog

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);
}

代码示例来源:origin: twitter/distributedlog

@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);
}

代码示例来源:origin: twitter/distributedlog

@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);
}

代码示例来源:origin: twitter/distributedlog

@Test(timeout = 60000)
public void testStoreMaxLogSegmentSequenceNumber() throws Exception {
  Transaction<Object> updateTxn = lsmStore.transaction();
  Versioned<Long> value = new Versioned<Long>(999L, new ZkVersion(0));
  final Promise<Version> result = new Promise<Version>();
  lsmStore.storeMaxLogSegmentSequenceNumber(updateTxn, rootZkPath, value,
      new Transaction.OpListener<Version>() {
    @Override
    public void onCommit(Version r) {
      result.setValue(r);
    }
    @Override
    public void onAbort(Throwable t) {
      result.setException(t);
    }
  });
  FutureUtils.result(updateTxn.execute());
  assertEquals(1, ((ZkVersion) FutureUtils.result(result)).getZnodeVersion());
  Stat stat = new Stat();
  byte[] data = zkc.get().getData(rootZkPath, false, stat);
  assertEquals(999L, DLUtils.deserializeLogSegmentSequenceNumber(data));
  assertEquals(1, stat.getVersion());
}

代码示例来源:origin: twitter/distributedlog

@Test(timeout = 60000)
public void testStoreMaxTxnId() throws Exception {
  Transaction<Object> updateTxn = lsmStore.transaction();
  Versioned<Long> value = new Versioned<Long>(999L, new ZkVersion(0));
  final Promise<Version> result = new Promise<Version>();
  lsmStore.storeMaxTxnId(updateTxn, rootZkPath, value,
      new Transaction.OpListener<Version>() {
    @Override
    public void onCommit(Version r) {
      result.setValue(r);
    }
    @Override
    public void onAbort(Throwable t) {
      result.setException(t);
    }
  });
  FutureUtils.result(updateTxn.execute());
  assertEquals(1, ((ZkVersion) FutureUtils.result(result)).getZnodeVersion());
  Stat stat = new Stat();
  byte[] data = zkc.get().getData(rootZkPath, false, stat);
  assertEquals(999L, DLUtils.deserializeTransactionId(data));
  assertEquals(1, stat.getVersion());
}

代码示例来源:origin: twitter/distributedlog

@Test(timeout = 60000)
  public void testZkGetData() throws Exception {
    String path1 = "/zk-get-data/non-existent-path";
    Versioned<byte[]> data = FutureUtils.result(Utils.zkGetData(zkc.get(), path1, false));
    assertNull("No data should return from non-existent-path", data.getValue());
    assertNull("No version should return from non-existent-path", data.getVersion());

    String path2 = "/zk-get-data/path2";
    byte[] rawData = "test-data".getBytes(UTF_8);
    FutureUtils.result(Utils.zkAsyncCreateFullPathOptimistic(zkc, path2, rawData,
        zkc.getDefaultACL(), CreateMode.PERSISTENT));
    data = FutureUtils.result(Utils.zkGetData(zkc.get(), path2, false));
    assertArrayEquals("Data should return as written",
        rawData, data.getValue());
    assertEquals("Version should be zero",
        0, ((ZkVersion) data.getVersion()).getZnodeVersion());
  }
}

代码示例来源:origin: twitter/distributedlog

assertTrue(((ZkVersion) metadata.getVersion()).getZnodeVersion() >= 0);

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com