You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2018/03/06 21:40:46 UTC

[1/3] storm git commit: STORM-2762 use guava collection where ever it is possible

Repository: storm
Updated Branches:
  refs/heads/master 21832ad40 -> f9986fc09


STORM-2762 use guava collection where ever it is possible


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/2189abfa
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/2189abfa
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/2189abfa

Branch: refs/heads/master
Commit: 2189abfa1e15ce859969d93ad4656c5b84a345fd
Parents: 21832ad
Author: Gergely Hajos <ro...@gmail.com>
Authored: Sun Mar 4 17:30:41 2018 +0100
Committer: Gergely Hajos <ro...@gmail.com>
Committed: Sun Mar 4 17:47:30 2018 +0100

----------------------------------------------------------------------
 .../org/apache/storm/daemon/nimbus/Nimbus.java  |   5 +-
 .../scheduler/blacklist/BlacklistScheduler.java |   1 +
 .../apache/storm/scheduler/blacklist/Sets.java  | 106 -------------------
 .../scheduling/BaseResourceAwareStrategy.java   |  14 +--
 4 files changed, 9 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/2189abfa/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java
----------------------------------------------------------------------
diff --git a/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java b/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java
index c924377..aac4c21 100644
--- a/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java
+++ b/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java
@@ -23,6 +23,7 @@ import com.codahale.metrics.Histogram;
 import com.codahale.metrics.Meter;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableMap;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -469,7 +470,7 @@ public class Nimbus implements Iface, Shutdownable, DaemonCommon {
             });
     }
 
-    private static <K, V> Map<K, V> mapDiff(Map<? extends K, ? extends V> first, Map<? extends K, ? extends V> second) {
+    private static <K, V> Map<K, V> mapValuesOnlyOnRight(Map<? extends K, ? extends V> first, Map<? extends K, ? extends V> second) {
         Map<K, V> ret = new HashMap<>();
         for (Entry<? extends K, ? extends V> entry: second.entrySet()) {
             if (!entry.getValue().equals(first.get(entry.getKey()))) {
@@ -707,7 +708,7 @@ public class Nimbus implements Iface, Shutdownable, DaemonCommon {
             value.sort((a, b) -> a.get(0).compareTo(b.get(0)));
             newSlotAssigned.put(entry.getKey(), value);
         }
-        Map<List<Object>, List<List<Long>>> diff = mapDiff(slotAssigned, newSlotAssigned);
+        Map<List<Object>, List<List<Long>>> diff = mapValuesOnlyOnRight(slotAssigned, newSlotAssigned);
         List<List<Long>> ret = new ArrayList<>();
         for (List<List<Long>> val: diff.values()) {
             ret.addAll(val);

http://git-wip-us.apache.org/repos/asf/storm/blob/2189abfa/storm-server/src/main/java/org/apache/storm/scheduler/blacklist/BlacklistScheduler.java
----------------------------------------------------------------------
diff --git a/storm-server/src/main/java/org/apache/storm/scheduler/blacklist/BlacklistScheduler.java b/storm-server/src/main/java/org/apache/storm/scheduler/blacklist/BlacklistScheduler.java
index 8083e01..35c039e 100644
--- a/storm-server/src/main/java/org/apache/storm/scheduler/blacklist/BlacklistScheduler.java
+++ b/storm-server/src/main/java/org/apache/storm/scheduler/blacklist/BlacklistScheduler.java
@@ -19,6 +19,7 @@
 package org.apache.storm.scheduler.blacklist;
 
 import com.google.common.collect.EvictingQueue;
+import com.google.common.collect.Sets;
 
 import java.util.ArrayList;
 import java.util.HashMap;

http://git-wip-us.apache.org/repos/asf/storm/blob/2189abfa/storm-server/src/main/java/org/apache/storm/scheduler/blacklist/Sets.java
----------------------------------------------------------------------
diff --git a/storm-server/src/main/java/org/apache/storm/scheduler/blacklist/Sets.java b/storm-server/src/main/java/org/apache/storm/scheduler/blacklist/Sets.java
deleted file mode 100644
index 57344e6..0000000
--- a/storm-server/src/main/java/org/apache/storm/scheduler/blacklist/Sets.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.storm.scheduler.blacklist;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class Sets {
-
-    /**
-     * Calculate union of both sets.
-     *
-     * @param setA parameter 1
-     * @param setB parameter 2
-     * @param <T> generic type of Set elements.
-     * @return the Set which is union of both Sets.
-     */
-    public static <T> Set<T> union(Set<T> setA, Set<T> setB) {
-        Set<T> result = new HashSet<T>(setA);
-        result.addAll(setB);
-        return result;
-    }
-
-    /**
-     * Calculate intersection of both sets.
-     *
-     * @param setA parameter 1
-     * @param setB parameter 2
-     * @param <T> generic type of Set elements.
-     * @return the Set which is intersection of both Sets.
-     */
-    public static <T> Set<T> intersection(Set<T> setA, Set<T> setB) {
-        Set<T> result = new HashSet<T>(setA);
-        result.retainAll(setB);
-        return result;
-    }
-
-    /**
-     * Calculate difference of difference of two sets.
-     *
-     * @param setA parameter 1
-     * @param setB parameter 2
-     * @param <T> generic type of Set elements.
-     * @return the Set which is difference of two sets.
-     */
-    public static <T> Set<T> difference(Set<T> setA, Set<T> setB) {
-        Set<T> result = new HashSet<T>(setA);
-        result.removeAll(setB);
-        return result;
-    }
-
-    /**
-     * Calculate symmetric difference of two sets.
-     *
-     * @param setA parameter 1
-     * @param setB parameter 2
-     * @param <T> generic type of Set elements.
-     * @return the Set which is symmetric difference of two sets.
-     */
-    public static <T> Set<T> symDifference(Set<T> setA, Set<T> setB) {
-        Set<T> union = union(setA, setB);
-        Set<T> intersection = intersection(setA, setB);
-        return difference(union, intersection);
-    }
-
-    /**
-     * Check whether a set is a subset of another set.
-     *
-     * @param setA parameter 1
-     * @param setB parameter 2
-     * @param <T> generic type of Set elements.
-     * @return true when setB is a subset of setA, false otherwise.
-     */
-    public static <T> boolean isSubset(Set<T> setA, Set<T> setB) {
-        return setB.containsAll(setA);
-    }
-
-    /**
-     * Check whether a set is a superset of another set.
-     *
-     * @param setA parameter 1
-     * @param setB parameter 2
-     * @param <T> generic type of Set elements.
-     * @return true when setA is a superset of setB, false otherwise.
-     */
-    public static <T> boolean isSuperset(Set<T> setA, Set<T> setB) {
-        return setA.containsAll(setB);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/storm/blob/2189abfa/storm-server/src/main/java/org/apache/storm/scheduler/resource/strategies/scheduling/BaseResourceAwareStrategy.java
----------------------------------------------------------------------
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 02d06a9..bd4d3ce 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
@@ -19,6 +19,8 @@
 package org.apache.storm.scheduler.resource.strategies.scheduling;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.Sets;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -410,12 +412,12 @@ public abstract class BaseResourceAwareStrategy implements IStrategy {
                 int connections1 = 0;
                 int connections2 = 0;
 
-                for (String childId : union(o1.getChildren(), o1.getParents())) {
+                for (String childId : Sets.union(o1.getChildren(), o1.getParents())) {
                     connections1 +=
                         (componentMap.get(childId).getExecs().size() * o1.getExecs().size());
                 }
 
-                for (String childId : union(o2.getChildren(), o2.getParents())) {
+                for (String childId : Sets.union(o2.getChildren(), o2.getParents())) {
                     connections2 +=
                         (componentMap.get(childId).getExecs().size() * o2.getExecs().size());
                 }
@@ -432,12 +434,6 @@ public abstract class BaseResourceAwareStrategy implements IStrategy {
         return sortedComponents;
     }
 
-    private static <T> Set<T> union(Set<T> a, Set<T> b) {
-        HashSet<T> ret = new HashSet<>(a);
-        ret.addAll(b);
-        return ret;
-    }
-
     /**
      * Sort a component's neighbors by the number of connections it needs to make with this component.
      *
@@ -495,7 +491,7 @@ public abstract class BaseResourceAwareStrategy implements IStrategy {
 
         for (Component currComp : sortedComponents) {
             Map<String, Component> neighbors = new HashMap<String, Component>();
-            for (String compId : union(currComp.getChildren(), currComp.getParents())) {
+            for (String compId : Sets.union(currComp.getChildren(), currComp.getParents())) {
                 neighbors.put(compId, componentMap.get(compId));
             }
             Set<Component> sortedNeighbors = sortNeighbors(currComp, neighbors);


[3/3] storm git commit: Merge branch 'STORM-2762' of https://github.com/ghajos/storm into STORM-2762

Posted by bo...@apache.org.
Merge branch 'STORM-2762' of https://github.com/ghajos/storm into STORM-2762

STORM-2762: use guava collection where ever it is possible

This closes #2585


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/f9986fc0
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/f9986fc0
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/f9986fc0

Branch: refs/heads/master
Commit: f9986fc091e0d95c3499bffb92496684378d80d9
Parents: 21832ad 6a5f4b2
Author: Robert Evans <ev...@yahoo-inc.com>
Authored: Tue Mar 6 14:58:56 2018 -0600
Committer: Robert Evans <ev...@yahoo-inc.com>
Committed: Tue Mar 6 14:58:56 2018 -0600

----------------------------------------------------------------------
 .../org/apache/storm/daemon/nimbus/Nimbus.java  |   1 +
 .../scheduler/blacklist/BlacklistScheduler.java |   1 +
 .../apache/storm/scheduler/blacklist/Sets.java  | 106 -------------------
 .../scheduling/BaseResourceAwareStrategy.java   |  14 +--
 4 files changed, 7 insertions(+), 115 deletions(-)
----------------------------------------------------------------------



[2/3] storm git commit: STORM-2762 use guava collection where ever it is possible

Posted by bo...@apache.org.
STORM-2762 use guava collection where ever it is possible


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/6a5f4b25
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/6a5f4b25
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/6a5f4b25

Branch: refs/heads/master
Commit: 6a5f4b256cfe956b9eeda5f3c45e2cfbd83cb723
Parents: 2189abf
Author: Gergely Hajos <ro...@gmail.com>
Authored: Tue Mar 6 18:29:49 2018 +0100
Committer: Gergely Hajos <ro...@gmail.com>
Committed: Tue Mar 6 18:29:49 2018 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/6a5f4b25/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java
----------------------------------------------------------------------
diff --git a/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java b/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java
index aac4c21..a1dedcd 100644
--- a/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java
+++ b/storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java
@@ -470,7 +470,7 @@ public class Nimbus implements Iface, Shutdownable, DaemonCommon {
             });
     }
 
-    private static <K, V> Map<K, V> mapValuesOnlyOnRight(Map<? extends K, ? extends V> first, Map<? extends K, ? extends V> second) {
+    private static <K, V> Map<K, V> mapDiff(Map<? extends K, ? extends V> first, Map<? extends K, ? extends V> second) {
         Map<K, V> ret = new HashMap<>();
         for (Entry<? extends K, ? extends V> entry: second.entrySet()) {
             if (!entry.getValue().equals(first.get(entry.getKey()))) {
@@ -708,7 +708,7 @@ public class Nimbus implements Iface, Shutdownable, DaemonCommon {
             value.sort((a, b) -> a.get(0).compareTo(b.get(0)));
             newSlotAssigned.put(entry.getKey(), value);
         }
-        Map<List<Object>, List<List<Long>>> diff = mapValuesOnlyOnRight(slotAssigned, newSlotAssigned);
+        Map<List<Object>, List<List<Long>>> diff = mapDiff(slotAssigned, newSlotAssigned);
         List<List<Long>> ret = new ArrayList<>();
         for (List<List<Long>> val: diff.values()) {
             ret.addAll(val);