本文整理汇总了Java中org.apache.curator.framework.recipes.leader.LeaderSelector.autoRequeue方法的典型用法代码示例。如果您正苦于以下问题:Java LeaderSelector.autoRequeue方法的具体用法?Java LeaderSelector.autoRequeue怎么用?Java LeaderSelector.autoRequeue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.curator.framework.recipes.leader.LeaderSelector
的用法示例。
在下文中一共展示了LeaderSelector.autoRequeue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.apache.curator.framework.recipes.leader.LeaderSelector; //导入方法依赖的package包/类
public void start() throws Exception {
client.start();
leaderSelector = new LeaderSelector(client, SnowflakeConfig.getLeaderPath(), this);
leaderSelector.autoRequeue();
LOGGER.info("start SnowflakeServer... ip: {}", getHostname());
leaderSelector.start();
while (!hasLeader()) {
Thread.sleep(1000);
}
initWorkerId();
ReporterHolder.metrics.register(MetricRegistry.name("SnowflakeServer", "workerId"), new Gauge<Integer>() {
@Override
public Integer getValue() {
return workerId;
}
});
}
示例2: ZooKeeperCommandExecutor
import org.apache.curator.framework.recipes.leader.LeaderSelector; //导入方法依赖的package包/类
private ZooKeeperCommandExecutor(String replicaId, CommandExecutor delegate, CuratorFramework curator,
String zkPath, boolean createPathIfNotExist, File revisionFile,
int numWorkers, int maxLogCount, long minLogAgeMillis) {
super(replicaId);
this.delegate = delegate;
this.revisionFile = revisionFile;
this.curator = curator;
this.zkPath = zkPath;
this.createPathIfNotExist = createPathIfNotExist;
this.maxLogCount = maxLogCount;
this.minLogAgeMillis = minLogAgeMillis;
final ThreadPoolExecutor executor = new ThreadPoolExecutor(
numWorkers, numWorkers,
60, TimeUnit.SECONDS, new LinkedTransferQueue<>(),
new DefaultThreadFactory("zookeeper-command-executor", true));
executor.allowCoreThreadTimeOut(true);
this.executor = executor;
logWatcher = new PathChildrenCache(curator, absolutePath(LOG_PATH), true);
logWatcher.getListenable().addListener(this, MoreExecutors.directExecutor());
oldLogRemover = new OldLogRemover();
leaderSelector = new LeaderSelector(curator, absolutePath(LEADER_PATH), oldLogRemover);
leaderSelector.autoRequeue();
}
示例3: initialize
import org.apache.curator.framework.recipes.leader.LeaderSelector; //导入方法依赖的package包/类
private void initialize() throws Exception {
if (!initialized) {
logger.info("lock");
synchronized (this) {
logger.info("lock acquired");
if (!initialized) {
String zkServers = WeixinConfig.getZKServerList();
logger.info("ZK servers: {}", zkServers);
client = CuratorFrameworkFactory.newClient(zkServers, new ExponentialBackoffRetry(1000, 10));
client.start();
client.blockUntilConnected();
logger.info("ZK connected");
if (WeixinConfig.isLeaderMode()) {
leaderSelector = new LeaderSelector(client, getZkLeaderPath(), this);
leaderSelector.autoRequeue();
leaderSelector.start();
}
value = new DistributedAtomicValue(client, getZkValuePath(), new ExponentialBackoffRetry(1000, 10));
initialized = true;
}
}
}
}
示例4: SchedulerSelector
import org.apache.curator.framework.recipes.leader.LeaderSelector; //导入方法依赖的package包/类
public SchedulerSelector(WorkflowManagerImpl workflowManager, QueueFactory queueFactory, AutoCleanerHolder autoCleanerHolder)
{
this.workflowManager = workflowManager;
this.queueFactory = queueFactory;
this.autoCleanerHolder = autoCleanerHolder;
LeaderSelectorListener listener = new LeaderSelectorListenerAdapter()
{
@Override
public void takeLeadership(CuratorFramework client) throws Exception
{
SchedulerSelector.this.takeLeadership();
}
};
leaderSelector = new LeaderSelector(workflowManager.getCurator(), ZooKeeperConstants.getSchedulerLeaderPath(), listener);
leaderSelector.autoRequeue();
}
示例5: LeaderSelectorClient
import org.apache.curator.framework.recipes.leader.LeaderSelector; //导入方法依赖的package包/类
public LeaderSelectorClient(String zookeeperAddress, String electionPath, String leaderPath,
String name) {
ZOOKEEPER_ADDRESS = zookeeperAddress;
ELECTION_PATH = electionPath;
if (leaderPath.endsWith(Constants.PATH_SEPARATOR)) {
LEADER_FOLDER = leaderPath;
} else {
LEADER_FOLDER = leaderPath + Constants.PATH_SEPARATOR;
}
NAME = name;
// create a leader selector using the given path for management
// all participants in a given leader selection must use the same path
// ExampleClient here is also a LeaderSelectorListener but this isn't required
CuratorFramework client =
CuratorFrameworkFactory.newClient(ZOOKEEPER_ADDRESS, new ExponentialBackoffRetry(
Constants.SECOND_MS, 3));
client.start();
LEADER_SELECTOR = new LeaderSelector(client, ELECTION_PATH, this);
LEADER_SELECTOR.setId(name);
// for most cases you will want your instance to requeue when it relinquishes leadership
LEADER_SELECTOR.autoRequeue();
}
示例6: SimpleClient
import org.apache.curator.framework.recipes.leader.LeaderSelector; //导入方法依赖的package包/类
public SimpleClient(String clientName, CuratorFramework client, String path) {
this.clientName = clientName;
this.client = client;
this.path = path;
leaderSelector = new LeaderSelector(this.client,this.path, this);
leaderSelector.autoRequeue();
// initialize oracle change notification
ctx = new ClassPathXmlApplicationContext("spring-context.xml");
consumer = (DBNotifactionConsumer)ctx.getBean("consumer");
}
示例7: ExampleClient
import org.apache.curator.framework.recipes.leader.LeaderSelector; //导入方法依赖的package包/类
public ExampleClient(CuratorFramework client, String path, String name)
{
this.name = name;
// create a leader selector using the given path for management
// all participants in a given leader selection must use the same path
// ExampleClient here is also a LeaderSelectorListener but this isn't required
leaderSelector = new LeaderSelector(client, path, this);
// for most cases you will want your instance to requeue when it relinquishes leadership
leaderSelector.autoRequeue();
}
示例8: LeaderSelectorClient
import org.apache.curator.framework.recipes.leader.LeaderSelector; //导入方法依赖的package包/类
public LeaderSelectorClient(SchedulerDriver schedulerDriver) {
leaderSelector = new LeaderSelector(schedulerDriver.getCuratorUtils().getClient(), ZKLOCKS + HTTP_SEPERATOR + MESOS_FRAMEWORK_TAG, this);
leaderSelector.autoRequeue();
this.schedulerDriver = schedulerDriver;
}
示例9: init
import org.apache.curator.framework.recipes.leader.LeaderSelector; //导入方法依赖的package包/类
@PostConstruct
public void init() {
leaderSelector = new LeaderSelector(zkClient, props.getMasterNodePath(), this);
leaderSelector.autoRequeue();
}
示例10: electLeader
import org.apache.curator.framework.recipes.leader.LeaderSelector; //导入方法依赖的package包/类
public void electLeader(String ELECTION_PATH, LeaderSelectorListener listener) {
leaderSelector = new LeaderSelector(client, ELECTION_PATH, listener);
leaderSelector.autoRequeue();
leaderSelector.start();
}
示例11: ExampleClient
import org.apache.curator.framework.recipes.leader.LeaderSelector; //导入方法依赖的package包/类
public ExampleClient(CuratorFramework client, String path, String name) {
this.name = name;
leaderSelector = new LeaderSelector(client, path, this);
leaderSelector.autoRequeue();
}