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());
}
}
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);
}
}
Aggregations