Search in sources :

Example 11 with DAGNode

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

the class AmbroseHiveStatPublisher method send.

private void send(String jobIDStr, Map<String, Double> counterValues) {
    EmbeddedAmbroseHiveProgressReporter reporter = getEmbeddedProgressReporter();
    Configuration conf = SessionState.get().getConf();
    String queryId = AmbroseHiveUtil.getHiveQueryId(conf);
    Map<String, DAGNode<Job>> nodeIdToDAGNode = reporter.getNodeIdToDAGNode();
    DAGNode<Job> dagNode = nodeIdToDAGNode.get(nodeId);
    if (dagNode == null) {
        LOG.warn("jobStartedNotification - unrecorgnized operator name found for " + "jobId " + jobIDStr);
        return;
    }
    HiveJob job = (HiveJob) dagNode.getJob();
    // a job has been started
    if (job.getId() == null) {
        // job identifier on GUI
        job.setId(AmbroseHiveUtil.asDisplayId(queryId, jobIDStr, nodeId));
        reporter.addJobIdToNodeId(jobIDStr, nodeId);
        reporter.pushEvent(queryId, new Event.JobStartedEvent(dagNode));
    }
    try {
        boolean isUpdated = updateJobState();
        if (isUpdated && !reporter.getCompletedJobIds().contains(jobIDStr)) {
            Event<DAGNode<? extends Job>> event = null;
            job.setMapReduceJobState(jobProgress);
            if (jobProgress.isComplete()) {
                event = new Event.JobFinishedEvent(dagNode);
                // update reduce progress to 1 if we have no reducers
                int reducers = jobProgress.getTotalReducers();
                if (reducers == 0) {
                    jobProgress.setReduceProgress(1.0f);
                }
                // update job state
                job.setConfiguration(((HiveConf) conf).getAllProperties());
                job.setCounterGroupMap(AmbroseHiveUtil.counterGroupInfoMap(counterValues));
                reporter.addCompletedJobIds(jobIDStr);
                reporter.addJob(job);
            } else {
                event = new Event.JobProgressEvent(dagNode);
            }
            reporter.addJobIdToProgress(jobIDStr, getJobProgress());
            pushWorkflowProgress(queryId, reporter);
            reporter.pushEvent(queryId, event);
        }
    } catch (IOException e) {
        LOG.error("Error getting job info!", e);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) IOException(java.io.IOException) DAGNode(com.twitter.ambrose.model.DAGNode) Event(com.twitter.ambrose.model.Event) RunningJob(org.apache.hadoop.mapred.RunningJob) Job(com.twitter.ambrose.model.Job) EmbeddedAmbroseHiveProgressReporter(com.twitter.ambrose.hive.reporter.EmbeddedAmbroseHiveProgressReporter)

Example 12 with DAGNode

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

the class PigJobTest method doTestRoundTrip.

private void doTestRoundTrip(DAGNode<PigJob> expected) throws IOException {
    String asJson = expected.toJson();
    DAGNode asDAGNodeAgain = DAGNode.fromJson(asJson);
    assertEquals(expected.getName(), asDAGNodeAgain.getName());
    assertNotNull(asDAGNodeAgain.getJob());
    // assert that it's an instance of PigJob
    assertNotNull(asDAGNodeAgain.getJob() instanceof PigJob);
    assertJobEquals(expected.getJob(), (PigJob) asDAGNodeAgain.getJob());
}
Also used : DAGNode(com.twitter.ambrose.model.DAGNode)

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