static public ResultSummaryRecord readXml(XmlReader xr) { Util.Assert(xr.Name.Equals(_xml_tag)); bool isVerificationTimeout = false; Boolean.TryParse( xr.GetAttribute(_IsVerificationTimeout_attr), out isVerificationTimeout); xr.ReadToFollowing(Disposition._xml_tag); Disposition d = Disposition.readXml(xr); List <BuildObjectValuePointer> lbovp = new List <BuildObjectValuePointer>(); while (xr.Read()) { if (xr.NodeType == XmlNodeType.EndElement) { Util.Assert(xr.Name.Equals(_xml_tag)); break; } else if (xr.NodeType == XmlNodeType.Element) { if (xr.Name.Equals(BuildObjectValuePointer._xml_tag)) { lbovp.Add(BuildObjectValuePointer.readXml(xr)); } else { throw new Exception("Unknown xml tag " + xr.Name); } } } return(new ResultSummaryRecord(d, lbovp, isVerificationTimeout)); }
//- Fetch an object from the cache and store it in the local //- nuobj tree. //- //- NB BuildObjectValuePointers get stored in untrusted places, so we never //- actually use their RelativePath values in filesystem calls. //- Instead, we require the caller to supply a local BuildObject where //- he expects the ptr to point, and we test for equality, and then //- use the obj value for filesystem operations. void fetchObject(BuildObjectValuePointer ptr, BuildObject obj) { //-Console.WriteLine("ResultCache.fetchObject " + obj); Util.Assert(obj.getRelativePath().Equals(ptr.relativePath)); File.Delete(obj.getFilesystemPath()); this.itemCache.FetchItemToFile(ItemCacheContainer.Objects, ptr.objectHash, obj.getFilesystemPath()); this.knownObjectHash[obj] = ptr.objectHash; }
/// <summary> /// Helper function to read an XML element (not a full document) /// representing a cloud execution report. /// </summary> /// <remarks> /// Note that the XmlReader is expected to be positioned in the XML /// document such that the current node is a report element. /// </remarks> /// <param name="xr">The XmlReader object to read from.</param> /// <returns> /// A new report corresponding to the XML representation read. /// </returns> public static CloudExecutionReport ReadXml(XmlReader xr) { Util.Assert(xr.Name.Equals(CloudExecutionReport.XmlTag)); string versionText = xr.GetAttribute(CloudExecutionReport.XmlVersionAttribute); int version = int.Parse(versionText, CultureInfo.InvariantCulture); string identifier = string.Empty; StatusCode status = StatusCode.Completed; string processingNode = "Unknown Benevolence"; int exitCode = 0; string standardOutput = string.Empty; string standardError = string.Empty; double cpuTime = 0; bool inOutputFileMappings = false; List <BuildObjectValuePointer> outputFileMappings = new List <BuildObjectValuePointer>(); List <BuildObject> outputFiles = new List <BuildObject>(); while (xr.Read()) { if (xr.NodeType == XmlNodeType.Element) { switch (xr.Name) { case XmlIdentifierElement: identifier = xr.ReadElementContentAsString(); break; case XmlStatusElement: status = (StatusCode)Enum.Parse(typeof(StatusCode), xr.ReadElementContentAsString()); break; case XmlProcessingNodeElement: processingNode = xr.ReadElementContentAsString(); break; case XmlExitCodeElement: exitCode = xr.ReadElementContentAsInt(); break; case XmlStandardOutputElement: standardOutput = xr.ReadElementContentAsString(); break; case XmlStandardErrorElement: standardError = xr.ReadElementContentAsString(); break; case XmlCpuTimeElement: cpuTime = xr.ReadElementContentAsDouble(); break; case XmlOutputFileMappingsElement: inOutputFileMappings = true; break; case BuildObjectValuePointer.XmlTag: Util.Assert(inOutputFileMappings); outputFileMappings.Add(BuildObjectValuePointer.ReadXml(xr)); break; } } else if (xr.NodeType == XmlNodeType.EndElement) { if (xr.Name.Equals(CloudExecutionReport.XmlTag)) { break; // All done. } switch (xr.Name) { case XmlOutputFileMappingsElement: inOutputFileMappings = false; break; } } } // REVIEW: Require element presence? Sanity check things here? return(new CloudExecutionReport( version, identifier, status, processingNode, exitCode, standardOutput, standardError, cpuTime, outputFileMappings)); }
/// <summary> /// Helper function to read an XML element (not a full document) /// representing a cloud execution request. /// </summary> /// <remarks> /// Note that the XmlReader is expected to be positioned in the XML /// document such that the current node is a request element. /// </remarks> /// <param name="xr">The XmlReader object to read from.</param> /// <returns> /// A new request corresponding to the XML representation read. /// </returns> public static CloudExecutionRequest ReadXml(XmlReader xr) { Util.Assert(xr.Name.Equals(CloudExecutionRequest.XmlTag)); string versionText = xr.GetAttribute(CloudExecutionRequest.XmlVersionAttribute); int version = int.Parse(versionText, CultureInfo.InvariantCulture); string reportQueue = "reports"; string identifier = string.Empty; Operation operation = Operation.RunExecutable; string executable = string.Empty; string arguments = string.Empty; bool inInputFileMappings = false; List <BuildObjectValuePointer> inputFileMappings = new List <BuildObjectValuePointer>(); bool inOutputFiles = false; List <BuildObject> outputFiles = new List <BuildObject>(); while (xr.Read()) { if (xr.NodeType == XmlNodeType.Element) { switch (xr.Name) { case XmlReportQueueElement: reportQueue = xr.ReadElementContentAsString(); break; case XmlIdentifierElement: identifier = xr.ReadElementContentAsString(); break; case XmlOperationElement: operation = (Operation)Enum.Parse(typeof(Operation), xr.ReadElementContentAsString()); break; case XmlExecutableElement: executable = xr.ReadElementContentAsString(); break; case XmlArgumentsElement: arguments = xr.ReadElementContentAsString(); break; case XmlInputFileMappingsElement: inInputFileMappings = true; break; case BuildObjectValuePointer.XmlTag: Util.Assert(inInputFileMappings); inputFileMappings.Add(BuildObjectValuePointer.ReadXml(xr)); break; case XmlOutputFilesElement: inOutputFiles = true; break; case BuildObject.XmlTag: Util.Assert(inOutputFiles); outputFiles.Add(BuildObject.ReadXml(xr)); break; } } else if (xr.NodeType == XmlNodeType.EndElement) { if (xr.Name.Equals(CloudExecutionRequest.XmlTag)) { break; // All done. } switch (xr.Name) { case XmlInputFileMappingsElement: inInputFileMappings = false; break; case XmlOutputFilesElement: inOutputFiles = false; break; } } } // REVIEW: Require presence of (some/all) elements? Sanity check things here? return(new CloudExecutionRequest( version, reportQueue, identifier, operation, executable, arguments, inputFileMappings, outputFiles)); }