/// <exception cref="System.IO.IOException"/> protected override void DoGet(HttpServletRequest req, HttpServletResponse resp) { resp.SetContentType("application/json; charset=UTF-8"); StartupProgress prog = NameNodeHttpServer.GetStartupProgressFromContext(GetServletContext ()); StartupProgressView view = prog.CreateView(); JsonGenerator json = new JsonFactory().CreateJsonGenerator(resp.GetWriter()); try { json.WriteStartObject(); json.WriteNumberField(ElapsedTime, view.GetElapsedTime()); json.WriteNumberField(PercentComplete, view.GetPercentComplete()); json.WriteArrayFieldStart(Phases); foreach (Phase phase in view.GetPhases()) { json.WriteStartObject(); json.WriteStringField(Name, phase.GetName()); json.WriteStringField(Desc, phase.GetDescription()); json.WriteStringField(Status, view.GetStatus(phase).ToString()); json.WriteNumberField(PercentComplete, view.GetPercentComplete(phase)); json.WriteNumberField(ElapsedTime, view.GetElapsedTime(phase)); WriteStringFieldIfNotNull(json, File, view.GetFile(phase)); WriteNumberFieldIfDefined(json, Size, view.GetSize(phase)); json.WriteArrayFieldStart(Steps); foreach (Step step in view.GetSteps(phase)) { json.WriteStartObject(); StepType type = step.GetType(); if (type != null) { json.WriteStringField(Name, type.GetName()); json.WriteStringField(Desc, type.GetDescription()); } json.WriteNumberField(Count, view.GetCount(phase, step)); WriteStringFieldIfNotNull(json, File, step.GetFile()); WriteNumberFieldIfDefined(json, Size, step.GetSize()); json.WriteNumberField(Total, view.GetTotal(phase, step)); json.WriteNumberField(PercentComplete, view.GetPercentComplete(phase, step)); json.WriteNumberField(ElapsedTime, view.GetElapsedTime(phase, step)); json.WriteEndObject(); } json.WriteEndArray(); json.WriteEndObject(); } json.WriteEndArray(); json.WriteEndObject(); } finally { IOUtils.Cleanup(Log, json); } }