本文整理了Java中org.apache.flink.runtime.util.ZooKeeperUtils
类的一些代码示例,展示了ZooKeeperUtils
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperUtils
类的具体详情如下:
包路径:org.apache.flink.runtime.util.ZooKeeperUtils
类名称:ZooKeeperUtils
[英]Class containing helper functions to interact with ZooKeeper.
[中]类,该类包含与ZooKeeper交互的助手函数。
代码示例来源:origin: apache/flink
@Override
public MesosWorkerStore createMesosWorkerStore(Configuration configuration, Executor executor) throws Exception {
RetrievableStateStorageHelper<MesosWorkerStore.Worker> stateStorageHelper =
ZooKeeperUtils.createFileSystemStateStorage(configuration, "mesosWorkerStore");
ZooKeeperStateHandleStore<MesosWorkerStore.Worker> zooKeeperStateHandleStore = zooKeeperUtilityFactory.createZooKeeperStateHandleStore(
"/workers",
stateStorageHelper);
ZooKeeperSharedValue frameworkId = zooKeeperUtilityFactory.createSharedValue("/frameworkId", new byte[0]);
ZooKeeperSharedCount totalTaskCount = zooKeeperUtilityFactory.createSharedCount("/taskCount", 0);
return new ZooKeeperMesosWorkerStore(
zooKeeperStateHandleStore,
frameworkId,
totalTaskCount);
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.11
@Override
public CheckpointIDCounter createCheckpointIDCounter(JobID jobID) throws Exception {
return ZooKeeperUtils.createCheckpointIDCounter(client, config, jobID);
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.11
@Override
public CompletedCheckpointStore createCheckpointStore(JobID jobId, int maxNumberOfCheckpointsToRetain, ClassLoader userClassLoader)
throws Exception {
return ZooKeeperUtils.createCompletedCheckpoints(client, config, jobId,
maxNumberOfCheckpointsToRetain, executor);
}
代码示例来源:origin: com.alibaba.blink/flink-runtime
/**
* Creates a {@link ZooKeeperLeaderElectionService} instance.
*
* @param client The {@link CuratorFramework} ZooKeeper client to use
* @param configuration {@link Configuration} object containing the configuration values
* @return {@link ZooKeeperLeaderElectionService} instance.
*/
public static ZooKeeperLeaderElectionService createLeaderElectionService(
CuratorFramework client,
Configuration configuration) throws Exception {
return createLeaderElectionService(client, configuration, "");
}
代码示例来源:origin: org.apache.flink/flink-runtime
@Override
public LeaderRetrievalService getResourceManagerLeaderRetriever() {
return ZooKeeperUtils.createLeaderRetrievalService(client, configuration, RESOURCE_MANAGER_LEADER_PATH);
}
代码示例来源:origin: org.apache.flink/flink-runtime
public ZooKeeperUtilityFactory(Configuration configuration, String path) throws Exception {
Preconditions.checkNotNull(path, "path");
root = ZooKeeperUtils.startCuratorFramework(configuration);
root.newNamespaceAwareEnsurePath(path).ensure(root.getZookeeperClient());
facade = root.usingNamespace(ZooKeeperUtils.generateZookeeperPath(root.getNamespace(), path));
}
代码示例来源:origin: com.alibaba.blink/flink-runtime
public static HighAvailabilityServices createAvailableOrEmbeddedServices(
Configuration config,
Executor executor) throws Exception {
HighAvailabilityMode highAvailabilityMode = LeaderRetrievalUtils.getRecoveryMode(config);
switch (highAvailabilityMode) {
case NONE:
return new EmbeddedHaServices(executor);
case FILESYSTEM:
throw new UnsupportedOperationException("to be implemented");
case ZOOKEEPER:
BlobStoreService blobStoreService = BlobUtils.createBlobStoreFromConfig(config);
return new ZooKeeperHaServices(
ZooKeeperUtils.startCuratorFramework(config),
executor,
config,
blobStoreService);
default:
throw new Exception("High availability mode " + highAvailabilityMode + " is not supported.");
}
}
代码示例来源: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.11
@Override
public SubmittedJobGraphStore getSubmittedJobGraphStore() throws Exception {
return ZooKeeperUtils.createSubmittedJobGraphs(client, configuration);
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.11
/**
* Returns the port range for the common {@link RpcService}.
*
* @param configuration to extract the port range from
* @return Port range for the common {@link RpcService}
*/
protected String getRPCPortRange(Configuration configuration) {
if (ZooKeeperUtils.isZooKeeperRecoveryMode(configuration)) {
return configuration.getString(HighAvailabilityOptions.HA_JOB_MANAGER_PORT_RANGE);
} else {
return String.valueOf(configuration.getInteger(JobManagerOptions.PORT));
}
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.10
/**
* Creates a {@link ZooKeeperLeaderElectionService} instance.
*
* @param client The {@link CuratorFramework} ZooKeeper client to use
* @param configuration {@link Configuration} object containing the configuration values
* @return {@link ZooKeeperLeaderElectionService} instance.
*/
public static ZooKeeperLeaderElectionService createLeaderElectionService(
CuratorFramework client,
Configuration configuration) throws Exception {
return createLeaderElectionService(client, configuration, "");
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.11
@Override
public LeaderRetrievalService getDispatcherLeaderRetriever() {
return ZooKeeperUtils.createLeaderRetrievalService(client, configuration, DISPATCHER_LEADER_PATH);
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.11
public ZooKeeperUtilityFactory(Configuration configuration, String path) throws Exception {
Preconditions.checkNotNull(path, "path");
root = ZooKeeperUtils.startCuratorFramework(configuration);
root.newNamespaceAwareEnsurePath(path).ensure(root.getZookeeperClient());
facade = root.usingNamespace(ZooKeeperUtils.generateZookeeperPath(root.getNamespace(), path));
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.10
public static HighAvailabilityServices createAvailableOrEmbeddedServices(
Configuration config,
Executor executor) throws Exception {
HighAvailabilityMode highAvailabilityMode = LeaderRetrievalUtils.getRecoveryMode(config);
switch (highAvailabilityMode) {
case NONE:
return new EmbeddedHaServices(executor);
case ZOOKEEPER:
BlobStoreService blobStoreService = BlobUtils.createBlobStoreFromConfig(config);
return new ZooKeeperHaServices(
ZooKeeperUtils.startCuratorFramework(config),
executor,
config,
blobStoreService);
default:
throw new Exception("High availability mode " + highAvailabilityMode + " is not supported.");
}
}
代码示例来源:origin: org.apache.flink/flink-runtime
/**
* 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
@Override
public SubmittedJobGraphStore getSubmittedJobGraphStore() throws Exception {
return ZooKeeperUtils.createSubmittedJobGraphs(client, configuration);
}
代码示例来源:origin: org.apache.flink/flink-runtime
/**
* Returns the port range for the common {@link RpcService}.
*
* @param configuration to extract the port range from
* @return Port range for the common {@link RpcService}
*/
protected String getRPCPortRange(Configuration configuration) {
if (ZooKeeperUtils.isZooKeeperRecoveryMode(configuration)) {
return configuration.getString(HighAvailabilityOptions.HA_JOB_MANAGER_PORT_RANGE);
} else {
return String.valueOf(configuration.getInteger(JobManagerOptions.PORT));
}
}
代码示例来源:origin: org.apache.flink/flink-runtime
/**
* Creates a {@link ZooKeeperLeaderElectionService} instance.
*
* @param client The {@link CuratorFramework} ZooKeeper client to use
* @param configuration {@link Configuration} object containing the configuration values
* @return {@link ZooKeeperLeaderElectionService} instance.
*/
public static ZooKeeperLeaderElectionService createLeaderElectionService(
CuratorFramework client,
Configuration configuration) throws Exception {
return createLeaderElectionService(client, configuration, "");
}
代码示例来源:origin: org.apache.flink/flink-runtime
@Override
public LeaderRetrievalService getWebMonitorLeaderRetriever() {
return ZooKeeperUtils.createLeaderRetrievalService(client, configuration, REST_SERVER_LEADER_PATH);
}
代码示例来源:origin: org.apache.flink/flink-runtime_2.10
public ZooKeeperUtilityFactory(Configuration configuration, String path) throws Exception {
Preconditions.checkNotNull(path, "path");
root = ZooKeeperUtils.startCuratorFramework(configuration);
root.newNamespaceAwareEnsurePath(path).ensure(root.getZookeeperClient());
facade = root.usingNamespace(ZooKeeperUtils.generateZookeeperPath(root.getNamespace(), path));
}
内容来源于网络,如有侵权,请联系作者删除!