- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.flink.runtime.zookeeper.ZooKeeperStateHandleStore
类的一些代码示例,展示了ZooKeeperStateHandleStore
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperStateHandleStore
类的具体详情如下:
包路径:org.apache.flink.runtime.zookeeper.ZooKeeperStateHandleStore
类名称:ZooKeeperStateHandleStore
[英]Class which stores state via the provided RetrievableStateStorageHelper and writes the returned state handle to ZooKeeper. The ZooKeeper node can be locked by creating an ephemeral child and only allowing the deletion of the ZooKeeper node if it does not have any children. That way we protect concurrent accesses from different ZooKeeperStateHandleStore instances.
Added state is persisted via RetrievableStateHandle, which in turn are written to ZooKeeper. This level of indirection is necessary to keep the amount of data in ZooKeeper small. ZooKeeper is build for data in the KB range whereas state can grow to multiple MBs.
State modifications require some care, because it is possible that certain failures bring the state handle backend and ZooKeeper out of sync.
ZooKeeper holds the ground truth about state handles, i.e. the following holds:
State handle in ZooKeeper => State handle exists
But not:
State handle exists => State handle in ZooKeeper
There can be lingering state handles when failures happen during operation. They need to be cleaned up manually (see FLINK-2513 about a possible way to overcome this).
[中]类,该类通过提供的RetrievableStateStorageHelper存储状态,并将返回的状态句柄写入ZooKeeper。ZooKeeper节点可以通过创建短暂的子节点来锁定,并且只有在没有子节点时才允许删除ZooKeeper节点。这样我们就可以保护来自不同ZookePerstateHandleStore实例的并发访问。
添加的状态通过RetrievableStateHandle持久化,然后写入ZooKeeper。这种级别的间接寻址对于保持ZooKeeper中的数据量较小是必要的。ZooKeeper是为KB范围内的数据构建的,而state可以增长到多MB。
状态修改需要谨慎,因为某些故障可能会导致状态句柄后端和ZooKeeper不同步。
ZooKeeper持有关于州手柄的基本事实,即以下观点:
State handle in ZooKeeper => State handle exists
但不是:
State handle exists => State handle in ZooKeeper
当操作过程中发生故障时,可能会有延迟状态句柄。它们需要手动清理(请参阅FLINK-2513了解克服此问题的可能方法)。
代码示例来源: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: apache/flink
@Override
public boolean removeWorker(Protos.TaskID taskID) throws Exception {
checkNotNull(taskID, "taskID");
String path = getPathForWorker(taskID);
synchronized (startStopLock) {
verifyIsRunning();
if (workersInZooKeeper.exists(path) == -1) {
LOG.debug("No such worker {} in ZooKeeper.", taskID);
return false;
}
workersInZooKeeper.releaseAndTryRemove(path);
LOG.debug("Removed worker {} from ZooKeeper.", taskID);
return true;
}
}
代码示例来源: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: com.alibaba.blink/flink-runtime
checkNotNull(pathInZooKeeper, "Path in ZooKeeper");
final String path = normalizePath(pathInZooKeeper);
client.create().withMode(CreateMode.EPHEMERAL).forPath(getLockPath(path));
} catch (KeeperException.NodeExistsException ignored) {
if (!success && lock) {
release(path);
代码示例来源: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 all lock nodes of this ZooKeeperStateHandleStores and tries to remove all state nodes which
* are not locked anymore.
*
* <p>The delete operation is executed asynchronously
*
* @throws Exception if the delete operation fails
*/
public void releaseAndTryRemoveAll() throws Exception {
Collection<String> children = getAllPaths();
Exception exception = null;
for (String child : children) {
try {
releaseAndTryRemove('/' + child);
} catch (Exception e) {
exception = ExceptionUtils.firstOrSuppressed(e, exception);
}
}
if (exception != null) {
throw new Exception("Could not properly release and try removing all state nodes.", exception);
}
}
代码示例来源: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.
*
* <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 (expected to start with a '/')
* @throws Exception If the ZooKeeper operation fails
*/
public void releaseAndTryRemove(String pathInZooKeeper) throws Exception {
releaseAndTryRemove(pathInZooKeeper, null);
}
代码示例来源:origin: com.alibaba.blink/flink-runtime
/**
* Releases all lock nodes of this ZooKeeperStateHandleStore.
*
* @throws Exception if the delete operation of a lock file fails
*/
public void releaseAll() throws Exception {
Collection<String> children = getAllPaths();
Exception exception = null;
for (String child: children) {
try {
release(child);
} catch (Exception e) {
exception = ExceptionUtils.firstOrSuppressed(e, exception);
}
}
if (exception != null) {
throw new Exception("Could not properly release all state nodes.", exception);
}
}
代码示例来源:origin: com.alibaba.blink/flink-runtime
checkNotNull(state, "State");
final String path = normalizePath(pathInZooKeeper);
RetrievableStateHandle<T> oldStateHandle = get(path, false);
代码示例来源:origin: org.apache.flink/flink-runtime_2.10
jobGraphRetrievableStateHandle = jobGraphsInZooKeeper.getAndLock(path);
} catch (KeeperException.NoNodeException ignored) {
success = true;
} finally {
if (!success) {
jobGraphsInZooKeeper.release(path);
代码示例来源:origin: org.apache.flink/flink-runtime_2.11
/**
* Creates a {@link ZooKeeperStateHandleStore} instance with the provided arguments.
*
* @param zkStateHandleStorePath specifying the path in ZooKeeper to store the state handles to
* @param stateStorageHelper storing the actual state data
* @param <T> Type of the state to be stored
* @return a ZooKeeperStateHandleStore instance
* @throws Exception if ZooKeeper could not create the provided state handle store path in
* ZooKeeper
*/
public <T extends Serializable> ZooKeeperStateHandleStore<T> createZooKeeperStateHandleStore(
String zkStateHandleStorePath,
RetrievableStateStorageHelper<T> stateStorageHelper) throws Exception {
facade.newNamespaceAwareEnsurePath(zkStateHandleStorePath).ensure(facade.getZookeeperClient());
CuratorFramework stateHandleStoreFacade = facade.usingNamespace(
ZooKeeperUtils.generateZookeeperPath(
facade.getNamespace(),
zkStateHandleStorePath));
return new ZooKeeperStateHandleStore<>(stateHandleStoreFacade, stateStorageHelper);
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.10
final RetrievableStateHandle<T> stateHandle = getAndLock(path);
stateHandles.add(new Tuple2<>(stateHandle, path));
} catch (KeeperException.NoNodeException ignored) {
"corrupted data. Releasing and trying to remove this node.", path, ioException);
releaseAndTryRemove(path);
代码示例来源: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
/**
* Gets the {@link RetrievableStateHandle} stored in the given ZooKeeper node and locks it. A
* locked node cannot be removed by another {@link ZooKeeperStateHandleStore} instance as long
* as this instance remains connected to ZooKeeper.
*
* @param pathInZooKeeper Path to the ZooKeeper node which contains the state handle
* @return The retrieved state handle from the specified ZooKeeper node
* @throws IOException Thrown if the method failed to deserialize the stored state handle
* @throws Exception Thrown if a ZooKeeper operation failed
*/
public RetrievableStateHandle<T> getAndLock(String pathInZooKeeper) throws Exception {
return get(pathInZooKeeper, true);
}
代码示例来源: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
@Override
public Collection<JobID> getJobIds() throws Exception {
Collection<String> paths;
LOG.debug("Retrieving all stored job ids from ZooKeeper under {}.", zooKeeperFullBasePath);
try {
paths = jobGraphsInZooKeeper.getAllPaths();
} catch (Exception e) {
throw new Exception("Failed to retrieve entry paths from ZooKeeperStateHandleStore.", e);
}
List<JobID> jobIds = new ArrayList<>(paths.size());
for (String path : paths) {
try {
jobIds.add(jobIdfromPath(path));
} catch (Exception exception) {
LOG.warn("Could not parse job id from {}. This indicates a malformed path.", path, exception);
}
}
return jobIds;
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.10
final RetrievableStateHandle<T> stateHandle = getAndLock(path);
stateHandles.add(new Tuple2<>(stateHandle, path));
} catch (KeeperException.NoNodeException ignored) {
代码示例来源: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
checkNotNull(pathInZooKeeper, "Path in ZooKeeper");
final String path = normalizePath(pathInZooKeeper);
client.create().withMode(CreateMode.EPHEMERAL).forPath(getLockPath(path));
} catch (KeeperException.NodeExistsException ignored) {
if (!success && lock) {
release(path);
代码示例来源: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);
}
}
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicate: Sample data for IPv6? 除了 wireshark 在其网站上提供的内容之外,是否有可以下
我正在寻找可以集成到现有应用程序中并使用多拖放功能的示例或任何现成的解决方案。我在互联网上找到的大多数解决方案在将多个项目从 ListBox 等控件拖放到另一个 ListBox 时效果不佳。谁能指出我
我是 GATE Embedded 的新手,我尝试了简单的示例并得到了 NoClassDefFoundError。首先我会解释我尝试了什么 在 D:\project\gate-7.0 中下载并提取 Ga
是否有像 Eclipse 中的 SWT 示例那样的多合一 JFace 控件示例?搜索(在 stackoverflow.com 上使用谷歌搜索和搜索)对我没有帮助。 如果它是一个独立的应用程序或 ecl
我找不到任何可以清楚地解释如何通过 .net API(特别是 c#)使用谷歌计算引擎的内容。有没有人可以指点我什么? 附言我知道 API 引用 ( https://developers.google.
最近在做公司的一个项目时,客户需要我们定时获取他们矩阵系统的数据。在与客户进行对接时,提到他们的接口使用的目前不常用的BASIC 认证。天呢,它好不安全,容易被不法人监听,咋还在使用呀。但是没办法呀,
最近在做公司的一个项目时,客户需要我们定时获取他们矩阵系统的数据。在与客户进行对接时,提到他们的接口使用的目前不常用的BASIC 认证。天呢,它好不安全,容易被不法人监听,咋还在使用呀。但是没办法呀,
我正在尝试为我的应用程序设计配置文件格式并选择了 YAML。但是,这(显然)意味着我需要能够定义、解析和验证正确的 YAML 语法! 在配置文件中,必须有一个名为 widgets 的集合/序列。 .这
你能给我一个使用 pysmb 库连接到一些 samba 服务器的例子吗?我读过有类 smb.SMBConnection.SMBConnection(用户名、密码、my_name、remote_name
linux服务器默认通过22端口用ssh协议登录,这种不安全。今天想做限制,即允许部分来源ip连接服务器。 案例目标:通过iptables规则限制对linux服务器的登录。 处理方法:编
我一直在寻找任何 PostProjectAnalysisTask 工作代码示例,但没有看。 This页面指出 HipChat plugin使用这个钩子(Hook),但在我看来它仍然使用遗留的 Po
我发现了 GWT 的 CustomScrollPanel 以及如何自定义滚动条,但我找不到任何示例或如何设置它。是否有任何示例显示正在使用的自定义滚动条? 最佳答案 这是自定义 native 滚动条的
我正在尝试开发一个 Backbone Marionette 应用程序,我需要知道如何以最佳方式执行 CRUD(创建、读取、更新和销毁)操作。我找不到任何解释这一点的资源(仅适用于 Backbone)。
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题?通过 editing this post 添加详细信息并澄清问题. 去年关闭。 Improve this
我需要一个提交多个单独请求的 django 表单,如果没有大量定制,我找不到如何做到这一点的示例。即,假设有一个汽车维修店使用的表格。该表格将列出商店能够进行的所有可能的维修,并且用户将选择他们想要进
我有一个 Multi-Tenancy 应用程序。然而,这个相同的应用程序有 liquibase。我需要在我的所有数据源中运行 liquibase,但是我不能使用这个 Bean。 我的应用程序.yml
我了解有关单元测试的一般思想,并已在系统中发生复杂交互的场景中使用它,但我仍然对所有这些原则结合在一起有疑问。 我们被警告不要测试框架或数据库。好的 UI 设计不适合非人工测试。 MVC 框架不包括一
我正在使用 docjure并且它的 select-columns 函数需要一个列映射。我想获取所有列而无需手动指定。 如何将以下内容生成为惰性无限向量序列 [:A :B :C :D :E ... :A
$condition使用说明和 $param在 findByAttributes在 Yii 在大多数情况下,这就是我使用 findByAttributes 的方式 Person::model()->f
我在 Ubuntu 11.10 上安装了 qtcreator sudo apt-get install qtcreator 安装的版本有:QT Creator 2.2.1、QT 4.7.3 当我启动
我是一名优秀的程序员,十分优秀!