Commit 52893e0a authored by Daniel Eggert's avatar Daniel Eggert
Browse files

added job details rest queries to flink api

parent d8a32c6f
......@@ -11,6 +11,8 @@ import java.net.URL;
import com.fasterxml.jackson.databind.ObjectMapper;
import de.potsdam.gfz.flink.api.Config;
import de.potsdam.gfz.flink.api.JobDetails;
import de.potsdam.gfz.flink.api.JobOverview;
import de.potsdam.gfz.flink.api.Jobs;
import de.potsdam.gfz.flink.api.Overview;
......@@ -44,6 +46,17 @@ public class FlinkAPI {
return mapper.readValue(getStream("GET", "jobs"), Jobs.class);
}
public JobOverview getJobOverview() throws IOException, FlinkAPIError {
return mapper.readValue(getStream("GET", "joboverview"), JobOverview.class);
}
public JobDetails getJobDetails(String jid) throws IOException, FlinkAPIError {
if (jid == null || jid.isEmpty()) {
throw new FlinkAPIError("Null or empty flink job id (jid) given!");
}
return mapper.readValue(getStream("GET", "jobs/" + jid), JobDetails.class);
}
private InputStream getStream(String method, String request) throws IOException, FlinkAPIError {
URL url = new URL(this.url + "/" + request);
......
/**
*
*/
package de.potsdam.gfz.flink.api;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* FlinkAPI Job POJO<br>
* <br>
* small summary of a jobs status
*
* @author Daniel Eggert (daniel.eggert@gfz-potsdam.de)
*
*/
public class Job {
public String jid;
public String name;
public String state;
@JsonProperty("start-time")
public long startTime;
@JsonProperty("end-time")
public long endTime;
@JsonProperty("duration")
public long duration;
@JsonProperty("last-modification")
public long lastModification;
public JobTasks tasks;
}
/**
*
*/
package de.potsdam.gfz.flink.api;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* FlinkAPI JobDetails POJO<br>
* <br>
* Summary of one job, listing dataflow plan, status, timestamps of state transitions, aggregate information for each vertex (operator).
*
* @author Daniel Eggert (daniel.eggert@gfz-potsdam.de)
*
*/
public class JobDetails extends Job {
/**
* FlinkAPI Timestamps POJO<br>
* <br>
* small summary of a job timestamps
*
* @author Daniel Eggert (daniel.eggert@gfz-potsdam.de)
*
*/
public static class Timestamps {
public long CREATED;
public long RUNNING;
public long FAILING;
public long FAILED;
public long CANCELLING;
public long CANCELED;
public long FINISHED;
public long RESTARTING;
}
public boolean isStoppable;
public long now;
public Timestamps timestamps;
public Operator[] vertices;
@JsonProperty("status-counts")
public OperatorTasks statusCounts;
public Object plan;
}
package de.potsdam.gfz.flink.api;
/**
* FlinkAPI JobOverview POJO<br>
* <br>
* Jobs, groupes by status, each with a small summary of its status.
*
* @author Daniel Eggert (daniel.eggert@gfz-potsdam.de)
*
*/
public class JobOverview {
// {"running":[],"finished":[{"jid":"d53072f1ee5db6a29301c97d4a7c26f1","name":"sampling123456","state":"FINISHED","start-time":1495197012587,"end-time":1495197388461,"duration":375874,"last-modification":1495197388461,"tasks":{"total":14,"pending":0,"running":0,"finished":14,"canceling":0,"canceled":0,"failed":0}},{"jid":"9cdd8f2edb462ca491443f478e0890b4","name":"Classification123456","state":"FINISHED","start-time":1495197398840,"end-time":1495199810151,"duration":2411311,"last-modification":1495199810151,"tasks":{"total":16,"pending":0,"running":0,"finished":16,"canceling":0,"canceled":0,"failed":0}}]}
public Job[] running;
public Job[] finished;
}
/**
*
*/
package de.potsdam.gfz.flink.api;
/**
* FlinkAPI Tasks POJO<br>
* <br>
* small summary of a jobs tasks
*
* @author Daniel Eggert (daniel.eggert@gfz-potsdam.de)
*
*/
public class JobTasks {
public int total;
public int pending;
public int running;
public int finished;
public int canceling;
public int canceled;
public int failed;
}
/**
*
*/
package de.potsdam.gfz.flink.api;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* FlinkAPI Operator POJO<br>
* <br>
* Information about one specific operator/vertex.
*
* @author Daniel Eggert (daniel.eggert@gfz-potsdam.de)
*
*/
public class Operator {
public String id;
public String name;
public String status;
public int parallelism;
@JsonProperty("start-time")
public long startTime;
@JsonProperty("end-time")
public long endTime;
@JsonProperty("duration")
public long duration;
public OperatorTasks tasks;
public OperatorMetrics metrics;
}
/**
*
*/
package de.potsdam.gfz.flink.api;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* FlinkAPI Operator Metrics POJO<br>
* <br>
* small summary of a operator metrics
*
* @author Daniel Eggert (daniel.eggert@gfz-potsdam.de)
*
*/
public class OperatorMetrics {
@JsonProperty("read-bytes")
public long readBytes;
@JsonProperty("write-bytes")
public long writeBytes;
@JsonProperty("read-records")
public long readRecords;
@JsonProperty("write-records")
public long writeRecords;
}
/**
*
*/
package de.potsdam.gfz.flink.api;
/**
* FlinkAPI Operator Tasks POJO<br>
* <br>
* small summary of a operator tasks
*
* @author Daniel Eggert (daniel.eggert@gfz-potsdam.de)
*
*/
public class OperatorTasks {
public int CREATED;
public int SCHEDULED;
public int DEPLOYING;
public int RUNNING;
public int FINISHED;
public int CANCELING;
public int CANCELED;
public int FAILED;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment