You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by et...@apache.org on 2020/02/27 14:57:33 UTC
[storm] branch master updated: [STORM-3589] Prevent inconsistent
results from consecutive hasNext and next calls in LazyNodeSortingIterator
This is an automated email from the ASF dual-hosted git repository.
ethanli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/storm.git
The following commit(s) were added to refs/heads/master by this push:
new 2b6b5cd [STORM-3589] Prevent inconsistent results from consecutive hasNext and next calls in LazyNodeSortingIterator
new a595c67 Merge pull request #3216 from RuiLi8080/STORM-3589
2b6b5cd is described below
commit 2b6b5cd80e58fad75b436f790e0fef0ff6877bcf
Author: Rui Li <ru...@verizonmedia.com>
AuthorDate: Tue Feb 25 23:33:24 2020 -0600
[STORM-3589] Prevent inconsistent results from consecutive hasNext and next calls in LazyNodeSortingIterator
---
.../strategies/scheduling/BaseResourceAwareStrategy.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/storm-server/src/main/java/org/apache/storm/scheduler/resource/strategies/scheduling/BaseResourceAwareStrategy.java b/storm-server/src/main/java/org/apache/storm/scheduler/resource/strategies/scheduling/BaseResourceAwareStrategy.java
index 6ab379f..7861cf9 100644
--- a/storm-server/src/main/java/org/apache/storm/scheduler/resource/strategies/scheduling/BaseResourceAwareStrategy.java
+++ b/storm-server/src/main/java/org/apache/storm/scheduler/resource/strategies/scheduling/BaseResourceAwareStrategy.java
@@ -27,6 +27,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.NoSuchElementException;
import java.util.Queue;
import java.util.Set;
import java.util.TreeSet;
@@ -271,14 +272,18 @@ public abstract class BaseResourceAwareStrategy implements IStrategy {
if (pre.hasNext()) {
return true;
}
+ if (nextValueFromNode != null) {
+ return true;
+ }
while (true) {
//For the node we don't know if we have another one unless we look at the contents
Iterator<ObjectResources> nodeIterator = getNodeIterator();
if (nodeIterator == null || !nodeIterator.hasNext()) {
break;
}
- nextValueFromNode = nodeIterator.next().id;
- if (!skip.contains(nextValueFromNode)) {
+ String tmp = nodeIterator.next().id;
+ if (!skip.contains(tmp)) {
+ nextValueFromNode = tmp;
return true;
}
}
@@ -290,6 +295,9 @@ public abstract class BaseResourceAwareStrategy implements IStrategy {
@Override
public String next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
if (pre.hasNext()) {
return pre.next();
}
@@ -521,7 +529,7 @@ public abstract class BaseResourceAwareStrategy implements IStrategy {
Map<String, Queue<ExecutorDetails>> compToExecsToSchedule = new HashMap<>();
for (Component component : componentMap.values()) {
- compToExecsToSchedule.put(component.getId(), new LinkedList<ExecutorDetails>());
+ compToExecsToSchedule.put(component.getId(), new LinkedList<>());
for (ExecutorDetails exec : component.getExecs()) {
if (unassignedExecutors.contains(exec)) {
compToExecsToSchedule.get(component.getId()).add(exec);