Search in sources :

Example 1 with JobsWithIDsOverview

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

the class WebMonitorMessagesTest method testStatusMessages.

@Test
public void testStatusMessages() {
    try {
        final Random rnd = new Random();
        GenericMessageTester.testMessageInstance(RequestJobsOverview.getInstance());
        GenericMessageTester.testMessageInstance(RequestJobsWithIDsOverview.getInstance());
        GenericMessageTester.testMessageInstance(RequestStatusOverview.getInstance());
        GenericMessageTester.testMessageInstance(RequestJobsOverview.getInstance());
        GenericMessageTester.testMessageInstance(GenericMessageTester.instantiateGeneric(RequestJobDetails.class, rnd));
        GenericMessageTester.testMessageInstance(GenericMessageTester.instantiateGeneric(StatusOverview.class, rnd));
        GenericMessageTester.testMessageInstance(GenericMessageTester.instantiateGeneric(JobsOverview.class, rnd));
        GenericMessageTester.testMessageInstance(new JobsWithIDsOverview(randomIds(rnd), randomIds(rnd), randomIds(rnd), randomIds(rnd)));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : RequestStatusOverview(org.apache.flink.runtime.messages.webmonitor.RequestStatusOverview) StatusOverview(org.apache.flink.runtime.messages.webmonitor.StatusOverview) Random(java.util.Random) RequestJobsWithIDsOverview(org.apache.flink.runtime.messages.webmonitor.RequestJobsWithIDsOverview) JobsWithIDsOverview(org.apache.flink.runtime.messages.webmonitor.JobsWithIDsOverview) RequestJobDetails(org.apache.flink.runtime.messages.webmonitor.RequestJobDetails) RequestJobsOverview(org.apache.flink.runtime.messages.webmonitor.RequestJobsOverview) JobsOverview(org.apache.flink.runtime.messages.webmonitor.JobsOverview) Test(org.junit.Test)

Example 2 with JobsWithIDsOverview

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

the class CurrentJobIdsHandler 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(RequestJobsWithIDsOverview.getInstance(), timeout);
            JobsWithIDsOverview overview = (JobsWithIDsOverview) Await.result(future, timeout);
            StringWriter writer = new StringWriter();
            JsonGenerator gen = JsonFactory.jacksonFactory.createGenerator(writer);
            gen.writeStartObject();
            gen.writeArrayFieldStart("jobs-running");
            for (JobID jid : overview.getJobsRunningOrPending()) {
                gen.writeString(jid.toString());
            }
            gen.writeEndArray();
            gen.writeArrayFieldStart("jobs-finished");
            for (JobID jid : overview.getJobsFinished()) {
                gen.writeString(jid.toString());
            }
            gen.writeEndArray();
            gen.writeArrayFieldStart("jobs-cancelled");
            for (JobID jid : overview.getJobsCancelled()) {
                gen.writeString(jid.toString());
            }
            gen.writeEndArray();
            gen.writeArrayFieldStart("jobs-failed");
            for (JobID jid : overview.getJobsFailed()) {
                gen.writeString(jid.toString());
            }
            gen.writeEndArray();
            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 : StringWriter(java.io.StringWriter) RequestJobsWithIDsOverview(org.apache.flink.runtime.messages.webmonitor.RequestJobsWithIDsOverview) JobsWithIDsOverview(org.apache.flink.runtime.messages.webmonitor.JobsWithIDsOverview) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) JobID(org.apache.flink.api.common.JobID)

Aggregations

JobsWithIDsOverview (org.apache.flink.runtime.messages.webmonitor.JobsWithIDsOverview)2 RequestJobsWithIDsOverview (org.apache.flink.runtime.messages.webmonitor.RequestJobsWithIDsOverview)2 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 StringWriter (java.io.StringWriter)1 Random (java.util.Random)1 JobID (org.apache.flink.api.common.JobID)1 JobsOverview (org.apache.flink.runtime.messages.webmonitor.JobsOverview)1 RequestJobDetails (org.apache.flink.runtime.messages.webmonitor.RequestJobDetails)1 RequestJobsOverview (org.apache.flink.runtime.messages.webmonitor.RequestJobsOverview)1 RequestStatusOverview (org.apache.flink.runtime.messages.webmonitor.RequestStatusOverview)1 StatusOverview (org.apache.flink.runtime.messages.webmonitor.StatusOverview)1 Test (org.junit.Test)1