gpt4 book ai didi

com.twitter.distributedlog.lock.ZKSessionLock.executeLockAction()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 11:05:23 27 4
gpt4 key购买 nike

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

ZKSessionLock.executeLockAction介绍

[英]Execute a lock action of a given lockEpoch in ordered safe way.
[中]以有序安全的方式执行给定锁的锁操作。

代码示例

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

private void handleNodeDelete(int lockEpoch, final WatchedEvent event) {
  executeLockAction(lockEpoch, new LockAction() {
    @Override
    public void execute() {
      // The lock is either expired or closed
      if (!lockState.inState(State.WAITING)) {
        LOG.info("{} ignore watched node {} deleted event, since lock state has moved to {}.",
            new Object[] { lockId, event.getPath(), lockState.getState() });
        return;
      }
      lockState.transition(State.PREPARED);
      // we don't need to wait and check the result, since:
      // 1) if it claimed the ownership, it would notify the waiters when claimed ownerships
      // 2) if it failed, it would also notify the waiters, the waiters would cleanup the state.
      checkLockOwnerAndWaitIfPossible(watcher, true);
    }
    @Override
    public String getActionName() {
      return "handleNodeDelete(path=" + event.getPath() + ")";
    }
  });
}

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

executeLockAction(lockEpoch, new LockAction() {
  @Override
  public void execute() {

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

final List<String> children,
              final Promise<String> promise) {
executeLockAction(lockWatcher.epoch, new LockAction() {
  @Override
  public void execute() {

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

final Pair<String, Long> currentOwner,
            final Promise<String> promise) {
executeLockAction(lockWatcher.epoch, new LockAction() {
  @Override
  public void execute() {

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

executeLockAction(epoch.get(), new LockAction() {
  @Override
  public void execute() {

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

private boolean checkOrClaimLockOwner(final Pair<String, Long> currentOwner,
                   final Promise<String> result) {
  if (lockId.compareTo(currentOwner) != 0 && !lockContext.hasLockId(currentOwner)) {
    lockStateExecutor.submit(lockPath, new SafeRunnable() {
      @Override
      public void safeRun() {
        result.setValue(currentOwner.getLeft());
      }
    });
    return false;
  }
  // current owner is itself
  final int curEpoch = epoch.incrementAndGet();
  executeLockAction(curEpoch, new LockAction() {
    @Override
    public void execute() {
      if (!lockState.inState(State.INIT)) {
        result.setException(new LockStateChangedException(lockPath, lockId, State.INIT, lockState.getState()));
        return;
      }
      asyncTryLock(false, result);
    }
    @Override
    public String getActionName() {
      return "claimOwnership(owner=" + currentOwner + ")";
    }
  }, result);
  return true;
}

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

lock.executeLockAction(lock.getEpoch().get(), new LockAction() {
  @Override
  public void execute() {
lock.executeLockAction(lock.getEpoch().get() + 1, new LockAction() {
  @Override
  public void execute() {
lock.executeLockAction(lock.getEpoch().get(), new LockAction() {
  @Override
  public void execute() {
lock.executeLockAction(lock.getEpoch().get() + 1, new LockAction() {
  @Override
  public void execute() {

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