Package com.taobao.top.analysis.node.job

Examples of com.taobao.top.analysis.node.job.JobTaskResult


        {
          try
          {
              long start = System.currentTimeMillis();
            //计算并输出
            JobTaskResult jobTaskResult = statisticsEngine.doAnalysis(jobTasks.get(0));
           
            jobTaskResult.setEfficiency((System.currentTimeMillis() - timer + hardWorkTimer.get())
                /(System.currentTimeMillis()  - nodeStartTimeStamp));
                        if (logger.isInfoEnabled())
                            logger.info("analysis task:" + jobTasks.get(0).getTaskId() + ","
                                    + jobTasks.get(0).getInput() + " uses:" + (System.currentTimeMillis() - start));

                        start = System.currentTimeMillis();
            if (jobTaskResult != null)
            {
              handleTaskResult(jobTasks.get(0),jobTaskResult);
            }
            if (logger.isInfoEnabled())
                            logger.info("send result task:" + jobTasks.get(0).getTaskId() + ","
                                    + jobTasks.get(0).getInput() + " uses:" + (System.currentTimeMillis() - start));
            doingTasks.remove(jobTasks.get(0).getTaskId() + "_" + jobTasks.get(0).getJobEpoch());
          }
          catch (Exception e) {
            logger.error("SlaveNode send result error." + jobTasks.get(0).getJobName(),e);
          }
        }
        else
        {
          final CountDownLatch taskCountDownLatch = new CountDownLatch(jobTasks.size());
         
          final List<JobTaskResult> taskResults = new ArrayList<JobTaskResult>();
         
          //同一个Job的多个Task并行执行
          for(final JobTask jobtask : jobTasks)
          {
            final JobTask j = jobtask;
           
            analysisWorkerThreadPool.execute(
                new Runnable()
                {
                  public void run()
                  {
                    try
                    {
                      taskResults.add(statisticsEngine.doAnalysis(j));
                    }
                    catch (Exception e)
                    {
                      logger.error("analysis error : " + jobtask.getJobName(), e);
                    }
                    finally
                    {
                      taskCountDownLatch.countDown();
                    }
                  }
                }
                );
          }       
         
         
          try
          {
            if (!taskCountDownLatch.await(config.getMaxTaskProcessTime(),TimeUnit.SECONDS)) {
                StringBuilder sb = new StringBuilder("task analysis timeout !tasks:{");
                for(JobTask task : jobTasks) {
                    sb.append(task.getTaskId()).append(",").append(task.getInput()).append(";");
                }
                sb.append("}");
               
              logger.error(sb.toString());
            }
          }
          catch (InterruptedException e) {
            //do nothing
          }
         
          long start = System.currentTimeMillis();
         
          //合并分析结果
          JobTaskResult jobTaskResult = jobResultMerger.merge(jobTasks.get(0), taskResults,false,false);
          // 统计merge, 这里的时间并不科学, 应用线程并发, 时间可能被多计算了
          monitor.mergedTask(System.currentTimeMillis() - start, taskResults.size());
         
          jobTaskResult.setEfficiency((System.currentTimeMillis() - timer + hardWorkTimer.get())
              /(System.currentTimeMillis()  - nodeStartTimeStamp));
          if (logger.isInfoEnabled())
                        logger.info("merge result task:" + jobTasks.get(0).getTaskId() + ","
                                + jobTasks.get(0).getInput() + "," + taskResults.size() + ",uses:" + (System.currentTimeMillis() - start));
         
View Full Code Here


    // 小于批量操作的数目,实际数目
    while (mergeResults.size() < config
        .getMinMergeJobCount()) {
     
      JobTaskResult jt = jobTaskResultsQueue.poll();

      while (jt != null) {
        mergeResults.add(jt.getResults());
        mergeResultCount += jt.getTaskIds().size();
        jt = jobTaskResultsQueue.poll();
      }

     
      JobMergedResult jr = branchResultQueue.poll();
View Full Code Here

          info.append(id).append(" , ");
     
      logger.info(info.toString());
    }
   
    JobTaskResult base = jobTaskResults.get(0);
   
    @SuppressWarnings("unchecked")
    Map<String, Map<String, Object>>[] taskResultContents = new Map[jobTaskResults.size()];
    taskResultContents[0] = base.getResults();
   
    for(int i = 1 ; i < jobTaskResults.size(); i++)
    {
      JobTaskResult mergeResult = jobTaskResults.get(i);
     
      taskResultContents[i] = mergeResult.getResults();
     
      base.addTaskIds(mergeResult.getTaskIds());
      base.addTaskExecuteInfos(mergeResult.getTaskExecuteInfos());
    }
   
    if (needDeepMerge)
      base.setResults(ReportUtil.mergeEntryResult(taskResultContents,
        jobTask.getStatisticsRule().getEntryPool(), needMergeLazy,ReduceType.DEEP_MERGE));
View Full Code Here

TOP

Related Classes of com.taobao.top.analysis.node.job.JobTaskResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.