- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.samza.zk.ZkLeaderElector.amILeader()
方法的一些代码示例,展示了ZkLeaderElector.amILeader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkLeaderElector.amILeader()
方法的具体详情如下:
包路径:org.apache.samza.zk.ZkLeaderElector
类名称:ZkLeaderElector
方法名:amILeader
暂无
代码示例来源:origin: apache/samza
public void onProcessorChange(List<String> processors) {
if (leaderElector.amILeader()) {
LOG.info("ZkJobCoordinator::onProcessorChange - list of processors changed. List size=" + processors.size());
debounceTimer.scheduleAfterDebounceTime(ON_PROCESSOR_CHANGE, debounceTimeMs, this::doOnProcessorChange);
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.11
public void onProcessorChange(List<String> processors) {
if (leaderElector.amILeader()) {
LOG.info("ZkJobCoordinator::onProcessorChange - list of processors changed. List size=" + processors.size());
debounceTimer.scheduleAfterDebounceTime(ON_PROCESSOR_CHANGE, debounceTimeMs, () -> doOnProcessorChange(processors));
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.12
public void onProcessorChange(List<String> processors) {
if (leaderElector.amILeader()) {
LOG.info("ZkJobCoordinator::onProcessorChange - list of processors changed. List size=" + processors.size());
debounceTimer.scheduleAfterDebounceTime(ON_PROCESSOR_CHANGE, debounceTimeMs, () -> doOnProcessorChange(processors));
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.10
public void onProcessorChange(List<String> processors) {
if (leaderElector.amILeader()) {
LOG.info("ZkJobCoordinator::onProcessorChange - list of processors changed. List size=" + processors.size());
debounceTimer.scheduleAfterDebounceTime(ON_PROCESSOR_CHANGE, debounceTimeMs, () -> doOnProcessorChange(processors));
}
}
代码示例来源:origin: org.apache.samza/samza-core
public void onProcessorChange(List<String> processors) {
if (leaderElector.amILeader()) {
LOG.info("ZkJobCoordinator::onProcessorChange - list of processors changed. List size=" + processors.size());
debounceTimer.scheduleAfterDebounceTime(ON_PROCESSOR_CHANGE, debounceTimeMs, () -> doOnProcessorChange(processors));
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.11
@Override
public void onBarrierCreated(String version) {
// Start the timer for rebalancing
startTime = System.nanoTime();
metrics.barrierCreation.inc();
if (leaderElector.amILeader()) {
debounceTimer.scheduleAfterDebounceTime(barrierAction, (new ZkConfig(config)).getZkBarrierTimeoutMs(), () -> barrier.expire(version));
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.12
@Override
public void onBarrierCreated(String version) {
// Start the timer for rebalancing
startTime = System.nanoTime();
metrics.barrierCreation.inc();
if (leaderElector.amILeader()) {
debounceTimer.scheduleAfterDebounceTime(barrierAction, (new ZkConfig(config)).getZkBarrierTimeoutMs(), () -> barrier.expire(version));
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.10
@Override
public void onBarrierCreated(String version) {
// Start the timer for rebalancing
startTime = System.nanoTime();
metrics.barrierCreation.inc();
if (leaderElector.amILeader()) {
debounceTimer.scheduleAfterDebounceTime(barrierAction, (new ZkConfig(config)).getZkBarrierTimeoutMs(), () -> barrier.expire(version));
}
}
代码示例来源:origin: apache/samza
@Override
public void onBarrierCreated(String version) {
// Start the timer for rebalancing
startTime = System.nanoTime();
metrics.barrierCreation.inc();
if (leaderElector.amILeader()) {
debounceTimer.scheduleAfterDebounceTime(barrierAction, (new ZkConfig(config)).getZkBarrierTimeoutMs(), () -> barrier.expire(version));
}
}
代码示例来源:origin: org.apache.samza/samza-core
@Override
public void onBarrierCreated(String version) {
// Start the timer for rebalancing
startTime = System.nanoTime();
metrics.barrierCreation.inc();
if (leaderElector.amILeader()) {
debounceTimer.scheduleAfterDebounceTime(barrierAction, (new ZkConfig(config)).getZkBarrierTimeoutMs(), () -> barrier.expire(version));
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.10
if (leaderElector.amILeader()) {
LOG.info("Resigning leadership for processorId: " + processorId);
leaderElector.resignLeadership();
代码示例来源:origin: org.apache.samza/samza-core_2.10
public void onBarrierStateChanged(final String version, ZkBarrierForVersionUpgrade.State state) {
LOG.info("JobModel version " + version + " obtained consensus successfully!");
metrics.barrierStateChange.inc();
metrics.singleBarrierRebalancingTime.update(System.nanoTime() - startTime);
if (ZkBarrierForVersionUpgrade.State.DONE.equals(state)) {
debounceTimer.scheduleAfterDebounceTime(barrierAction, 0, () -> {
LOG.info("pid=" + processorId + "new version " + version + " of the job model got confirmed");
// read the new Model
JobModel jobModel = getJobModel();
// start the container with the new model
if (coordinatorListener != null) {
coordinatorListener.onNewJobModel(processorId, jobModel);
}
});
} else {
if (ZkBarrierForVersionUpgrade.State.TIMED_OUT.equals(state)) {
// no-op for non-leaders
// for leader: make sure we do not stop - so generate a new job model
LOG.warn("Barrier for version " + version + " timed out.");
if (leaderElector.amILeader()) {
LOG.info("Leader will schedule a new job model generation");
debounceTimer.scheduleAfterDebounceTime(ON_PROCESSOR_CHANGE, debounceTimeMs, () -> {
// actual actions to do are the same as onProcessorChange
doOnProcessorChange(new ArrayList<>());
});
}
}
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.11
public void onBarrierStateChanged(final String version, ZkBarrierForVersionUpgrade.State state) {
LOG.info("JobModel version " + version + " obtained consensus successfully!");
metrics.barrierStateChange.inc();
metrics.singleBarrierRebalancingTime.update(System.nanoTime() - startTime);
if (ZkBarrierForVersionUpgrade.State.DONE.equals(state)) {
debounceTimer.scheduleAfterDebounceTime(barrierAction, 0, () -> {
LOG.info("pid=" + processorId + "new version " + version + " of the job model got confirmed");
// read the new Model
JobModel jobModel = getJobModel();
// start the container with the new model
if (coordinatorListener != null) {
coordinatorListener.onNewJobModel(processorId, jobModel);
}
});
} else {
if (ZkBarrierForVersionUpgrade.State.TIMED_OUT.equals(state)) {
// no-op for non-leaders
// for leader: make sure we do not stop - so generate a new job model
LOG.warn("Barrier for version " + version + " timed out.");
if (leaderElector.amILeader()) {
LOG.info("Leader will schedule a new job model generation");
debounceTimer.scheduleAfterDebounceTime(ON_PROCESSOR_CHANGE, debounceTimeMs, () -> {
// actual actions to do are the same as onProcessorChange
doOnProcessorChange(new ArrayList<>());
});
}
}
}
}
代码示例来源:origin: apache/samza
if (leaderElector.amILeader()) {
LOG.info("Resigning leadership for processorId: " + processorId);
leaderElector.resignLeadership();
代码示例来源:origin: org.apache.samza/samza-core
public void onBarrierStateChanged(final String version, ZkBarrierForVersionUpgrade.State state) {
LOG.info("JobModel version " + version + " obtained consensus successfully!");
metrics.barrierStateChange.inc();
metrics.singleBarrierRebalancingTime.update(System.nanoTime() - startTime);
if (ZkBarrierForVersionUpgrade.State.DONE.equals(state)) {
debounceTimer.scheduleAfterDebounceTime(barrierAction, 0, () -> {
LOG.info("pid=" + processorId + "new version " + version + " of the job model got confirmed");
// read the new Model
JobModel jobModel = getJobModel();
// start the container with the new model
if (coordinatorListener != null) {
coordinatorListener.onNewJobModel(processorId, jobModel);
}
});
} else {
if (ZkBarrierForVersionUpgrade.State.TIMED_OUT.equals(state)) {
// no-op for non-leaders
// for leader: make sure we do not stop - so generate a new job model
LOG.warn("Barrier for version " + version + " timed out.");
if (leaderElector.amILeader()) {
LOG.info("Leader will schedule a new job model generation");
debounceTimer.scheduleAfterDebounceTime(ON_PROCESSOR_CHANGE, debounceTimeMs, () -> {
// actual actions to do are the same as onProcessorChange
doOnProcessorChange(new ArrayList<>());
});
}
}
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.12
public void onBarrierStateChanged(final String version, ZkBarrierForVersionUpgrade.State state) {
LOG.info("JobModel version " + version + " obtained consensus successfully!");
metrics.barrierStateChange.inc();
metrics.singleBarrierRebalancingTime.update(System.nanoTime() - startTime);
if (ZkBarrierForVersionUpgrade.State.DONE.equals(state)) {
debounceTimer.scheduleAfterDebounceTime(barrierAction, 0, () -> {
LOG.info("pid=" + processorId + "new version " + version + " of the job model got confirmed");
// read the new Model
JobModel jobModel = getJobModel();
// start the container with the new model
if (coordinatorListener != null) {
coordinatorListener.onNewJobModel(processorId, jobModel);
}
});
} else {
if (ZkBarrierForVersionUpgrade.State.TIMED_OUT.equals(state)) {
// no-op for non-leaders
// for leader: make sure we do not stop - so generate a new job model
LOG.warn("Barrier for version " + version + " timed out.");
if (leaderElector.amILeader()) {
LOG.info("Leader will schedule a new job model generation");
debounceTimer.scheduleAfterDebounceTime(ON_PROCESSOR_CHANGE, debounceTimeMs, () -> {
// actual actions to do are the same as onProcessorChange
doOnProcessorChange(new ArrayList<>());
});
}
}
}
}
代码示例来源:origin: apache/samza
if (leaderElector.amILeader()) {
LOG.info("Leader will schedule a new job model generation");
代码示例来源:origin: apache/samza
@VisibleForTesting
StreamPartitionCountMonitor getPartitionCountMonitor() {
StreamMetadataCache streamMetadata = new StreamMetadataCache(systemAdmins, 0, SystemClock.instance());
Set<SystemStream> inputStreamsToMonitor = new TaskConfigJava(config).getAllInputStreams();
return new StreamPartitionCountMonitor(
inputStreamsToMonitor,
streamMetadata,
metrics.getMetricsRegistry(),
new JobConfig(config).getMonitorPartitionChangeFrequency(),
streamsChanged -> {
if (leaderElector.amILeader()) {
debounceTimer.scheduleAfterDebounceTime(ON_PROCESSOR_CHANGE, 0, this::doOnProcessorChange);
}
});
}
代码示例来源:origin: org.apache.samza/samza-core_2.10
if (leaderElector.amILeader()) {
leaderElector.resignLeadership();
代码示例来源:origin: apache/samza
@Test
public void testAmILeader() {
BooleanResult isLeader1 = new BooleanResult();
BooleanResult isLeader2 = new BooleanResult();
// Processor-1
ZkUtils zkUtils1 = getZkUtilsWithNewClient();
ZkLeaderElector leaderElector1 = new ZkLeaderElector("1", zkUtils1, null);
leaderElector1.setLeaderElectorListener(() -> isLeader1.res = true);
// Processor-2
ZkUtils zkUtils2 = getZkUtilsWithNewClient();
ZkLeaderElector leaderElector2 = new ZkLeaderElector("2", zkUtils2, null);
leaderElector2.setLeaderElectorListener(() -> isLeader2.res = true);
// Before Leader Election
Assert.assertFalse(leaderElector1.amILeader());
Assert.assertFalse(leaderElector2.amILeader());
leaderElector1.tryBecomeLeader();
leaderElector2.tryBecomeLeader();
// After Leader Election
Assert.assertTrue(leaderElector1.amILeader());
Assert.assertFalse(leaderElector2.amILeader());
zkUtils1.close();
zkUtils2.close();
}
本文整理了Java中org.apache.samza.zk.ZkLeaderElector.amILeader()方法的一些代码示例,展示了ZkLeaderElector.amILeader()的具体
本文整理了Java中org.apache.samza.zk.ZkLeaderElector.zLog()方法的一些代码示例,展示了ZkLeaderElector.zLog()的具体用法。这些代码示例主
本文整理了Java中org.apache.samza.zk.ZkLeaderElector.()方法的一些代码示例,展示了ZkLeaderElector.()的具体用法。这些代码示例主要来源于Gith
本文整理了Java中org.apache.samza.zk.ZkLeaderElector.resignLeadership()方法的一些代码示例,展示了ZkLeaderElector.resignL
本文整理了Java中org.apache.samza.zk.ZkLeaderElector.setLeaderElectorListener()方法的一些代码示例,展示了ZkLeaderElector
本文整理了Java中org.apache.samza.zk.ZkLeaderElector.getHostName()方法的一些代码示例,展示了ZkLeaderElector.getHostName(
我是一名优秀的程序员,十分优秀!