コード例 #1
0
 @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
0
 @Transition(to = "STANDBY", from = "LEADER")
 public void onBecomeStandbyFromLeader(Message message, NotificationContext context) {
   LOG.info("Become STANDBY from LEADER");
   HelixManager manager = context.getManager();
   manager.removeListener(_particHolder);
 }