Package com.linkedin.whiteelephant.parsing

Examples of com.linkedin.whiteelephant.parsing.Task


     
      String line = value.toString();
     
      Job job = null;
      Attempt attempt = null;
      Task task = null;
     
      job = LineParsing.tryParseJob(line);
     
      if (job == null)
      {     
        attempt = LineParsing.tryParseAttempt(line);
       
        if (attempt == null)
        {
          task = LineParsing.tryParseTask(line);
        }
      }
     
      LogData data = new LogData();
      String jobId = null;
     
      data.setCluster(_clusterName);
     
      try
      {
        if (job != null)
        {
          // log lines are sometimes truncated, so data may be missing - just ignore these
          if (job.getJobId() != null)
          {
            jobId = job.getJobId().toString();
            job.setTasks(new ArrayList<Task>());
            data.setEntry(job);
            data.setPath(findInputSplitForJob(jobId,inputSplits));
            context.write(new AvroKey<String>(jobId), new AvroValue<LogData>(data));
          }
        }
        else if (attempt != null)
        {
          // log lines are sometimes truncated, so data may be missing - just ignore these
          if (attempt.getJobId() != null && attempt.getTaskId() != null && attempt.getTaskAttemptId() != null && attempt.getType() != null)
          {
            jobId = attempt.getJobId().toString();
            data.setEntry(attempt);
            data.setPath(findInputSplitForJob(jobId,inputSplits));
            context.write(new AvroKey<String>(jobId), new AvroValue<LogData>(data));
          }
        }
        else if (task != null)
        {
          // log lines are sometimes truncated, so data may be missing - just ignore these
          if (task.getJobId() != null && task.getTaskId() != null && task.getType() != null)
          {
            jobId = task.getJobId().toString();
            task.setAttempts(new ArrayList<Attempt>());
            data.setEntry(task);
            data.setPath(findInputSplitForJob(jobId,inputSplits));
            context.write(new AvroKey<String>(jobId), new AvroValue<LogData>(data));
          }
        }
View Full Code Here


        if (taskId == null)
        {
          throw new RuntimeException("Missing task ID");
        }
       
        Task task = null;
       
        if (!taskIdToTask.containsKey(taskId))
        {
          taskIdToTask.put(taskId,new Task());
        }
       
        task = taskIdToTask.get(taskId);
       
        if (task.getAttempts() == null)
        {
          task.setAttempts(new ArrayList<Attempt>());
        }
       
        if (entry.getTaskId() != null)
        {
          task.setTaskId(entry.getTaskId());
        }

        if (entry.getTaskStatus() != null)
        {
          task.setTaskStatus(entry.getTaskStatus());
        }
       
        if (entry.getStartTime() != null)
        {
          task.setStartTime(entry.getStartTime());
        }
       
        if (entry.getFinishTime() != null)
        {
          task.setFinishTime(entry.getFinishTime());
        }
       
        if (entry.getJobId() != null)
        {
          task.setJobId(entry.getJobId());
        }
       
        if (entry.getType() != null)
        {
          task.setType(entry.getType());
        }
      }
     
      List<Task> tasks = new ArrayList<Task>(taskIdToTask.values());
     
View Full Code Here

      }
     
      // collect each of the attempts and add to the corresponding task
      for (Attempt attempt : filteredAttempts)
      {
        Task task = taskIdToTask.get(attempt.getTaskId().toString());
       
        if (task == null)
        {
          throw new RuntimeException("Could not find task");
        }
       
        if (task.getAttempts() == null)
        {
          task.setAttempts(new ArrayList<Attempt>());
        }
       
        task.getAttempts().add(attempt);
      }
     
      for (Task task : job.getTasks())
      {
        if (task.getAttempts().size() > 0)
        {
          // sort attempts by start time
          Collections.sort(task.getAttempts(),new Comparator<Attempt>() {
            @Override
            public int compare(Attempt o1, Attempt o2)
            {
              return o1.getStartTime().compareTo(o2.getStartTime());
            }
          });
         
          boolean foundSuccess = false;
         
          // For simplicity we'll say that all attempts which are not successful are excess.
          // In reality there could be some overlapping successful attempts, but we'll ignore this
          // because it should be rare.
         
          for (Attempt attempt : task.getAttempts())
          {
            if (attempt.getStartTime() == 0 || attempt.getFinishTime() == 0)
            {
              attempt.setStartTime(null);
              attempt.setFinishTime(null);
              //context.getCounter("Job Parsing", "startTime or finishTime zero").increment(1);
            }
            else
            {
              ((DerivedAttemptData)attempt.getDerived()).setMinutes((attempt.getFinishTime() - attempt.getStartTime())/1000.0/60.0);
            }
           
            if (attempt.getCounters().containsKey(CPU_MILLISECONDS))
            {
              attempt.getDerived().setCpuMinutes(attempt.getCounters().get(CPU_MILLISECONDS)/1000.0/60.0);
            }
           
            if (attempt.getTaskStatus().equals("SUCCESS"))
            {
              ((DerivedAttemptData)attempt.getDerived()).setExcess(false);
              foundSuccess = true;
            }
            else
            {
              ((DerivedAttemptData)attempt.getDerived()).setExcess(true);
            }
          }
         
          // If none were successful then mark the first attempt as the non-excess one.
          if (task.getAttempts().size() > 0 && !foundSuccess)
          {
            ((DerivedAttemptData)task.getAttempts().get(0).getDerived()).setExcess(false);
          }
         
          // sort by task attempt id
          Collections.sort(task.getAttempts(),new Comparator<Attempt>() {
            @Override
            public int compare(Attempt o1, Attempt o2)
            {
              return o1.getTaskAttemptId().toString().compareTo(o2.getTaskAttemptId().toString());
            }
View Full Code Here

  public static Task tryParseTask(String line)
  {
    // these mess with our pattern matching
    line = line.replace("\\\"", "");
   
    Task task = null;
   
    Matcher m = taskLinePattern.matcher(line);
   
    if (m.matches())
    {
      task = new Task();
     
      task.setType(TaskType.valueOf(m.group(2).toUpperCase()));
     
      Matcher matcher = parameterPattern.matcher(line);
     
      while (matcher.find())
      {
        String name = matcher.group(1);
        String value = matcher.group(2);
        maybeSetTaskParam(task,name,value);
      }
     
      if (task.getTaskId() != null)
      {
        Matcher taskMatcher = taskPattern.matcher(task.getTaskId());
       
        if (taskMatcher.matches())
        {
          String jobId = String.format("job_%s",taskMatcher.group(1));
          task.setJobId(jobId);
        }
        else
        {
          System.out.println("Could not match task ID for " + task.getTaskId());
          System.out.println("line: " + line);
        }
      }
      else
      {
View Full Code Here

TOP

Related Classes of com.linkedin.whiteelephant.parsing.Task

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.