Search in sources :

Example 1 with SubtasksAllAccumulatorsInfo

use of org.apache.flink.runtime.rest.messages.job.SubtasksAllAccumulatorsInfo in project flink by apache.

the class SubtasksAllAccumulatorsHandler method handleRequest.

@Override
protected SubtasksAllAccumulatorsInfo handleRequest(HandlerRequest<EmptyRequestBody> request, AccessExecutionJobVertex jobVertex) throws RestHandlerException {
    JobVertexID jobVertexId = jobVertex.getJobVertexId();
    int parallelism = jobVertex.getParallelism();
    final List<SubtasksAllAccumulatorsInfo.SubtaskAccumulatorsInfo> subtaskAccumulatorsInfos = new ArrayList<>();
    for (AccessExecutionVertex vertex : jobVertex.getTaskVertices()) {
        TaskManagerLocation location = vertex.getCurrentAssignedResourceLocation();
        String locationString = location == null ? "(unassigned)" : location.getHostname();
        StringifiedAccumulatorResult[] accs = vertex.getCurrentExecutionAttempt().getUserAccumulatorsStringified();
        List<UserAccumulator> userAccumulators = new ArrayList<>(accs.length);
        for (StringifiedAccumulatorResult acc : accs) {
            userAccumulators.add(new UserAccumulator(acc.getName(), acc.getType(), acc.getValue()));
        }
        subtaskAccumulatorsInfos.add(new SubtasksAllAccumulatorsInfo.SubtaskAccumulatorsInfo(vertex.getCurrentExecutionAttempt().getParallelSubtaskIndex(), vertex.getCurrentExecutionAttempt().getAttemptNumber(), locationString, userAccumulators));
    }
    return new SubtasksAllAccumulatorsInfo(jobVertexId, parallelism, subtaskAccumulatorsInfos);
}
Also used : TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) ArrayList(java.util.ArrayList) StringifiedAccumulatorResult(org.apache.flink.runtime.accumulators.StringifiedAccumulatorResult) SubtasksAllAccumulatorsInfo(org.apache.flink.runtime.rest.messages.job.SubtasksAllAccumulatorsInfo) UserAccumulator(org.apache.flink.runtime.rest.messages.job.UserAccumulator) AccessExecutionVertex(org.apache.flink.runtime.executiongraph.AccessExecutionVertex)

Aggregations

ArrayList (java.util.ArrayList)1 StringifiedAccumulatorResult (org.apache.flink.runtime.accumulators.StringifiedAccumulatorResult)1 AccessExecutionVertex (org.apache.flink.runtime.executiongraph.AccessExecutionVertex)1 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)1 SubtasksAllAccumulatorsInfo (org.apache.flink.runtime.rest.messages.job.SubtasksAllAccumulatorsInfo)1 UserAccumulator (org.apache.flink.runtime.rest.messages.job.UserAccumulator)1 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)1