当前位置: 首页>>代码示例>>Java>>正文


Java LeaderSelector.autoRequeue方法代码示例

本文整理汇总了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;
		}
	});
}
 
开发者ID:mm23504570,项目名称:snowflake,代码行数:22,代码来源:SnowflakeServer.java

示例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();
}
 
开发者ID:line,项目名称:centraldogma,代码行数:27,代码来源:ZooKeeperCommandExecutor.java

示例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;
            }
        }
    }
}
 
开发者ID:huahang,项目名称:weixin-utils,代码行数:24,代码来源:TokenCache.java

示例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();
}
 
开发者ID:NirmataOSS,项目名称:workflow,代码行数:18,代码来源:SchedulerSelector.java

示例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();
}
 
开发者ID:mtunique,项目名称:tachyon-rdma,代码行数:25,代码来源:LeaderSelectorClient.java

示例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");
}
 
开发者ID:srecon,项目名称:OracleToElasticSearch,代码行数:11,代码来源:SimpleClient.java

示例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();
}
 
开发者ID:apache,项目名称:curator,代码行数:13,代码来源:ExampleClient.java

示例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;

}
 
开发者ID:HujiangTechnology,项目名称:Juice,代码行数:7,代码来源:LeaderSelectorClient.java

示例9: init

import org.apache.curator.framework.recipes.leader.LeaderSelector; //导入方法依赖的package包/类
@PostConstruct
public void init() {
  leaderSelector = new LeaderSelector(zkClient, props.getMasterNodePath(), this);
  leaderSelector.autoRequeue();
}
 
开发者ID:Yirendai,项目名称:cicada,代码行数:6,代码来源:ClusterLeaderManager.java

示例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();
}
 
开发者ID:xjdr,项目名称:xio,代码行数:7,代码来源:ZkClient.java

示例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();
}
 
开发者ID:smallnest,项目名称:ZKRecipesByExample,代码行数:6,代码来源:ExampleClient.java


注:本文中的org.apache.curator.framework.recipes.leader.LeaderSelector.autoRequeue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。