- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.gobblin.restli.throttling.ZookeeperLeaderElection
类的一些代码示例,展示了ZookeeperLeaderElection
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperLeaderElection
类的具体详情如下:
包路径:org.apache.gobblin.restli.throttling.ZookeeperLeaderElection
类名称:ZookeeperLeaderElection
[英]A LeaderFinder using Zookeeper.
[中]使用Zookeeper的领队。
代码示例来源:origin: apache/incubator-gobblin
private static Optional<LeaderFinder<URIMetadata>> getLeaderFinder(Config config) throws URISyntaxException,
IOException {
if (config.hasPath(ZK_STRING_KEY)) {
Preconditions.checkArgument(config.hasPath(LISTENING_PORT), "Missing required config " + LISTENING_PORT);
Preconditions.checkArgument(config.hasPath(HA_CLUSTER_NAME), "Missing required config " + HA_CLUSTER_NAME);
int port = config.getInt(LISTENING_PORT);
String hostname = config.hasPath(HOSTNAME) ? config.getString(HOSTNAME) : InetAddress.getLocalHost().getCanonicalHostName();
String clusterName = config.getString(HA_CLUSTER_NAME);
String zkString = config.getString(ZK_STRING_KEY);
return Optional.<LeaderFinder<URIMetadata>>of(new ZookeeperLeaderElection<>(zkString, clusterName,
new URIMetadata(new URI("http", null, hostname, port, null, null, null))));
}
return Optional.absent();
}
代码示例来源:origin: apache/incubator-gobblin
private void findLeader() {
ReentrantReadWriteLock.WriteLock lock = this.readWriteLock.writeLock();
lock.lock();
try {
if (this.zooKeeper.checkExists().usingWatcher(new FindLeaderWatcher()).forPath(this.leaderNode) == null) {
determineLeadership();
}
byte[] leaderData = this.zooKeeper.getData().usingWatcher(new FindLeaderWatcher()).forPath(this.leaderNode);
this.leaderMetadata = deserializeMetadata(leaderData);
} catch (KeeperException exc) {
reset();
} catch (Throwable exc) {
log.error("Fatal failure.", exc);
this.fatalFailure = true;
} finally {
lock.unlock();
}
}
代码示例来源:origin: apache/incubator-gobblin
private void determineLeadership() {
ReentrantReadWriteLock.WriteLock lock = this.readWriteLock.writeLock();
lock.lock();
try {
List<String> children = this.zooKeeper.getChildren().forPath(this.leaderElectionNode);
Collections.sort(children);
int idx = children.indexOf(this.nodeId);
if (idx == 0) {
Stat stat = this.zooKeeper.checkExists().forPath(this.leaderNode);
if (stat == null) {
this.zooKeeper.create().forPath(this.leaderNode, serializeMetadata(this.localMetadata));
} else {
this.zooKeeper.setData().forPath(this.leaderNode, serializeMetadata(this.localMetadata));
}
this.isLeader = true;
} else {
this.isLeader = false;
String watchedNode = this.leaderElectionNode + "/" + children.get(idx - 1);
this.zooKeeper.checkExists().usingWatcher(new DetermineLeadershipWatcher()).forPath(watchedNode);
}
findLeader();
} catch (KeeperException exc) {
reset();
} catch (Throwable exc) {
log.error("Fatal failure.", exc);
this.fatalFailure = true;
} finally {
lock.unlock();
}
}
代码示例来源:origin: apache/incubator-gobblin
@Override
protected void startUp() throws Exception {
reset();
}
代码示例来源:origin: apache/incubator-gobblin
private void reset() {
ReentrantReadWriteLock.WriteLock lock = this.readWriteLock.writeLock();
lock.lock();
try {
if (this.zooKeeper != null) {
this.zooKeeper.close();
}
this.zooKeeper = CuratorFrameworkFactory.builder().retryPolicy(new ExponentialBackoffRetry(100, 3))
.connectString(this.zkConnectString).build();
this.zooKeeper.start();
if (!this.zooKeeper.blockUntilConnected(1, TimeUnit.SECONDS)) {
throw new RuntimeException("Could not connect to Zookeeper.");
}
String nodePath = this.zooKeeper.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL_SEQUENTIAL)
.forPath(this.leaderElectionNode + "/p_");
this.nodeId = nodePath.substring(nodePath.lastIndexOf("/") + 1);
determineLeadership();
} catch (Throwable exc) {
throw new RuntimeException(exc);
} finally {
lock.unlock();
}
}
代码示例来源:origin: org.apache.gobblin/gobblin-throttling-service-server
@Override
protected void startUp() throws Exception {
reset();
}
代码示例来源:origin: org.apache.gobblin/gobblin-throttling-service-server
private void reset() {
ReentrantReadWriteLock.WriteLock lock = this.readWriteLock.writeLock();
lock.lock();
try {
if (this.zooKeeper != null) {
this.zooKeeper.close();
}
this.zooKeeper = CuratorFrameworkFactory.builder().retryPolicy(new ExponentialBackoffRetry(100, 3))
.connectString(this.zkConnectString).build();
this.zooKeeper.start();
if (!this.zooKeeper.blockUntilConnected(1, TimeUnit.SECONDS)) {
throw new RuntimeException("Could not connect to Zookeeper.");
}
String nodePath = this.zooKeeper.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL_SEQUENTIAL)
.forPath(this.leaderElectionNode + "/p_");
this.nodeId = nodePath.substring(nodePath.lastIndexOf("/") + 1);
determineLeadership();
} catch (Throwable exc) {
throw new RuntimeException(exc);
} finally {
lock.unlock();
}
}
代码示例来源:origin: org.apache.gobblin/gobblin-throttling-service-server
private void findLeader() {
ReentrantReadWriteLock.WriteLock lock = this.readWriteLock.writeLock();
lock.lock();
try {
if (this.zooKeeper.checkExists().usingWatcher(new FindLeaderWatcher()).forPath(this.leaderNode) == null) {
determineLeadership();
}
byte[] leaderData = this.zooKeeper.getData().usingWatcher(new FindLeaderWatcher()).forPath(this.leaderNode);
this.leaderMetadata = deserializeMetadata(leaderData);
} catch (KeeperException exc) {
reset();
} catch (Throwable exc) {
log.error("Fatal failure.", exc);
this.fatalFailure = true;
} finally {
lock.unlock();
}
}
代码示例来源:origin: org.apache.gobblin/gobblin-throttling-service-server
private void determineLeadership() {
ReentrantReadWriteLock.WriteLock lock = this.readWriteLock.writeLock();
lock.lock();
try {
List<String> children = this.zooKeeper.getChildren().forPath(this.leaderElectionNode);
Collections.sort(children);
int idx = children.indexOf(this.nodeId);
if (idx == 0) {
Stat stat = this.zooKeeper.checkExists().forPath(this.leaderNode);
if (stat == null) {
this.zooKeeper.create().forPath(this.leaderNode, serializeMetadata(this.localMetadata));
} else {
this.zooKeeper.setData().forPath(this.leaderNode, serializeMetadata(this.localMetadata));
}
this.isLeader = true;
} else {
this.isLeader = false;
String watchedNode = this.leaderElectionNode + "/" + children.get(idx - 1);
this.zooKeeper.checkExists().usingWatcher(new DetermineLeadershipWatcher()).forPath(watchedNode);
}
findLeader();
} catch (KeeperException exc) {
reset();
} catch (Throwable exc) {
log.error("Fatal failure.", exc);
this.fatalFailure = true;
} finally {
lock.unlock();
}
}
代码示例来源:origin: org.apache.gobblin/gobblin-throttling-service-server
private static Optional<LeaderFinder<URIMetadata>> getLeaderFinder(Config config) throws URISyntaxException,
IOException {
if (config.hasPath(ZK_STRING_KEY)) {
Preconditions.checkArgument(config.hasPath(LISTENING_PORT), "Missing required config " + LISTENING_PORT);
Preconditions.checkArgument(config.hasPath(HA_CLUSTER_NAME), "Missing required config " + HA_CLUSTER_NAME);
int port = config.getInt(LISTENING_PORT);
String hostname = config.hasPath(HOSTNAME) ? config.getString(HOSTNAME) : InetAddress.getLocalHost().getCanonicalHostName();
String clusterName = config.getString(HA_CLUSTER_NAME);
String zkString = config.getString(ZK_STRING_KEY);
return Optional.<LeaderFinder<URIMetadata>>of(new ZookeeperLeaderElection<>(zkString, clusterName,
new URIMetadata(new URI("http", null, hostname, port, null, null, null))));
}
return Optional.absent();
}
上下文:我正在 javascript tutorial 的任务下编写一个简单的 throttle 。 任务:编写一个像这样工作的 throttle : function f(a) { consol
我有一个带有 React 函数 component 的简单点击事件,我尝试使用 RxJS throttleTime 进行 throttle 。每次单击我都会在 500 毫秒 内 throttle ,但
在 Laravel 6 中,密码代理现在具有以下功能来限制密码重置( https://github.com/laravel/framework/blob/6.x/src/Illuminate/Auth
我有一个事件监听器,我正在尝试用 lodash.throttle 包装它: import throttle from "lodash.throttle" const throttledHandleRe
当我尝试使用 go get 命令安装 throttled 时: go get "github.com/throttled/throttled" 我得到错误: 无法加载包:包 github.com/th
更具体地说,我正在寻找 BlackBerry 6.0 API Animator 类,其构造函数描述为“创建一个以指定帧速率限制 update() 调用的 Animator 对象”。 http://ww
在应用洞察中,在 API->Activity & Errors 下有与“Api Throttling”和“API Throttling Warnings”相关的部分。但是我找不到关于这些部分的含义以及
最近,我们在使用IPP数据服务的应用中,不时遇到这些错误。 ErrorRequest 2012-12-07T10:10:59+00:00 3001 messag
最近,我们在使用IPP数据服务的应用中,不时遇到这些错误。 ErrorRequest 2012-12-07T10:10:59+00:00 3001 messag
我有以下代码: IDisposable subscription = myObservable.Throttle(TimeSpan.FromMilliseconds(50), RxApp.MainTh
我有一个定义 onDragEvent 的 Controller : controller = Em.Object.create( { onDragEvent: function() {
我如何使用 ScheduledThreadPoolExecutor、ScheduledFuture 和 ExecutorCompletionService 的组合来限制接受可变参数?收到来自 Call
我在 trait ThrottlesLogins 中添加了以下方法在 Laravel 5.5 中 protected function TotalRegisterAttemptsLeft($reque
我正在使用 ThrottleRequest 来限制登录尝试。 在 Kendler.php 我有 'throttle' => \Illuminate\Routing\Middleware\Throttl
我可能对此完全疯了,但是YouTube视频的下载/缓冲速率似乎在一开始就更快,并且缓冲点距当前播放的标记越远,缓冲的速度就越慢。 我疯了吗,还是对其他所有人一样? 假设是后者,那么关于它们如何做的任何
我在我的几个页面上设置了无限滚动功能。它工作得很好,但是加载更多项目的 Ajax 调用会进行多次数据库调用,并且每次都必须加载大量图像,并且通常需要几秒钟才能加载。根据我的连接情况,我将其计时在 3
加特林世界的新手,但一位经验丰富的 Loadrunner 用户。我创建了一个示例模拟来运行两个场景,每个场景有 10 个用户,并且希望运行 10 分钟。以下是我的 setup 函数中的内容。但每次我运
我想知道是否有办法执行诸如 System.out.println(); 之类的操作或记录已发生的限制。目前我可以查看是否发生限制的唯一方法是将rejectExecution 设置为True。问题在于,
我正在使用一个 API,它只允许您使用像 request-promise 或 axios 这样的 promise 请求库每秒进行 200 次调用(1000 毫秒)怎么可能你使用 rx.js 去抖/限制
我正在以用户在多线程环境中定义的批量大小写入内存分布式数据库。但是我想限制写入ex的行数。 1000 行/秒。这个要求的原因是我的生产者写得太快而消费者遇到叶内存错误。在批处理记录时是否有任何标准做法
我是一名优秀的程序员,十分优秀!