gpt4 book ai didi

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

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

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

ZooKeeperStateHandleStore.addAndLock介绍

[英]Creates a state handle, stores it in ZooKeeper and locks it. A locked node cannot be removed by another ZooKeeperStateHandleStore instance as long as this instance remains connected to ZooKeeper.

Important: This will not store the actual state in ZooKeeper, but create a state handle and store it in ZooKeeper. This level of indirection makes sure that data in ZooKeeper is small.

The operation will fail if there is already an node under the given path
[中]创建状态句柄,将其存储在ZooKeeper中并锁定。锁定的节点不能被另一个ZookePerstateHandleStore实例删除,只要该实例保持与ZooKeeper的连接。
重要提示:这将在ZooKeeper中存储实际状态,而是创建一个状态句柄并将其存储在ZooKeeper中。这种间接级别确保ZooKeeper中的数据很小。
如果给定路径下已有节点,则操作将失败

代码示例

代码示例来源:origin: apache/flink

@Override
public void putWorker(MesosWorkerStore.Worker worker) throws Exception {
  checkNotNull(worker, "worker");
  String path = getPathForWorker(worker.taskID());
  synchronized (startStopLock) {
    verifyIsRunning();
    int currentVersion = workersInZooKeeper.exists(path);
    if (currentVersion == -1) {
      workersInZooKeeper.addAndLock(path, worker);
      LOG.debug("Added {} in ZooKeeper.", worker);
    } else {
      workersInZooKeeper.replace(path, currentVersion, worker);
      LOG.debug("Updated {} in ZooKeeper.", worker);
    }
  }
}

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

/**
 * Synchronously writes the new checkpoints to ZooKeeper and asynchronously removes older ones.
 *
 * @param checkpoint Completed checkpoint to add.
 */
@Override
public void addCheckpoint(final CompletedCheckpoint checkpoint) throws Exception {
  checkNotNull(checkpoint, "Checkpoint");
  final String path = checkpointIdToPath(checkpoint.getCheckpointID());
  // Now add the new one. If it fails, we don't want to loose existing data.
  checkpointsInZooKeeper.addAndLock(path, checkpoint);
  completedCheckpoints.addLast(checkpoint);
  // Everything worked, let's remove a previous checkpoint if necessary.
  while (completedCheckpoints.size() > maxNumberOfCheckpointsToRetain) {
    try {
      removeSubsumed(completedCheckpoints.removeFirst());
    } catch (Exception e) {
      LOG.warn("Failed to subsume the old checkpoint", e);
    }
  }
  LOG.debug("Added {} to {}.", checkpoint, path);
}

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

/**
 * Synchronously writes the new checkpoints to ZooKeeper and asynchronously removes older ones.
 *
 * @param checkpoint Completed checkpoint to add.
 */
@Override
public void addCheckpoint(final CompletedCheckpoint checkpoint) throws Exception {
  checkNotNull(checkpoint, "Checkpoint");
  final String path = checkpointIdToPath(checkpoint.getCheckpointID());
  // Now add the new one. If it fails, we don't want to loose existing data.
  checkpointsInZooKeeper.addAndLock(path, checkpoint);
  completedCheckpoints.addLast(checkpoint);
  // Everything worked, let's remove a previous checkpoint if necessary.
  while (completedCheckpoints.size() > maxNumberOfCheckpointsToRetain) {
    try {
      removeSubsumed(completedCheckpoints.removeFirst());
    } catch (Exception e) {
      LOG.warn("Failed to subsume the old checkpoint", e);
    }
  }
  LOG.debug("Added {} to {}.", checkpoint, path);
}

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

/**
 * Synchronously writes the new checkpoints to ZooKeeper and asynchronously removes older ones.
 *
 * @param checkpoint Completed checkpoint to add.
 */
@Override
public void addCheckpoint(final CompletedCheckpoint checkpoint) throws Exception {
  checkNotNull(checkpoint, "Checkpoint");
  final String path = checkpointIdToPath(checkpoint.getCheckpointID());
  // Now add the new one. If it fails, we don't want to loose existing data.
  checkpointsInZooKeeper.addAndLock(path, checkpoint);
  completedCheckpoints.addLast(checkpoint);
  // Everything worked, let's remove a previous checkpoint if necessary.
  while (completedCheckpoints.size() > maxNumberOfCheckpointsToRetain) {
    final CompletedCheckpoint completedCheckpoint = completedCheckpoints.removeFirst();
    tryRemoveCompletedCheckpoint(completedCheckpoint, CompletedCheckpoint::discardOnSubsume);
  }
  LOG.debug("Added {} to {}.", checkpoint, path);
}

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

/**
 * Synchronously writes the new checkpoints to ZooKeeper and asynchronously removes older ones.
 *
 * @param checkpoint Completed checkpoint to add.
 */
@Override
public void addCheckpoint(final CompletedCheckpoint checkpoint) throws Exception {
  checkNotNull(checkpoint, "Checkpoint");
  final String path = checkpointIdToPath(checkpoint.getCheckpointID());
  // Now add the new one. If it fails, we don't want to loose existing data.
  checkpointsInZooKeeper.addAndLock(path, checkpoint);
  completedCheckpoints.addLast(checkpoint);
  // Everything worked, let's remove a previous checkpoint if necessary.
  while (completedCheckpoints.size() > maxNumberOfCheckpointsToRetain) {
    final CompletedCheckpoint completedCheckpoint = completedCheckpoints.removeFirst();
    tryRemoveCompletedCheckpoint(completedCheckpoint, CompletedCheckpoint::discardOnSubsume);
  }
  LOG.debug("Added {} to {}.", checkpoint, path);
}

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

jobGraphsInZooKeeper.addAndLock(path, jobGraph);

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

jobGraphsInZooKeeper.addAndLock(path, jobGraph);

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

jobGraphsInZooKeeper.addAndLock(path, jobGraph);

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

jobGraphsInZooKeeper.addAndLock(path, jobGraph);

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