gpt4 book ai didi

org.apache.flink.runtime.zookeeper.ZooKeeperStateHandleStore.normalizePath()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 20:17:31 35 4
gpt4 key购买 nike

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

ZooKeeperStateHandleStore.normalizePath介绍

[英]Makes sure that every path starts with a "/".
[中]确保每条路径都以“/”开头。

代码示例

代码示例来源:origin: org.apache.flink/flink-runtime

/**
 * Releases the lock from the node under the given ZooKeeper path. If no lock exists, then nothing happens.
 *
 * @param pathInZooKeeper Path describing the ZooKeeper node
 * @throws Exception if the delete operation of the lock node fails
 */
public void release(String pathInZooKeeper) throws Exception {
  final String path = normalizePath(pathInZooKeeper);
  try {
    client.delete().forPath(getLockPath(path));
  } catch (KeeperException.NoNodeException ignored) {
    // we have never locked this node
  } catch (Exception e) {
    throw new Exception("Could not release the lock: " + getLockPath(pathInZooKeeper) + '.', e);
  }
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.10

/**
 * Releases the lock from the node under the given ZooKeeper path. If no lock exists, then nothing happens.
 *
 * @param pathInZooKeeper Path describing the ZooKeeper node
 * @throws Exception if the delete operation of the lock node fails
 */
public void release(String pathInZooKeeper) throws Exception {
  final String path = normalizePath(pathInZooKeeper);
  try {
    client.delete().forPath(getLockPath(path));
  } catch (KeeperException.NoNodeException ignored) {
    // we have never locked this node
  } catch (Exception e) {
    throw new Exception("Could not release the lock: " + getLockPath(pathInZooKeeper) + '.', e);
  }
}

代码示例来源:origin: com.alibaba.blink/flink-runtime

/**
 * Releases the lock from the node under the given ZooKeeper path. If no lock exists, then nothing happens.
 *
 * @param pathInZooKeeper Path describing the ZooKeeper node
 * @throws Exception if the delete operation of the lock node fails
 */
public void release(String pathInZooKeeper) throws Exception {
  final String path = normalizePath(pathInZooKeeper);
  try {
    client.delete().forPath(getLockPath(path));
  } catch (KeeperException.NoNodeException ignored) {
    // we have never locked this node
  } catch (Exception e) {
    throw new Exception("Could not release the lock: " + getLockPath(pathInZooKeeper) + '.', e);
  }
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.11

/**
 * Releases the lock from the node under the given ZooKeeper path. If no lock exists, then nothing happens.
 *
 * @param pathInZooKeeper Path describing the ZooKeeper node
 * @throws Exception if the delete operation of the lock node fails
 */
public void release(String pathInZooKeeper) throws Exception {
  final String path = normalizePath(pathInZooKeeper);
  try {
    client.delete().forPath(getLockPath(path));
  } catch (KeeperException.NoNodeException ignored) {
    // we have never locked this node
  } catch (Exception e) {
    throw new Exception("Could not release the lock: " + getLockPath(pathInZooKeeper) + '.', e);
  }
}

代码示例来源:origin: com.alibaba.blink/flink-runtime

/**
 * Returns the version of the node if it exists or <code>-1</code> if it doesn't.
 *
 * @param pathInZooKeeper Path in ZooKeeper to check
 * @return Version of the ZNode if the path exists, <code>-1</code> otherwise.
 * @throws Exception If the ZooKeeper operation fails
 */
public int exists(String pathInZooKeeper) throws Exception {
  checkNotNull(pathInZooKeeper, "Path in ZooKeeper");
  final String path = normalizePath(pathInZooKeeper);
  Stat stat = client.checkExists().forPath(path);
  if (stat != null) {
    return stat.getVersion();
  }
  return -1;
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.11

/**
 * Releases the lock for the given state node and tries to remove the state node if it is no longer locked.
 * It returns the {@link RetrievableStateHandle} stored under the given state node if any.
 *
 * @param pathInZooKeeper Path of state handle to remove
 * @return True if the state handle could be released
 * @throws Exception If the ZooKeeper operation or discarding the state handle fails
 */
@Nullable
public boolean releaseAndTryRemove(String pathInZooKeeper) throws Exception {
  checkNotNull(pathInZooKeeper, "Path in ZooKeeper");
  final String path = normalizePath(pathInZooKeeper);
  RetrievableStateHandle<T> stateHandle = null;
  try {
    stateHandle = get(path, false);
  } catch (Exception e) {
    LOG.warn("Could not retrieve the state handle from node {}.", path, e);
  }
  release(pathInZooKeeper);
  try {
    client.delete().forPath(path);
  } catch (KeeperException.NotEmptyException ignored) {
    LOG.debug("Could not delete znode {} because it is still locked.", path);
    return false;
  }
  if (stateHandle != null) {
    stateHandle.discardState();
  }
  return true;
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.11

/**
 * Returns the version of the node if it exists or <code>-1</code> if it doesn't.
 *
 * @param pathInZooKeeper Path in ZooKeeper to check
 * @return Version of the ZNode if the path exists, <code>-1</code> otherwise.
 * @throws Exception If the ZooKeeper operation fails
 */
public int exists(String pathInZooKeeper) throws Exception {
  checkNotNull(pathInZooKeeper, "Path in ZooKeeper");
  final String path = normalizePath(pathInZooKeeper);
  Stat stat = client.checkExists().forPath(path);
  if (stat != null) {
    return stat.getVersion();
  }
  return -1;
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.10

/**
 * Returns the version of the node if it exists or <code>-1</code> if it doesn't.
 *
 * @param pathInZooKeeper Path in ZooKeeper to check
 * @return Version of the ZNode if the path exists, <code>-1</code> otherwise.
 * @throws Exception If the ZooKeeper operation fails
 */
public int exists(String pathInZooKeeper) throws Exception {
  checkNotNull(pathInZooKeeper, "Path in ZooKeeper");
  final String path = normalizePath(pathInZooKeeper);
  Stat stat = client.checkExists().forPath(path);
  if (stat != null) {
    return stat.getVersion();
  }
  return -1;
}

代码示例来源:origin: org.apache.flink/flink-runtime

/**
 * Returns the version of the node if it exists or <code>-1</code> if it doesn't.
 *
 * @param pathInZooKeeper Path in ZooKeeper to check
 * @return Version of the ZNode if the path exists, <code>-1</code> otherwise.
 * @throws Exception If the ZooKeeper operation fails
 */
public int exists(String pathInZooKeeper) throws Exception {
  checkNotNull(pathInZooKeeper, "Path in ZooKeeper");
  final String path = normalizePath(pathInZooKeeper);
  Stat stat = client.checkExists().forPath(path);
  if (stat != null) {
    return stat.getVersion();
  }
  return -1;
}

代码示例来源:origin: org.apache.flink/flink-runtime

/**
 * Releases the lock for the given state node and tries to remove the state node if it is no longer locked.
 * It returns the {@link RetrievableStateHandle} stored under the given state node if any.
 *
 * @param pathInZooKeeper Path of state handle to remove
 * @return True if the state handle could be released
 * @throws Exception If the ZooKeeper operation or discarding the state handle fails
 */
@Nullable
public boolean releaseAndTryRemove(String pathInZooKeeper) throws Exception {
  checkNotNull(pathInZooKeeper, "Path in ZooKeeper");
  final String path = normalizePath(pathInZooKeeper);
  RetrievableStateHandle<T> stateHandle = null;
  try {
    stateHandle = get(path, false);
  } catch (Exception e) {
    LOG.warn("Could not retrieve the state handle from node {}.", path, e);
  }
  release(pathInZooKeeper);
  try {
    client.delete().forPath(path);
  } catch (KeeperException.NotEmptyException ignored) {
    LOG.debug("Could not delete znode {} because it is still locked.", path);
    return false;
  }
  if (stateHandle != null) {
    stateHandle.discardState();
  }
  return true;
}

代码示例来源:origin: org.apache.flink/flink-runtime_2.10

/**
 * Releases the lock for the given state node and tries to remove the state node if it is no longer locked.
 * The deletion of the state node is executed asynchronously. After the state node has been deleted, the given
 * callback is called with the {@link RetrievableStateHandle} of the deleted state node.
 *
 * <p><strong>Important</strong>: This also discards the stored state handle after the given action
 * has been executed.
 *
 * @param pathInZooKeeper Path of state handle to remove
 * @param callback The callback to execute after a successful deletion. Null if no action needs to be executed.
 * @throws Exception If the ZooKeeper operation fails
 */
public void releaseAndTryRemove(
    String pathInZooKeeper,
    @Nullable final RemoveCallback<T> callback) throws Exception {
  checkNotNull(pathInZooKeeper, "Path in ZooKeeper");
  final String path = normalizePath(pathInZooKeeper);
  RetrievableStateHandle<T> stateHandle = null;
  try {
    stateHandle = get(path, false);
  } catch (Exception e) {
    LOG.warn("Could not retrieve the state handle from node " + path + '.', e);
  }
  release(pathInZooKeeper);
  final BackgroundCallback backgroundCallback = new RemoveBackgroundCallback<>(stateHandle, callback, path);
  client.delete().inBackground(backgroundCallback, executor).forPath(path);
}

代码示例来源:origin: com.alibaba.blink/flink-runtime

checkNotNull(pathInZooKeeper, "Path in ZooKeeper");
final String path = normalizePath(pathInZooKeeper);

代码示例来源:origin: com.alibaba.blink/flink-runtime

/**
 * Releases the lock for the given state node and tries to remove the state node if it is no longer locked.
 * The deletion of the state node is executed asynchronously. After the state node has been deleted, the given
 * callback is called with the {@link RetrievableStateHandle} of the deleted state node.
 *
 * <p><strong>Important</strong>: This also discards the stored state handle after the given action
 * has been executed.
 *
 * @param pathInZooKeeper Path of state handle to remove
 * @param callback The callback to execute after a successful deletion. Null if no action needs to be executed.
 * @throws Exception If the ZooKeeper operation fails
 */
public void releaseAndTryRemove(
    String pathInZooKeeper,
    @Nullable final RemoveCallback<T> callback) throws Exception {
  checkNotNull(pathInZooKeeper, "Path in ZooKeeper");
  final String path = normalizePath(pathInZooKeeper);
  RetrievableStateHandle<T> stateHandle = null;
  try {
    stateHandle = get(path, false);
  } catch (Exception e) {
    LOG.warn("Could not retrieve the state handle from node " + path + '.', e);
  }
  release(pathInZooKeeper);
  final BackgroundCallback backgroundCallback = new RemoveBackgroundCallback<>(stateHandle, callback, path);
  client.delete().inBackground(backgroundCallback, executor).forPath(path);
}

代码示例来源:origin: org.apache.flink/flink-runtime

checkNotNull(pathInZooKeeper, "Path in ZooKeeper");
final String path = normalizePath(pathInZooKeeper);

代码示例来源:origin: org.apache.flink/flink-runtime_2.11

checkNotNull(pathInZooKeeper, "Path in ZooKeeper");
final String path = normalizePath(pathInZooKeeper);

代码示例来源:origin: com.alibaba.blink/flink-runtime

checkNotNull(state, "State");
final String path = normalizePath(pathInZooKeeper);

代码示例来源:origin: org.apache.flink/flink-runtime

checkNotNull(state, "State");
final String path = normalizePath(pathInZooKeeper);

代码示例来源:origin: org.apache.flink/flink-runtime_2.11

checkNotNull(state, "State");
final String path = normalizePath(pathInZooKeeper);

代码示例来源:origin: org.apache.flink/flink-runtime_2.10

checkNotNull(state, "State");
final String path = normalizePath(pathInZooKeeper);

代码示例来源:origin: org.apache.flink/flink-runtime_2.10

checkNotNull(state, "State");
final String path = normalizePath(pathInZooKeeper);

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