Examples of ThriftTaskInProgress


Examples of org.apache.hadoop.thriftfs.jobtracker.api.ThriftTaskInProgress

        }


        public static ThriftTaskInProgress toThrift(TaskInProgress t,
                                                    JobTracker tracker) {
            ThriftTaskInProgress ret = new ThriftTaskInProgress();
            TaskStatus[] sts = null;
            ThriftTaskType type = getTaskInProgressType(t);

            synchronized(t) {
                ret.setComplete(t.isComplete());
                ret.setExecFinishTime(t.getExecFinishTime());
                ret.setExecStartTime(t.getExecStartTime());
                ret.setFailed(t.isFailed());
                ret.setProgress(t.getProgress());
                ret.setStartTime(t.getStartTime());
                ret.setTaskID(toThrift(t.getTIPId()));
                // TODO(henry): This can go away when we go on to > 0.20
                ret.taskID.setTaskType(type);

                // getTaskStatuses copies a collection but is not synchronised :(
                sts = t.getTaskStatuses();
            }

            ret.setCounters(new ThriftGroupList(toThrift(t.getCounters())));

            Map<String,ThriftTaskStatus> statusMap = new HashMap<String,ThriftTaskStatus>();
            Map<String,List<String>> dataMap = new HashMap<String,List<String>>();
            for (TaskStatus ts : sts) {
              ThriftTaskAttemptID id = toThrift(ts.getTaskID());
              id.taskID.setTaskType(type);
              statusMap.put(id.getAsString(), toThrift(ts));
              try {
                  // Atomic copy
                  String[] strDiags = tracker.getTaskDiagnostics(ts.getTaskID());
                  // Thrift does not like null values in maps
                  List<String> diag = (strDiags == null ? new ArrayList<String>() :
                                                          Arrays.asList(strDiags));
                  dataMap.put(id.getAsString(), diag);
              } catch (java.io.IOException e) {
                  // tracker.getTaskDiagnostics is supposed to throw,
                  // but I can't see where it does (and removing the throws clause
                  // doesn't cause a compile failure...), so this is probably
                  // extraneous
                  LOG.warn(e);
                  throw new RuntimeException(e.getMessage());
              }
            }
            ret.setTaskStatuses(statusMap);

            // Takes lock on t
            TaskReport report = t.generateSingleReport();
            ret.setMostRecentState(report.getState());
            ret.setSuccessfulAttempt(toThrift(report.getSuccessfulTaskAttempt()).asString);
            // Because report has a reference to an array from t, we need to synchronize on
            // t to copy it :(
            Collection<TaskAttemptID> attempts = null;
            synchronized(t) {
                attempts =
                    new ArrayList<TaskAttemptID>(report.getRunningTaskAttempts());
            }
            List<String> runningAttempts = new ArrayList<String>(attempts.size());
            for (TaskAttemptID tid : attempts) {
                runningAttempts.add(toThrift(tid).asString);
            }
            ret.setRunningAttempts(runningAttempts);
            ret.setTaskDiagnosticData(dataMap);

            return ret;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.