adoroszlai commented on code in PR #4767:
URL: https://github.com/apache/ozone/pull/4767#discussion_r1204644615
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/PipelineChoosePolicy.java:
##########
@@ -30,8 +30,18 @@ public interface PipelineChoosePolicy {
* Given an initial list of pipelines, return one of the pipelines.
*
* @param pipelineList list of pipelines.
- * @return one of the pipelines.
+ * @return one of the pipelines or null if no pipeline can be selected.
*/
Pipeline choosePipeline(List<Pipeline> pipelineList,
PipelineRequestInformation pri);
+
+ /**
+ * Given a list of pipelines, return the index of the chosen pipeline.
+ * @param pipelineList List of pipelines
+ * @param pri PipelineRequestInformation
+ * @return Index in the list of the chosen pipeline, or -1 if no pipeline
+ * could be selected.
+ */
+ int choosePipelineIndex(List<Pipeline> pipelineList,
+ PipelineRequestInformation pri);
Review Comment:
How about something like this as the default implementation?
```java
default int choosePipelineIndex(List<Pipeline> pipelineList,
PipelineRequestInformation pri) {
return pipelineList == null || pipelineList.isEmpty() ? -1 : 0;
}
```
i.e. return the first pipeline, unless there is none.
We can probably state in the release notes that custom implementations need
to override it to ensure that the two methods are consistent.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]