Search in sources :

Example 16 with NotificationContext

use of org.apache.helix.NotificationContext in project ambry by linkedin.

the class MockHelixManager method triggerConfigChangeNotification.

void triggerConfigChangeNotification(boolean init) {
    if (!isConnected) {
        return;
    }
    NotificationContext notificationContext = new NotificationContext(this);
    if (init) {
        notificationContext.setType(NotificationContext.Type.INIT);
    }
    instanceConfigChangeListeners.forEach(listener -> listener.onInstanceConfigChange(mockAdmin.getInstanceConfigs(clusterName), notificationContext));
}
Also used : NotificationContext(org.apache.helix.NotificationContext)

Example 17 with NotificationContext

use of org.apache.helix.NotificationContext in project ambry by linkedin.

the class MockHelixManager method triggerLiveInstanceNotification.

/**
 * Trigger a live instance change notification.
 */
void triggerLiveInstanceNotification(boolean init) {
    List<LiveInstance> liveInstances = new ArrayList<>();
    for (String instance : mockAdmin.getUpInstances()) {
        liveInstances.add(new LiveInstance(instance));
    }
    NotificationContext notificationContext = new NotificationContext(this);
    if (init) {
        notificationContext.setType(NotificationContext.Type.INIT);
    }
    liveInstanceChangeListener.onLiveInstanceChange(liveInstances, notificationContext);
}
Also used : NotificationContext(org.apache.helix.NotificationContext) LiveInstance(org.apache.helix.model.LiveInstance) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 18 with NotificationContext

use of org.apache.helix.NotificationContext in project ambry by linkedin.

the class MockHelixManager method triggerIdealStateNotification.

void triggerIdealStateNotification(boolean init) throws InterruptedException {
    NotificationContext notificationContext = new NotificationContext(this);
    if (init) {
        notificationContext.setType(NotificationContext.Type.INIT);
    }
    idealStateChangeListener.onIdealStateChange(mockAdmin.getIdealStates(), notificationContext);
}
Also used : NotificationContext(org.apache.helix.NotificationContext)

Example 19 with NotificationContext

use of org.apache.helix.NotificationContext in project pinot by linkedin.

the class PinotRealtimeSegmentManager method start.

public void start(ControllerMetrics controllerMetrics) {
    _controllerMetrics = controllerMetrics;
    LOGGER.info("Starting realtime segments manager, adding a listener on the property store table configs path.");
    String zkUrl = _pinotHelixResourceManager.getHelixZkURL();
    _zkClient = new ZkClient(zkUrl, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT);
    _zkClient.setZkSerializer(new ZNRecordSerializer());
    _zkClient.waitUntilConnected();
    // Subscribe to any data/child changes to property
    _zkClient.subscribeChildChanges(_tableConfigPath, this);
    _zkClient.subscribeDataChanges(_tableConfigPath, this);
    // Subscribe to leadership changes
    _pinotHelixResourceManager.getHelixZkManager().addControllerListener(new ControllerChangeListener() {

        @Override
        public void onControllerChange(NotificationContext changeContext) {
            processPropertyStoreChange(CONTROLLER_LEADER_CHANGE);
        }
    });
    // Setup change listeners for already existing tables, if any.
    processPropertyStoreChange(_tableConfigPath);
}
Also used : ZkClient(org.apache.helix.manager.zk.ZkClient) NotificationContext(org.apache.helix.NotificationContext) ControllerChangeListener(org.apache.helix.ControllerChangeListener) ZNRecordSerializer(org.apache.helix.manager.zk.ZNRecordSerializer)

Example 20 with NotificationContext

use of org.apache.helix.NotificationContext in project pinot by linkedin.

the class SegmentStatusChecker method start.

/**
   * Starts the segment status checker.
   */
public void start(ControllerMetrics metricsRegistry) {
    if (_segmentStatusIntervalSeconds == -1) {
        return;
    }
    _metricsRegistry = metricsRegistry;
    setStatusToDefault();
    // Subscribe to leadership changes
    _pinotHelixResourceManager.getHelixZkManager().addControllerListener(new ControllerChangeListener() {

        @Override
        public void onControllerChange(NotificationContext changeContext) {
            processLeaderChange(CONTROLLER_LEADER_CHANGE);
        }
    });
}
Also used : NotificationContext(org.apache.helix.NotificationContext) ControllerChangeListener(org.apache.helix.ControllerChangeListener)

Aggregations

NotificationContext (org.apache.helix.NotificationContext)35 Message (org.apache.helix.model.Message)11 Test (org.testng.annotations.Test)11 HelixManager (org.apache.helix.HelixManager)10 HelixException (org.apache.helix.HelixException)9 Date (java.util.Date)6 ArrayList (java.util.ArrayList)4 ZkNoNodeException (org.I0Itec.zkclient.exception.ZkNoNodeException)4 ControllerChangeListener (org.apache.helix.ControllerChangeListener)4 LiveInstance (org.apache.helix.model.LiveInstance)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Set (java.util.Set)3 HelixTimerTask (org.apache.helix.HelixTimerTask)3 PropertyKey (org.apache.helix.PropertyKey)3 GenericHelixController (org.apache.helix.controller.GenericHelixController)3 DistributedLeaderElection (org.apache.helix.manager.zk.DistributedLeaderElection)3 MessageHandler (org.apache.helix.messaging.handling.MessageHandler)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ResultSet (java.sql.ResultSet)2