本文整理了Java中com.twitter.distributedlog.lock.ZKSessionLock.executeLockAction()
方法的一些代码示例,展示了ZKSessionLock.executeLockAction()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKSessionLock.executeLockAction()
方法的具体详情如下:
包路径:com.twitter.distributedlog.lock.ZKSessionLock
类名称: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() {
内容来源于网络,如有侵权,请联系作者删除!