Search in sources :

Example 1 with IClusterEventsSubscriber

use of org.apache.asterix.common.api.IClusterEventsSubscriber in project asterixdb by apache.

the class ClusterLifecycleListener method notifyNodeJoin.

@Override
public void notifyNodeJoin(String nodeId, Map<IOption, Object> ncConfiguration) throws HyracksException {
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("NC: " + nodeId + " joined");
    }
    ClusterStateManager.INSTANCE.addNCConfiguration(nodeId, ncConfiguration);
    //if metadata node rejoining, we need to rebind the proxy connection when it is active again.
    if (!ClusterStateManager.INSTANCE.isMetadataNodeActive()) {
        MetadataManager.INSTANCE.rebindMetadataNode();
    }
    Set<String> nodeAddition = new HashSet<>();
    nodeAddition.add(nodeId);
    updateProgress(ClusterEventType.NODE_JOIN, nodeAddition);
    Set<IClusterEventsSubscriber> subscribers = ClusterManagerProvider.getClusterManager().getRegisteredClusterEventSubscribers();
    Set<IClusterManagementWork> work = new HashSet<>();
    for (IClusterEventsSubscriber sub : subscribers) {
        Set<IClusterManagementWork> workRequest = sub.notifyNodeJoin(nodeId);
        work.addAll(workRequest);
    }
    if (!work.isEmpty()) {
        executeWorkSet(work);
    }
}
Also used : IClusterEventsSubscriber(org.apache.asterix.common.api.IClusterEventsSubscriber) IClusterManagementWork(org.apache.asterix.common.api.IClusterManagementWork) HashSet(java.util.HashSet)

Example 2 with IClusterEventsSubscriber

use of org.apache.asterix.common.api.IClusterEventsSubscriber in project asterixdb by apache.

the class ClusterLifecycleListener method notifyNodeFailure.

@Override
public void notifyNodeFailure(Collection<String> deadNodeIds) throws HyracksException {
    for (String deadNode : deadNodeIds) {
        if (LOGGER.isLoggable(Level.INFO)) {
            LOGGER.info("NC: " + deadNode + " left");
        }
        ClusterStateManager.INSTANCE.removeNCConfiguration(deadNode);
        //if metadata node failed, we need to rebind the proxy connection when it is active again
        if (!ClusterStateManager.INSTANCE.isMetadataNodeActive()) {
            MetadataManager.INSTANCE.rebindMetadataNode();
        }
    }
    updateProgress(ClusterEventType.NODE_FAILURE, deadNodeIds);
    Set<IClusterEventsSubscriber> subscribers = ClusterManagerProvider.getClusterManager().getRegisteredClusterEventSubscribers();
    Set<IClusterManagementWork> work = new HashSet<>();
    for (IClusterEventsSubscriber sub : subscribers) {
        Set<IClusterManagementWork> workRequest = sub.notifyNodeFailure(deadNodeIds);
        work.addAll(workRequest);
    }
    if (!work.isEmpty()) {
        executeWorkSet(work);
    }
}
Also used : IClusterEventsSubscriber(org.apache.asterix.common.api.IClusterEventsSubscriber) IClusterManagementWork(org.apache.asterix.common.api.IClusterManagementWork) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)2 IClusterEventsSubscriber (org.apache.asterix.common.api.IClusterEventsSubscriber)2 IClusterManagementWork (org.apache.asterix.common.api.IClusterManagementWork)2