zentol commented on a change in pull request #11628: [FLINK-14504][rest] Add
Cluster DataSet REST API
URL: https://github.com/apache/flink/pull/11628#discussion_r406069509
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/DataSetMetaInfo.java
##########
@@ -17,18 +17,42 @@
package org.apache.flink.runtime.io.network.partition;
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.util.Preconditions;
+
+import java.util.Optional;
+
/**
* Container for meta-data of a data set.
*/
public final class DataSetMetaInfo {
+ private static final int UNKNOWN = -1;
+ private final int numRegisteredPartitions;
private final int numTotalPartitions;
- public DataSetMetaInfo(int numTotalPartitions) {
+ private DataSetMetaInfo(int numRegisteredPartitions, int
numTotalPartitions) {
+ this.numRegisteredPartitions = numRegisteredPartitions;
this.numTotalPartitions = numTotalPartitions;
}
+ public Optional<Integer> getNumRegisteredPartitions() {
Review comment:
hmm returning 0 might make sense yes.
Effectively, this method is supposed to never by called internally (i.e.,
within the `RMPartitionTrackerImpl`, and only be used when returned by
listDataSets.
This is naturally icky.
It could be argued that a separate class should be added that extends/wraps
some `InternalDataSetMetaInfo`, but this seemed quite overkill.
Originally I threw an IllegalStateException if used internally, but this
somewhat magnified how terrible this is.
So I oped for an optional instead.
For external users (like handlers), 0 is a sane default.
If used internally, the idea (or hope) was that it somewhat conveys that
this value may not be set, ideally resulting in the question "why?". Because if
you use this internally, you're about to do something wrong.
It is a tad convoluted thinking admittedly.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services