/** * Returns a list of Tasks from the thrift version. */ static List<Task> fromThrift(List<TTask> list) { List<Task> result = new ArrayList<Task>(); for (TTask l: list) { result.add(new Task(l)); } return result; }
@Override public void readFields(DataInput in) throws IOException { task_ = Task.deserialize(in); int numWorkers = in.readInt(); workerAddresses_ = new ArrayList<NetworkAddress>(); for (int i = 0; i < numWorkers; ++i) { int hostnameLen = in.readInt(); byte[] hostnameBuffer = new byte[hostnameLen]; in.readFully(hostnameBuffer); int port = in.readInt(); workerAddresses_.add(new NetworkAddress(new String(hostnameBuffer), port)); } } }
@Override public void write(DataOutput out) throws IOException { task_.serialize(out); out.writeInt(workerAddresses_.size()); for (NetworkAddress n: workerAddresses_) { out.writeInt(n.hostname.length()); out.writeBytes(n.hostname); out.writeInt(n.port); } }
/** * Set tag for the task. */ private void setTag(Task task, Configuration config) { String tag = System.getenv(CONTAINER_ID); if (tag == null || tag.isEmpty()) { tag = "MR-"; if (config.get(JOB_NAME) != null) { tag += config.get(JOB_NAME); } } task.setTag(tag); } }
public PlanRequestResult(TPlanRequestResult result) { tasks = Task.fromThrift(result.tasks); schema = new Schema(result.schema); requestId = new UniqueId(result.request_id); hosts = NetworkAddress.fromThrift(result.hosts); warnings = LogMessage.fromThrift(result.warnings); } }
/** * Deserializes Task from 'in' */ public static Task deserialize(DataInput in) throws IOException { int numLocalHosts = in.readInt(); List<NetworkAddress> localHosts = new ArrayList<NetworkAddress>(); for (int i = 0; i < numLocalHosts; ++i) { int hostnameLen = in.readInt(); byte[] hostnameBuffer = new byte[hostnameLen]; in.readFully(hostnameBuffer); int port = in.readInt(); localHosts.add(new NetworkAddress(new String(hostnameBuffer), port)); } int taskLen = in.readInt(); byte[] taskBuffer = new byte[taskLen]; in.readFully(taskBuffer); UniqueId id = new UniqueId(in.readLong(), in.readLong()); boolean resultsOrdered = in.readBoolean(); long taskSize = in.readLong(); int tagLen = in.readInt(); byte[] tagBuffer = new byte[tagLen]; in.readFully(tagBuffer); String tag = new String(tagBuffer); return new Task(localHosts, taskBuffer, id, resultsOrdered, taskSize, tag); }