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


Java HelixManager.addConfigChangeListener方法代码示例

本文整理汇总了Java中org.apache.helix.HelixManager.addConfigChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java HelixManager.addConfigChangeListener方法的具体用法?Java HelixManager.addConfigChangeListener怎么用?Java HelixManager.addConfigChangeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.helix.HelixManager的用法示例。


在下文中一共展示了HelixManager.addConfigChangeListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onBecomeLeaderFromStandby

import org.apache.helix.HelixManager; //导入方法依赖的package包/类
@Transition(to = "LEADER", from = "STANDBY")
public void onBecomeLeaderFromStandby(Message message, NotificationContext context)
    throws Exception {
  LOG.info("Become LEADER from STANDBY");
  HelixManager manager = context.getManager();
  if (manager == null) {
    throw new IllegalArgumentException("Require HelixManager in notification conext");
  }
  for (ChangeType notificationType : _notificationTypes) {
    if (notificationType == ChangeType.LIVE_INSTANCE) {
      manager.addLiveInstanceChangeListener(_particHolder);
    } else if (notificationType == ChangeType.CONFIG) {
      manager.addConfigChangeListener(_particHolder);
    } else if (notificationType == ChangeType.EXTERNAL_VIEW) {
      manager.addExternalViewChangeListener(_particHolder);
    } else {
      LOG.error("Unsupport notificationType:" + notificationType.toString());
    }
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:21,代码来源:GenericLeaderStandbyModel.java

示例2: testSpectator

import org.apache.helix.HelixManager; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Test
public void testSpectator() throws Exception {
  Map<String, Integer> stateReachedCounts = Maps.newHashMap();
  HelixManager participant =
      HelixManagerFactory.getZKHelixManager(_clusterName, "localhost_12918",
          InstanceType.PARTICIPANT, ZK_ADDR);
  participant.getStateMachineEngine().registerStateModelFactory("OnlineOffline",
      new MyStateModelFactory(stateReachedCounts));
  participant.connect();

  RoutingTableProvider routingTableProvider = new RoutingTableProvider();
  HelixManager spectator =
      HelixManagerFactory.getZKHelixManager(_clusterName, "spectator", InstanceType.SPECTATOR,
          ZK_ADDR);
  spectator.connect();
  spectator.addConfigChangeListener(routingTableProvider);
  spectator.addExternalViewChangeListener(routingTableProvider);
  Thread.sleep(1000);

  // Now let's stop the ZK server; this should do nothing
  TestHelper.stopZkServer(_zkServer);
  Thread.sleep(1000);

  // Verify routing table still works
  Assert.assertEquals(routingTableProvider.getInstances("resource0", "ONLINE").size(), 1);
  Assert.assertEquals(routingTableProvider.getInstances("resource0", "OFFLINE").size(), 0);
}
 
开发者ID:apache,项目名称:helix,代码行数:29,代码来源:TestCorrectnessOnConnectivityLoss.java


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