Search in sources :

Example 6 with DAGNode

use of com.twitter.ambrose.model.DAGNode in project ambrose by twitter.

the class AmbroseCascadingGraphConverter method convert.

/**
   * Converts the flowStep that generated from cascading to a Map of DAGNode and its name to be used
   * to build Ambrose Graph.
   */
public void convert() {
    // returns a set of the nodes contained in this graph
    Set vertices = jobsGraph.vertexSet();
    // create ambrose nodes
    for (Object vertex : vertices) {
        BaseFlowStep step = (BaseFlowStep) vertex;
        CascadingJob job = new CascadingJob();
        job.setFeatures(getNodeFeatures(step));
        String name = step.getName();
        DAGNode<CascadingJob> node = new DAGNode<CascadingJob>(name, job);
        dagNamesMap.put(name, node);
    }
    // loop again to set the successors for each node after nodes are created
    for (Object vertex : vertices) {
        BaseFlowStep step = (BaseFlowStep) vertex;
        String name = step.getName();
        DAGNode<CascadingJob> node = dagNamesMap.get(name);
        node.setSuccessors(getNodeSuccessors(vertex));
    }
}
Also used : Set(java.util.Set) BaseFlowStep(cascading.flow.planner.BaseFlowStep) DAGNode(com.twitter.ambrose.model.DAGNode)

Example 7 with DAGNode

use of com.twitter.ambrose.model.DAGNode in project ambrose by twitter.

the class TestHRavenStatsReadService method main.

/**
   * Main method for testing reading from hraven
   */
public static void main(String[] args) throws IOException {
    //cluster!userName!appId!runId!timestamp!flowId
    String workflowId = args[0];
    HRavenStatsReadService service = new HRavenStatsReadService();
    Map<String, DAGNode> dagMap = service.getDagNodeNameMap(workflowId);
    if (dagMap == null) {
        print("No dagNodeNameMap found for " + workflowId);
    } else {
        print(String.format("Found %d dapMap entries", dagMap.size()));
        for (Map.Entry<String, DAGNode> entry : dagMap.entrySet()) {
            DAGNode node = entry.getValue();
            String jobId = node.getJob() != null ? node.getJob().getId() : null;
            print(String.format("%s: nodeName=%s jobId=%s successors=%s", entry.getKey(), node.getName(), jobId, node.getSuccessorNames()));
        }
    }
    List<Event> events = service.getEventsSinceId(workflowId, -1);
    print(String.format("Found %d events", events.size()));
    for (Event event : events) {
        print(String.format("%d %d %s %s", event.getId(), event.getTimestamp(), event.getType(), event.getPayload()));
    }
}
Also used : Event(com.twitter.ambrose.model.Event) DAGNode(com.twitter.ambrose.model.DAGNode) Map(java.util.Map)

Example 8 with DAGNode

use of com.twitter.ambrose.model.DAGNode in project ambrose by twitter.

the class AmbroseCascadingGraphConverter method getNodeSuccessors.

/**
   * Return a Collection of successor nodes of a certain vertex.
   *
   * @param vertex the step or node its successors nodes will be returned.
   * @return collection of successor DAGNodes for each node.
   */
protected Collection<DAGNode<? extends Job>> getNodeSuccessors(Object vertex) {
    Collection<DAGNode<? extends Job>> nodeSuccessors = Sets.newHashSet();
    List successorNodes = Graphs.successorListOf(jobsGraph, vertex);
    for (Object node : successorNodes) {
        BaseFlowStep step = (BaseFlowStep) node;
        String name = step.getName();
        nodeSuccessors.add(dagNamesMap.get(name));
    }
    return nodeSuccessors;
}
Also used : BaseFlowStep(cascading.flow.planner.BaseFlowStep) List(java.util.List) DAGNode(com.twitter.ambrose.model.DAGNode) Job(com.twitter.ambrose.model.Job)

Example 9 with DAGNode

use of com.twitter.ambrose.model.DAGNode in project ambrose by twitter.

the class AmbroseCascadingGraphConverter method getNodeSuccessors.

/**
   * Return a Collection of successor nodes of a certain vertex.
   *
   * @param vertex the step or node its successors nodes will be returned.
   * @return collection of successor DAGNodes for each node.
   */
protected Collection<DAGNode<? extends Job>> getNodeSuccessors(Object vertex) {
    Collection<DAGNode<? extends Job>> nodeSuccessors = Sets.newHashSet();
    List successorNodes = Graphs.successorListOf(jobsGraph, vertex);
    for (Object node : successorNodes) {
        BaseFlowStep step = (BaseFlowStep) node;
        String name = step.getName();
        nodeSuccessors.add(dagNamesMap.get(name));
    }
    return nodeSuccessors;
}
Also used : BaseFlowStep(cascading.flow.planner.BaseFlowStep) List(java.util.List) DAGNode(com.twitter.ambrose.model.DAGNode) Job(com.twitter.ambrose.model.Job)

Example 10 with DAGNode

use of com.twitter.ambrose.model.DAGNode in project ambrose by twitter.

the class AmbroseHivePreHook method run.

@Override
public void run(HookContext hookContext) throws Exception {
    String queryId = AmbroseHiveUtil.getHiveQueryId(hookContext.getConf());
    EmbeddedAmbroseHiveProgressReporter reporter = getEmbeddedProgressReporter();
    HiveDAGTransformer transformer = new HiveDAGTransformer(hookContext);
    //conditional tasks may be filtered out by Hive at runtime. We them as
    //'complete'
    Map<String, DAGNode<Job>> nodeIdToDAGNode = reporter.getNodeIdToDAGNode();
    sendFilteredJobsStatus(queryId, reporter, nodeIdToDAGNode);
    if (transformer.getTotalMRJobs() == 0) {
        return;
    }
    waitBetween(hookContext, reporter, queryId);
    nodeIdToDAGNode = transformer.getNodeIdToDAGNode();
    reporter.setNodeIdToDAGNode(nodeIdToDAGNode);
    reporter.setTotalMRJobs(transformer.getTotalMRJobs());
    reporter.sendDagNodeNameMap(queryId, nodeIdToDAGNode);
}
Also used : DAGNode(com.twitter.ambrose.model.DAGNode) EmbeddedAmbroseHiveProgressReporter(com.twitter.ambrose.hive.reporter.EmbeddedAmbroseHiveProgressReporter)

Aggregations

DAGNode (com.twitter.ambrose.model.DAGNode)12 Job (com.twitter.ambrose.model.Job)5 BaseFlowStep (cascading.flow.planner.BaseFlowStep)4 Event (com.twitter.ambrose.model.Event)3 Map (java.util.Map)3 EmbeddedAmbroseHiveProgressReporter (com.twitter.ambrose.hive.reporter.EmbeddedAmbroseHiveProgressReporter)2 IOException (java.io.IOException)2 List (java.util.List)2 Set (java.util.Set)2 Configuration (org.apache.hadoop.conf.Configuration)2 WorkflowId (com.twitter.ambrose.model.WorkflowId)1 Flow (com.twitter.hraven.Flow)1 MapredWork (org.apache.hadoop.hive.ql.plan.MapredWork)1 RunningJob (org.apache.hadoop.mapred.RunningJob)1 MapReduceOper (org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MapReduceOper)1 OperatorKey (org.apache.pig.impl.plan.OperatorKey)1 MRScriptState (org.apache.pig.tools.pigstats.mapreduce.MRScriptState)1 Test (org.junit.Test)1