org.apache.hadoop.hdfs.server.namenode.startupprogress.StartupProgressView Java Examples
The following examples show how to use
org.apache.hadoop.hdfs.server.namenode.startupprogress.StartupProgressView.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StartupProgressMetrics.java From hadoop with Apache License 2.0 | 6 votes |
@Override public void getMetrics(MetricsCollector collector, boolean all) { StartupProgressView prog = startupProgress.createView(); MetricsRecordBuilder builder = collector.addRecord( STARTUP_PROGRESS_METRICS_INFO); builder.addCounter(info("ElapsedTime", "overall elapsed time"), prog.getElapsedTime()); builder.addGauge(info("PercentComplete", "overall percent complete"), prog.getPercentComplete()); for (Phase phase: prog.getPhases()) { addCounter(builder, phase, "Count", " count", prog.getCount(phase)); addCounter(builder, phase, "ElapsedTime", " elapsed time", prog.getElapsedTime(phase)); addCounter(builder, phase, "Total", " total", prog.getTotal(phase)); addGauge(builder, phase, "PercentComplete", " percent complete", prog.getPercentComplete(phase)); } }
Example #2
Source File: StartupProgressMetrics.java From big-c with Apache License 2.0 | 6 votes |
@Override public void getMetrics(MetricsCollector collector, boolean all) { StartupProgressView prog = startupProgress.createView(); MetricsRecordBuilder builder = collector.addRecord( STARTUP_PROGRESS_METRICS_INFO); builder.addCounter(info("ElapsedTime", "overall elapsed time"), prog.getElapsedTime()); builder.addGauge(info("PercentComplete", "overall percent complete"), prog.getPercentComplete()); for (Phase phase: prog.getPhases()) { addCounter(builder, phase, "Count", " count", prog.getCount(phase)); addCounter(builder, phase, "ElapsedTime", " elapsed time", prog.getElapsedTime(phase)); addCounter(builder, phase, "Total", " total", prog.getTotal(phase)); addGauge(builder, phase, "PercentComplete", " percent complete", prog.getPercentComplete(phase)); } }
Example #3
Source File: NameNodeLoader.java From NNAnalytics with Apache License 2.0 | 4 votes |
/** * Sends the loading status as JSON to the parameter HTTP response. Copied from NameNode. * * @param resp the HTTP response * @throws IOException error in fetching loading status */ public void sendLoadingStatus(HttpServletResponse resp) throws IOException { String count = "count"; String elapsedTime = "elapsedTime"; String file = "file"; String name = "name"; String desc = "desc"; String percentComplete = "percentComplete"; String phases = "phases"; String size = "size"; String status = "status"; String steps = "steps"; String total = "total"; StartupProgressView view = NameNode.getStartupProgress().createView(); JsonGenerator json = new JsonFactory().createJsonGenerator(resp.getWriter()).useDefaultPrettyPrinter(); try { json.writeStartObject(); json.writeNumberField(elapsedTime, view.getElapsedTime()); json.writeNumberField(percentComplete, view.getPercentComplete()); json.writeArrayFieldStart(phases); for (Phase phase : 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); for (Step step : view.getSteps(phase)) { json.writeStartObject(); StepType stepType = step.getType(); if (stepType != null) { json.writeStringField(name, stepType.getName()); json.writeStringField(desc, stepType.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.closeStream(json); } }
Example #4
Source File: StartupProgressServlet.java From hadoop with Apache License 2.0 | 4 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { 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(ELAPSED_TIME, view.getElapsedTime()); json.writeNumberField(PERCENT_COMPLETE, view.getPercentComplete()); json.writeArrayFieldStart(PHASES); for (Phase phase: view.getPhases()) { json.writeStartObject(); json.writeStringField(NAME, phase.getName()); json.writeStringField(DESC, phase.getDescription()); json.writeStringField(STATUS, view.getStatus(phase).toString()); json.writeNumberField(PERCENT_COMPLETE, view.getPercentComplete(phase)); json.writeNumberField(ELAPSED_TIME, view.getElapsedTime(phase)); writeStringFieldIfNotNull(json, FILE, view.getFile(phase)); writeNumberFieldIfDefined(json, SIZE, view.getSize(phase)); json.writeArrayFieldStart(STEPS); for (Step step: 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(PERCENT_COMPLETE, view.getPercentComplete(phase, step)); json.writeNumberField(ELAPSED_TIME, view.getElapsedTime(phase, step)); json.writeEndObject(); } json.writeEndArray(); json.writeEndObject(); } json.writeEndArray(); json.writeEndObject(); } finally { IOUtils.cleanup(LOG, json); } }
Example #5
Source File: StartupProgressServlet.java From big-c with Apache License 2.0 | 4 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { 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(ELAPSED_TIME, view.getElapsedTime()); json.writeNumberField(PERCENT_COMPLETE, view.getPercentComplete()); json.writeArrayFieldStart(PHASES); for (Phase phase: view.getPhases()) { json.writeStartObject(); json.writeStringField(NAME, phase.getName()); json.writeStringField(DESC, phase.getDescription()); json.writeStringField(STATUS, view.getStatus(phase).toString()); json.writeNumberField(PERCENT_COMPLETE, view.getPercentComplete(phase)); json.writeNumberField(ELAPSED_TIME, view.getElapsedTime(phase)); writeStringFieldIfNotNull(json, FILE, view.getFile(phase)); writeNumberFieldIfDefined(json, SIZE, view.getSize(phase)); json.writeArrayFieldStart(STEPS); for (Step step: 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(PERCENT_COMPLETE, view.getPercentComplete(phase, step)); json.writeNumberField(ELAPSED_TIME, view.getElapsedTime(phase, step)); json.writeEndObject(); } json.writeEndArray(); json.writeEndObject(); } json.writeEndArray(); json.writeEndObject(); } finally { IOUtils.cleanup(LOG, json); } }