Search in sources :

Example 21 with EdgeProperty

use of org.apache.tez.dag.api.EdgeProperty in project tez by apache.

the class InputReadyVertexManager method initialize.

@Override
public void initialize() {
    // this will prevent vertex from starting until we notify we are done
    getContext().vertexReconfigurationPlanned();
    Map<String, EdgeProperty> edges = getContext().getInputVertexEdgeProperties();
    // wait for sources and self to start
    numConfiguredSources = 0;
    configured = new AtomicBoolean(false);
    started = new AtomicBoolean(false);
    for (String entry : edges.keySet()) {
        getContext().registerForVertexStateUpdates(entry, EnumSet.of(VertexState.CONFIGURED));
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) EdgeProperty(org.apache.tez.dag.api.EdgeProperty)

Example 22 with EdgeProperty

use of org.apache.tez.dag.api.EdgeProperty in project tez by apache.

the class InputReadyVertexManager method configure.

private void configure() {
    Preconditions.checkState(!configured.get(), "Vertex: " + getContext().getVertexName());
    int numManagedTasks = getContext().getVertexNumTasks(getContext().getVertexName());
    LOG.info("Managing " + numManagedTasks + " tasks for vertex: " + getContext().getVertexName());
    // find out about all input edge types. If there is a custom edge then
    // TODO Until TEZ-1013 we cannot handle custom input formats
    Map<String, EdgeProperty> edges = getContext().getInputVertexEdgeProperties();
    int oneToOneSrcTaskCount = 0;
    numOneToOneEdges = 0;
    for (Map.Entry<String, EdgeProperty> entry : edges.entrySet()) {
        EdgeProperty edgeProp = entry.getValue();
        String srcVertex = entry.getKey();
        int numSrcTasks = getContext().getVertexNumTasks(srcVertex);
        switch(edgeProp.getDataMovementType()) {
            case CUSTOM:
                throw new TezUncheckedException("Cannot handle custom edge");
            case ONE_TO_ONE:
                numOneToOneEdges++;
                if (oneToOneSrcTaskCount == 0) {
                    oneToOneSrcTaskCount = numSrcTasks;
                } else if (oneToOneSrcTaskCount != numSrcTasks) {
                    throw new TezUncheckedException("All 1-1 source vertices must have identical concurrency");
                }
                break;
            case SCATTER_GATHER:
            case BROADCAST:
                break;
            default:
                throw new TezUncheckedException("Unknown edge type: " + edgeProp.getDataMovementType());
        }
        srcVertexInfo.put(srcVertex, new SourceVertexInfo(numSrcTasks, edgeProp));
    }
    if (numOneToOneEdges > 0) {
        Preconditions.checkState(oneToOneSrcTaskCount >= 0, "Vertex: " + getContext().getVertexName());
        if (oneToOneSrcTaskCount != numManagedTasks) {
            numManagedTasks = oneToOneSrcTaskCount;
            // must change parallelism to make them the same
            LOG.info("Update parallelism of vertex: " + getContext().getVertexName() + " to " + oneToOneSrcTaskCount + " to match source 1-1 vertices.");
            getContext().reconfigureVertex(oneToOneSrcTaskCount, null, null);
        }
        oneToOneSrcTasksDoneCount = new int[oneToOneSrcTaskCount];
        oneToOneLocationHints = new TaskLocationHint[oneToOneSrcTaskCount];
    }
    Preconditions.checkState(numManagedTasks >= 0, "Vertex: " + getContext().getVertexName());
    taskIsStarted = new boolean[numManagedTasks];
    // allow scheduling
    configured.set(true);
    getContext().doneReconfiguringVertex();
    trySchedulingPendingCompletions();
}
Also used : TezUncheckedException(org.apache.tez.dag.api.TezUncheckedException) EdgeProperty(org.apache.tez.dag.api.EdgeProperty) Map(java.util.Map) TaskLocationHint(org.apache.tez.dag.api.TaskLocationHint)

Example 23 with EdgeProperty

use of org.apache.tez.dag.api.EdgeProperty in project tez by apache.

the class ShuffleVertexManagerBase method onVertexStarted.

@Override
public synchronized void onVertexStarted(List<TaskAttemptIdentifier> completions) {
    // examine edges after vertex started because until then these may not have been defined
    Map<String, EdgeProperty> inputs = getContext().getInputVertexEdgeProperties();
    for (Map.Entry<String, EdgeProperty> entry : inputs.entrySet()) {
        srcVertexInfo.put(entry.getKey(), createSourceVertexInfo(entry.getValue(), getContext().getVertexNumTasks(getContext().getVertexName())));
        // TODO what if derived class has already called this
        // register for status update from all source vertices
        getContext().registerForVertexStateUpdates(entry.getKey(), EnumSet.of(VertexState.CONFIGURED));
        if (entry.getValue().getDataMovementType() == DataMovementType.SCATTER_GATHER) {
            bipartiteSources++;
        }
    }
    onVertexStartedCheck();
    for (VertexStateUpdate stateUpdate : pendingStateUpdates) {
        handleVertexStateUpdate(stateUpdate);
    }
    pendingStateUpdates.clear();
    // track the tasks in this vertex
    updatePendingTasks();
    for (VertexManagerEvent vmEvent : pendingVMEvents) {
        handleVertexManagerEvent(vmEvent);
    }
    pendingVMEvents.clear();
    LOG.info("OnVertexStarted vertex: {} with {} source tasks and {} pending" + " tasks", getContext().getVertexName(), totalNumBipartiteSourceTasks, totalTasksToSchedule);
    if (completions != null) {
        for (TaskAttemptIdentifier attempt : completions) {
            onSourceTaskCompleted(attempt);
        }
    }
    onVertexStartedDone.set(true);
    // for the special case when source has 0 tasks or min fraction == 0
    processPendingTasks(null);
}
Also used : VertexStateUpdate(org.apache.tez.dag.api.event.VertexStateUpdate) VertexManagerEvent(org.apache.tez.runtime.api.events.VertexManagerEvent) EdgeProperty(org.apache.tez.dag.api.EdgeProperty) ByteString(com.google.protobuf.ByteString) TaskAttemptIdentifier(org.apache.tez.runtime.api.TaskAttemptIdentifier) HashMap(java.util.HashMap) Map(java.util.Map)

Example 24 with EdgeProperty

use of org.apache.tez.dag.api.EdgeProperty in project tez by apache.

the class ShuffleVertexManagerBase method reconfigVertex.

private void reconfigVertex(final int finalTaskParallelism) {
    Map<String, EdgeProperty> edgeProperties = new HashMap<String, EdgeProperty>(bipartiteSources);
    Iterable<Map.Entry<String, SourceVertexInfo>> bipartiteItr = getBipartiteInfo();
    for (Map.Entry<String, SourceVertexInfo> entry : bipartiteItr) {
        String vertex = entry.getKey();
        EdgeProperty oldEdgeProp = entry.getValue().edgeProperty;
        EdgeProperty newEdgeProp = EdgeProperty.create(entry.getValue().newDescriptor, oldEdgeProp.getDataSourceType(), oldEdgeProp.getSchedulingType(), oldEdgeProp.getEdgeSource(), oldEdgeProp.getEdgeDestination());
        edgeProperties.put(vertex, newEdgeProp);
    }
    getContext().reconfigureVertex(finalTaskParallelism, null, edgeProperties);
}
Also used : HashMap(java.util.HashMap) EdgeProperty(org.apache.tez.dag.api.EdgeProperty) ByteString(com.google.protobuf.ByteString) HashMap(java.util.HashMap) Map(java.util.Map)

Example 25 with EdgeProperty

use of org.apache.tez.dag.api.EdgeProperty in project tez by apache.

the class HistoryEventJsonConversion method convertVertexReconfigureDoneEvent.

private static JSONObject convertVertexReconfigureDoneEvent(VertexConfigurationDoneEvent event) throws JSONException {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put(ATSConstants.ENTITY, event.getVertexID().toString());
    jsonObject.put(ATSConstants.ENTITY_TYPE, EntityTypes.TEZ_VERTEX_ID.name());
    // Events
    JSONArray events = new JSONArray();
    JSONObject updateEvent = new JSONObject();
    updateEvent.put(ATSConstants.TIMESTAMP, event.getReconfigureDoneTime());
    updateEvent.put(ATSConstants.EVENT_TYPE, HistoryEventType.VERTEX_CONFIGURE_DONE.name());
    JSONObject eventInfo = new JSONObject();
    eventInfo.put(ATSConstants.NUM_TASKS, event.getNumTasks());
    if (event.getSourceEdgeProperties() != null && !event.getSourceEdgeProperties().isEmpty()) {
        JSONObject updatedEdgeManagers = new JSONObject();
        for (Entry<String, EdgeProperty> entry : event.getSourceEdgeProperties().entrySet()) {
            updatedEdgeManagers.put(entry.getKey(), new JSONObject(DAGUtils.convertEdgeProperty(entry.getValue())));
        }
        eventInfo.put(ATSConstants.UPDATED_EDGE_MANAGERS, updatedEdgeManagers);
    }
    updateEvent.put(ATSConstants.EVENT_INFO, eventInfo);
    events.put(updateEvent);
    jsonObject.put(ATSConstants.EVENTS, events);
    // Other info
    JSONObject otherInfo = new JSONObject();
    jsonObject.put(ATSConstants.OTHER_INFO, otherInfo);
    // TODO add more on all other updated information
    return jsonObject;
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) JSONArray(org.codehaus.jettison.json.JSONArray) EdgeProperty(org.apache.tez.dag.api.EdgeProperty)

Aggregations

EdgeProperty (org.apache.tez.dag.api.EdgeProperty)62 Test (org.junit.Test)31 HashMap (java.util.HashMap)28 ByteString (com.google.protobuf.ByteString)19 VertexStateUpdate (org.apache.tez.dag.api.event.VertexStateUpdate)19 EdgeManagerPluginDescriptor (org.apache.tez.dag.api.EdgeManagerPluginDescriptor)16 VertexManagerPluginContext (org.apache.tez.dag.api.VertexManagerPluginContext)15 VertexLocationHint (org.apache.tez.dag.api.VertexLocationHint)14 Configuration (org.apache.hadoop.conf.Configuration)13 Map (java.util.Map)9 EdgeManagerForTest (org.apache.tez.test.EdgeManagerForTest)7 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)6 StateChangeNotifierForTest (org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)6 Vertex (org.apache.tez.dag.app.dag.Vertex)6 UserPayload (org.apache.tez.dag.api.UserPayload)5 TaskAttemptIdentifier (org.apache.tez.runtime.api.TaskAttemptIdentifier)5 GraceShuffleVertexManagerForTest (org.apache.tez.test.GraceShuffleVertexManagerForTest)5 VertexManagerPluginForTest (org.apache.tez.test.VertexManagerPluginForTest)5 TezUncheckedException (org.apache.tez.dag.api.TezUncheckedException)4 Vertex (org.apache.tez.dag.api.Vertex)4