Search in sources :

Example 1 with StatusOverview

use of org.apache.flink.runtime.messages.webmonitor.StatusOverview in project flink by apache.

the class ClusterOverviewHandler method handleJsonRequest.

@Override
public String handleJsonRequest(Map<String, String> pathParams, Map<String, String> queryParams, ActorGateway jobManager) throws Exception {
    // we need no parameters, get all requests
    try {
        if (jobManager != null) {
            Future<Object> future = jobManager.ask(RequestStatusOverview.getInstance(), timeout);
            StatusOverview overview = (StatusOverview) Await.result(future, timeout);
            StringWriter writer = new StringWriter();
            JsonGenerator gen = JsonFactory.jacksonFactory.createGenerator(writer);
            gen.writeStartObject();
            gen.writeNumberField("taskmanagers", overview.getNumTaskManagersConnected());
            gen.writeNumberField("slots-total", overview.getNumSlotsTotal());
            gen.writeNumberField("slots-available", overview.getNumSlotsAvailable());
            gen.writeNumberField("jobs-running", overview.getNumJobsRunningOrPending());
            gen.writeNumberField("jobs-finished", overview.getNumJobsFinished());
            gen.writeNumberField("jobs-cancelled", overview.getNumJobsCancelled());
            gen.writeNumberField("jobs-failed", overview.getNumJobsFailed());
            gen.writeStringField("flink-version", version);
            if (!commitID.equals(EnvironmentInformation.UNKNOWN)) {
                gen.writeStringField("flink-commit", commitID);
            }
            gen.writeEndObject();
            gen.close();
            return writer.toString();
        } else {
            throw new Exception("No connection to the leading JobManager.");
        }
    } catch (Exception e) {
        throw new RuntimeException("Failed to fetch list of all running jobs: " + e.getMessage(), e);
    }
}
Also used : RequestStatusOverview(org.apache.flink.runtime.messages.webmonitor.RequestStatusOverview) StatusOverview(org.apache.flink.runtime.messages.webmonitor.StatusOverview) StringWriter(java.io.StringWriter) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator)

Aggregations

JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 StringWriter (java.io.StringWriter)1 RequestStatusOverview (org.apache.flink.runtime.messages.webmonitor.RequestStatusOverview)1 StatusOverview (org.apache.flink.runtime.messages.webmonitor.StatusOverview)1