storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kabh...@apache.org
Subject [2/5] storm git commit: STORM-3184: remove guava dependency
Date Tue, 14 Aug 2018 14:24:57 GMT
STORM-3184: remove guava dependency


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

Branch: refs/heads/master
Commit: 0fe39c8844f1d7e508b4f314942e26ee66bb503b
Parents: 9d36724
Author: Arun Mahadevan <arunm@apache.org>
Authored: Sat Aug 11 09:41:43 2018 -0700
Committer: Arun Mahadevan <arunm@apache.org>
Committed: Sat Aug 11 10:28:55 2018 -0700

----------------------------------------------------------------------
 storm-client/pom.xml                            |  6 ----
 .../org/apache/storm/daemon/worker/Worker.java  |  4 +--
 .../jvm/org/apache/storm/utils/ConfigUtils.java | 38 +++++++++++++++-----
 .../org/apache/storm/daemon/nimbus/Nimbus.java  |  2 +-
 .../java/org/apache/storm/DaemonConfigTest.java |  2 +-
 5 files changed, 33 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/0fe39c88/storm-client/pom.xml
----------------------------------------------------------------------
diff --git a/storm-client/pom.xml b/storm-client/pom.xml
index c925ffd..7c28cce 100644
--- a/storm-client/pom.xml
+++ b/storm-client/pom.xml
@@ -97,12 +97,6 @@
 
         <!-- end of transitive dependency management -->
 
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <version>${guava.version}</version>
-        </dependency>
-
         <!-- test -->
         <dependency>
             <groupId>org.mockito</groupId>

http://git-wip-us.apache.org/repos/asf/storm/blob/0fe39c88/storm-client/src/jvm/org/apache/storm/daemon/worker/Worker.java
----------------------------------------------------------------------
diff --git a/storm-client/src/jvm/org/apache/storm/daemon/worker/Worker.java b/storm-client/src/jvm/org/apache/storm/daemon/worker/Worker.java
index 9f8428b..c0dfc0a 100644
--- a/storm-client/src/jvm/org/apache/storm/daemon/worker/Worker.java
+++ b/storm-client/src/jvm/org/apache/storm/daemon/worker/Worker.java
@@ -278,8 +278,8 @@ public class Worker implements Shutdownable, DaemonCommon {
         setupFlushTupleTimer(topologyConf, newExecutors);
         setupBackPressureCheckTimer(topologyConf);
 
-        LOG.info("Worker has topology config {}", Utils.redactValue(ConfigUtils.maskPasswords(topologyConf),
-                Config.STORM_ZOOKEEPER_TOPOLOGY_AUTH_PAYLOAD));
+        LOG.info("Worker has topology config {}", ConfigUtils.maskPasswords(Utils.redactValue(topologyConf,
+                Config.STORM_ZOOKEEPER_TOPOLOGY_AUTH_PAYLOAD)));
         LOG.info("Worker {} for storm {} on {}:{}  has finished loading", workerId, topologyId,
assignmentId, port);
         return this;
     }

http://git-wip-us.apache.org/repos/asf/storm/blob/0fe39c88/storm-client/src/jvm/org/apache/storm/utils/ConfigUtils.java
----------------------------------------------------------------------
diff --git a/storm-client/src/jvm/org/apache/storm/utils/ConfigUtils.java b/storm-client/src/jvm/org/apache/storm/utils/ConfigUtils.java
index 5fefcea..064365d 100644
--- a/storm-client/src/jvm/org/apache/storm/utils/ConfigUtils.java
+++ b/storm-client/src/jvm/org/apache/storm/utils/ConfigUtils.java
@@ -26,9 +26,9 @@ import java.util.Map;
 import java.util.Random;
 import java.util.Set;
 import java.util.function.BooleanSupplier;
+import java.util.function.Supplier;
 import java.util.stream.Collectors;
 
-import com.google.common.collect.Maps;
 import org.apache.storm.Config;
 import org.apache.storm.daemon.supervisor.AdvancedFSOps;
 import org.apache.storm.generated.StormTopology;
@@ -79,14 +79,34 @@ public class ConfigUtils {
         return oldInstance;
     }
 
-    public static Map<String, Object> maskPasswords(final Map<String, Object>
conf) {
-        Maps.EntryTransformer<String, Object, Object> maskPasswords =
-                new Maps.EntryTransformer<String, Object, Object>() {
-                    public Object transformEntry(String key, Object value) {
-                        return passwordConfigKeys.contains(key) ? "*****" : value;
-                    }
-                };
-        return Maps.transformEntries(conf, maskPasswords);
+    private static class MaskedConf implements Supplier<Map<String, Object>>
{
+        private final Map<String, Object> conf;
+
+        MaskedConf(Map<String, Object> conf) {
+            this.conf = conf;
+        }
+
+        @Override
+        public Map<String, Object> get() {
+            Map<String, Object> res = new HashMap<>();
+            for (Map.Entry<String, Object> e : conf.entrySet()) {
+                if (passwordConfigKeys.contains(e.getKey())) {
+                    res.put(e.getKey(), "*****");
+                } else {
+                    res.put(e.getKey(), e.getValue());
+                }
+            }
+            return res;
+        }
+
+        @Override
+        public String toString() {
+            return get().toString();
+        }
+    }
+
+    public static Supplier<Map<String, Object>> maskPasswords(Map<String,
Object> conf) {
+        return new MaskedConf(conf);
     }
 
     public static boolean isLocalMode(Map<String, Object> conf) {

http://git-wip-us.apache.org/repos/asf/storm/blob/0fe39c88/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 b66153b..13f430d 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
@@ -3075,7 +3075,7 @@ public class Nimbus implements Iface, Shutdownable, DaemonCommon {
             }
             LOG.info("Received topology submission for {} (storm-{} JDK-{}) with conf {}",
topoName,
                      topoVersionString, topology.get_jdk_version(),
-                     Utils.redactValue(ConfigUtils.maskPasswords(topoConf), Config.STORM_ZOOKEEPER_TOPOLOGY_AUTH_PAYLOAD));
+                    ConfigUtils.maskPasswords(Utils.redactValue(topoConf, Config.STORM_ZOOKEEPER_TOPOLOGY_AUTH_PAYLOAD)));
 
             // lock protects against multiple topologies being submitted at once and
             // cleanup thread killing topology in b/w assignment and starting the topology

http://git-wip-us.apache.org/repos/asf/storm/blob/0fe39c88/storm-server/src/test/java/org/apache/storm/DaemonConfigTest.java
----------------------------------------------------------------------
diff --git a/storm-server/src/test/java/org/apache/storm/DaemonConfigTest.java b/storm-server/src/test/java/org/apache/storm/DaemonConfigTest.java
index 2304f77..de7c378 100644
--- a/storm-server/src/test/java/org/apache/storm/DaemonConfigTest.java
+++ b/storm-server/src/test/java/org/apache/storm/DaemonConfigTest.java
@@ -97,7 +97,7 @@ public class DaemonConfigTest {
         Map<String, Object> conf = new HashMap<>();
         conf.put(DaemonConfig.LOGVIEWER_HTTPS_KEY_PASSWORD, "pass1");
         conf.put(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS, 100);
-        Map result = ConfigUtils.maskPasswords(conf);
+        Map result = ConfigUtils.maskPasswords(conf).get();
         Assert.assertEquals("*****", result.get(DaemonConfig.LOGVIEWER_HTTPS_KEY_PASSWORD));
         Assert.assertEquals(100, result.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS));
     }


Mime
View raw message