New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-9212][flip6] Port SubtasksAllAccumulatorsHandler to new REST endpoint #5893
Conversation
public class SubtasksAllAccumulatorsHandler extends AbstractJobVertexHandler<SubtasksAllAccumulatorsInfo, JobVertexMessageParameters> { | ||
|
||
/** | ||
* Instantiates a new subtasks all accumulators handler. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we typically don't have javadocs on constructors as they rarely offer any value
import java.util.Collection; | ||
import java.util.Objects; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line
)); | ||
} | ||
|
||
return new SubtasksAllAccumulatorsInfo(vertexId, parallelism, subtaskAccumulatorsInfos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the vertex ID should be passed as a JobVertexID
, not as a string.
public static final String FILED_NMAE_SUBTASKS = "subtasks"; | ||
|
||
@JsonProperty(FIELD_NAME_ID) | ||
private String id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a JobVertexID
, and a more descriptive field name would be great. (the JSON field name should remain the same ;) )
|
||
final List<SubtasksAllAccumulatorsInfo.SubtaskAccumulatorsInfo> subtaskAccumulatorsInfos = new ArrayList<>(); | ||
|
||
int index = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the actual subtask index. Use vertex.getCurrentExecutionAttempt().getParallelSubtaskIndex()
instead.
|
||
@Override | ||
protected SubtasksAllAccumulatorsInfo getTestResponseInstance() throws Exception { | ||
List<SubtasksAllAccumulatorsInfo.SubtaskAccumulatorsInfo> subtaskAccumulatorsInfos = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you now the size of this array already. (3)
protected SubtasksAllAccumulatorsInfo getTestResponseInstance() throws Exception { | ||
List<SubtasksAllAccumulatorsInfo.SubtaskAccumulatorsInfo> subtaskAccumulatorsInfos = new ArrayList<>(); | ||
|
||
List<UserAccumulator> userAccumulators = new ArrayList<>(3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you actually only have 2 accumulators.
@zentol thanks for your review. I have updated the PR. |
You have not changed the type of |
i saw if i change the type of
|
You have to use the |
see |
267f294
to
7e8cc4a
Compare
@zentol thanks you. I updated the code. 😆 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 minor comments, otherwise +1.
for (AccessExecutionVertex vertex : jobVertex.getTaskVertices()) { | ||
|
||
TaskManagerLocation location = vertex.getCurrentAssignedResourceLocation(); | ||
String locationString = location == null ? "(unassigned)" : location.getHostname(); | ||
|
||
gen.writeStartObject(); | ||
|
||
gen.writeNumberField("subtask", num++); | ||
gen.writeNumberField("subtask", vertex.getCurrentExecutionAttempt().getParallelSubtaskIndex()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep this at it is.
public static final String FIELD_NAME_PARALLELISM = "parallelism"; | ||
public static final String FILED_NMAE_SUBTASKS = "subtasks"; | ||
public static final String FILED_NAME_SUBTASKS = "subtasks"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: FILED -> FIELD
I'll address the remaining issues myself when merging, thanks for working on this! |
…dpoint This closes apache#5893.
…dpoint This closes apache#5893.
What is the purpose of the change
Port SubtasksAllAccumulatorsHandler to new REST endpoint
Brief change log
Verifying this change
Added test case SubtasksAllAccumulatorsInfoTest to generate the json response
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (yes / no)Documentation