本文整理汇总了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());
}
}
}
示例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);
}