/** * 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; }
/** * 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); }