Search in sources :

Example 1 with VertexState

use of org.apache.tez.dag.api.event.VertexState in project hive by apache.

the class SourceStateTracker method sourceStateUpdated.

/**
   * Handled notifications on state updates for sources
   * @param sourceName
   * @param sourceState
   */
public synchronized void sourceStateUpdated(String sourceName, VertexState sourceState) {
    SourceInfo sourceInfo = getSourceInfo(sourceName);
    // Update source info if the state is SUCCEEDED
    if (sourceState == VertexState.SUCCEEDED) {
        sourceInfo.numCompletedTasks = getVertexCompletedTaskCount(sourceName);
        sourceInfo.numTasks = getVertexTotalTaskCount(sourceName);
    }
    sourceInfo.lastKnownState = sourceState;
    // to a single node may fail.
    for (LlapNodeId nodeId : sourceInfo.getInterestedNodes()) {
        NodeInfo nodeInfo = nodeInfoMap.get(nodeId);
        VertexState lastStateForNode = nodeInfo.getLastKnownStateForSource(sourceName);
        // Send only if the state has changed.
        if (lastStateForNode != sourceState) {
            nodeInfo.setLastKnownStateForSource(sourceName, sourceState);
            sendStateUpdateToNode(nodeId, sourceName, sourceState);
        }
    }
}
Also used : LlapNodeId(org.apache.hadoop.hive.llap.LlapNodeId) VertexState(org.apache.tez.dag.api.event.VertexState)

Example 2 with VertexState

use of org.apache.tez.dag.api.event.VertexState in project hive by apache.

the class SourceStateTracker method registerTaskForStateUpdates.

/**
   * Used to register a task for state updates. Effectively registers for state updates to go to the specific node.
   * @param host
   * @param port
   * @param inputSpecList
   */
public synchronized void registerTaskForStateUpdates(String host, int port, List<InputSpec> inputSpecList) {
    // Add tracking information. Check if source state already known and send out an update if it is.
    List<String> sourcesOfInterest = getSourceInterestList(inputSpecList);
    if (sourcesOfInterest != null && !sourcesOfInterest.isEmpty()) {
        LlapNodeId nodeId = LlapNodeId.getInstance(host, port);
        NodeInfo nodeInfo = getNodeInfo(nodeId);
        // Set up the data structures, before any notifications come in.
        for (String src : sourcesOfInterest) {
            VertexState oldStateForNode = nodeInfo.getLastKnownStateForSource(src);
            if (oldStateForNode == null) {
                // Not registered for this node.
                // Register and send state if it is successful.
                SourceInfo srcInfo = getSourceInfo(src);
                srcInfo.addNode(nodeId);
                nodeInfo.addSource(src, srcInfo.lastKnownState);
                if (srcInfo.lastKnownState == VertexState.SUCCEEDED) {
                    sendStateUpdateToNode(nodeId, src, srcInfo.lastKnownState);
                }
            } else {
            // Already registered to send updates to this node for the specific source.
            // Nothing to do for now, unless tracking tasks at a later point.
            }
            // Setup for actual notifications, if not already done for a previous task.
            maybeRegisterForVertexUpdates(src);
        }
    } else {
    // Don't need to track anything for this task. No new notifications, etc.
    }
}
Also used : LlapNodeId(org.apache.hadoop.hive.llap.LlapNodeId) VertexState(org.apache.tez.dag.api.event.VertexState)

Aggregations

LlapNodeId (org.apache.hadoop.hive.llap.LlapNodeId)2 VertexState (org.apache.tez.dag.api.event.VertexState)2