use of org.apache.helix.HelixConstants.ChangeType in project helix by apache.
the class GenericLeaderStandbyModel method onBecomeLeaderFromStandby.
@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());
}
}
}
use of org.apache.helix.HelixConstants.ChangeType in project helix by apache.
the class GenericLeaderStandbyModel method onBecomeStandbyFromLeader.
@Transition(to = "STANDBY", from = "LEADER")
public void onBecomeStandbyFromLeader(Message message, NotificationContext context) {
LOG.info("Become STANDBY from LEADER");
HelixManager manager = context.getManager();
if (manager == null) {
throw new IllegalArgumentException("Require HelixManager in notification conext");
}
Builder keyBuilder = new Builder(manager.getClusterName());
for (ChangeType notificationType : _notificationTypes) {
if (notificationType == ChangeType.LIVE_INSTANCE) {
manager.removeListener(keyBuilder.liveInstances(), _particHolder);
} else if (notificationType == ChangeType.CONFIG) {
manager.removeListener(keyBuilder.instanceConfigs(), _particHolder);
} else if (notificationType == ChangeType.EXTERNAL_VIEW) {
manager.removeListener(keyBuilder.externalViews(), _particHolder);
} else {
LOG.error("Unsupport notificationType:" + notificationType.toString());
}
}
}
Aggregations