You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by ka...@apache.org on 2018/02/21 04:41:20 UTC
[1/3] storm git commit: Refactor addResource and addResources Method
and avoid NPEs
Repository: storm
Updated Branches:
refs/heads/master dc4011cd6 -> 461ac628f
Refactor addResource and addResources Method and avoid NPEs
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/0267d549
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/0267d549
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/0267d549
Branch: refs/heads/master
Commit: 0267d549a96c1e7aefa3cb5d23e1cca559dd8e74
Parents: 09e0123
Author: Kishor Patil <kp...@yahoo-inc.com>
Authored: Fri Feb 16 19:23:17 2018 -0500
Committer: Kishor Patil <kp...@yahoo-inc.com>
Committed: Fri Feb 16 19:23:17 2018 -0500
----------------------------------------------------------------------
.../coordination/BatchSubtopologyBuilder.java | 21 ++------
.../storm/drpc/LinearDRPCTopologyBuilder.java | 24 +++------
.../topology/BaseConfigurationDeclarer.java | 26 ++++++++++
.../ComponentConfigurationDeclarer.java | 7 +++
.../apache/storm/topology/TopologyBuilder.java | 10 ++++
.../TransactionalTopologyBuilder.java | 51 ++++++--------------
.../topology/TridentTopologyBuilder.java | 50 ++++++-------------
7 files changed, 84 insertions(+), 105 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/0267d549/storm-client/src/jvm/org/apache/storm/coordination/BatchSubtopologyBuilder.java
----------------------------------------------------------------------
diff --git a/storm-client/src/jvm/org/apache/storm/coordination/BatchSubtopologyBuilder.java b/storm-client/src/jvm/org/apache/storm/coordination/BatchSubtopologyBuilder.java
index d8e5231..c1efb46 100644
--- a/storm-client/src/jvm/org/apache/storm/coordination/BatchSubtopologyBuilder.java
+++ b/storm-client/src/jvm/org/apache/storm/coordination/BatchSubtopologyBuilder.java
@@ -450,17 +450,7 @@ public class BatchSubtopologyBuilder {
@Override
public BoltDeclarer addConfigurations(Map<String, Object> conf) {
if (conf != null) {
- component.componentConf.putAll(conf);
- }
- return this;
- }
-
- @Override
- public BoltDeclarer addResources(Map<String, Double> resources) {
- if (resources != null) {
- Map<String, Double> currentResources = (Map<String, Double>) component.componentConf.computeIfAbsent(
- Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, (k) -> new HashMap<>());
- currentResources.putAll(resources);
+ getComponentConfiguration().putAll(conf);
}
return this;
}
@@ -471,14 +461,9 @@ public class BatchSubtopologyBuilder {
return this;
}
- @SuppressWarnings("unchecked")
@Override
- public BoltDeclarer addResource(String resourceName, Number resourceValue) {
- Map<String, Double> resourcesMap = (Map<String, Double>) component.componentConf.computeIfAbsent(
- Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, (k) -> new HashMap<>());
-
- resourcesMap.put(resourceName, resourceValue.doubleValue());
- return this;
+ public Map<String, Object> getComponentConfiguration() {
+ return component.componentConf;
}
}
}
http://git-wip-us.apache.org/repos/asf/storm/blob/0267d549/storm-client/src/jvm/org/apache/storm/drpc/LinearDRPCTopologyBuilder.java
----------------------------------------------------------------------
diff --git a/storm-client/src/jvm/org/apache/storm/drpc/LinearDRPCTopologyBuilder.java b/storm-client/src/jvm/org/apache/storm/drpc/LinearDRPCTopologyBuilder.java
index 6844ad0..7d6a6be 100644
--- a/storm-client/src/jvm/org/apache/storm/drpc/LinearDRPCTopologyBuilder.java
+++ b/storm-client/src/jvm/org/apache/storm/drpc/LinearDRPCTopologyBuilder.java
@@ -407,24 +407,14 @@ public class LinearDRPCTopologyBuilder {
return this;
}
+ /**
+ * return the current component configuration.
+ *
+ * @return the current configuration.
+ */
@Override
- public LinearDRPCInputDeclarer addResources(Map<String, Double> resources) {
- if (resources != null) {
- Map<String, Double> currentResources = (Map<String, Double>) component.componentConf.computeIfAbsent(
- Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, (k) -> new HashMap<>());
- currentResources.putAll(resources);
- }
- return this;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public LinearDRPCInputDeclarer addResource(String resourceName, Number resourceValue) {
- Map<String, Double> resourcesMap = (Map<String, Double>) component.componentConf.computeIfAbsent(
- Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, (k) -> new HashMap<>());
-
- resourcesMap.put(resourceName, resourceValue.doubleValue());
- return this;
+ public Map<String, Object> getComponentConfiguration() {
+ return component.componentConf;
}
@Override
http://git-wip-us.apache.org/repos/asf/storm/blob/0267d549/storm-client/src/jvm/org/apache/storm/topology/BaseConfigurationDeclarer.java
----------------------------------------------------------------------
diff --git a/storm-client/src/jvm/org/apache/storm/topology/BaseConfigurationDeclarer.java b/storm-client/src/jvm/org/apache/storm/topology/BaseConfigurationDeclarer.java
index 6515c46..ea78e2a 100644
--- a/storm-client/src/jvm/org/apache/storm/topology/BaseConfigurationDeclarer.java
+++ b/storm-client/src/jvm/org/apache/storm/topology/BaseConfigurationDeclarer.java
@@ -86,4 +86,30 @@ public abstract class BaseConfigurationDeclarer<T extends ComponentConfiguration
}
return (T) this;
}
+
+ @SuppressWarnings("unchecked")
+ public T addResource(String resourceName, Number resourceValue) {
+ Map<String, Double> resourcesMap = (Map<String, Double>) getComponentConfiguration().computeIfAbsent(Config.TOPOLOGY_COMPONENT_RESOURCES_MAP,
+ (x) -> new HashMap<String, Double>());
+ resourcesMap.put(resourceName, resourceValue.doubleValue());
+
+ return (T) this;
+ }
+
+ /**
+ * Add generic resources for this component.
+ *
+ * @param resources
+ */
+ @Override
+ public T addResources(Map<String, Double> resources) {
+ if (resources != null) {
+ Map<String, Double> currentResources = (Map<String, Double>) getComponentConfiguration().computeIfAbsent(
+ Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, (k) -> new HashMap<>());
+ currentResources.putAll(resources);
+ }
+ return (T) this;
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/storm/blob/0267d549/storm-client/src/jvm/org/apache/storm/topology/ComponentConfigurationDeclarer.java
----------------------------------------------------------------------
diff --git a/storm-client/src/jvm/org/apache/storm/topology/ComponentConfigurationDeclarer.java b/storm-client/src/jvm/org/apache/storm/topology/ComponentConfigurationDeclarer.java
index ce38392..28c4418 100644
--- a/storm-client/src/jvm/org/apache/storm/topology/ComponentConfigurationDeclarer.java
+++ b/storm-client/src/jvm/org/apache/storm/topology/ComponentConfigurationDeclarer.java
@@ -29,6 +29,13 @@ public interface ComponentConfigurationDeclarer<T extends ComponentConfiguration
T addConfigurations(Map<String, Object> conf);
/**
+ * return the current component configuration.
+ *
+ * @return the current configuration.
+ */
+ Map<String, Object> getComponentConfiguration();
+
+ /**
* Add in a single config.
* @param config the key for the config
* @param value the value of the config
http://git-wip-us.apache.org/repos/asf/storm/blob/0267d549/storm-client/src/jvm/org/apache/storm/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/storm-client/src/jvm/org/apache/storm/topology/TopologyBuilder.java b/storm-client/src/jvm/org/apache/storm/topology/TopologyBuilder.java
index 7c28797..60a7eb3 100644
--- a/storm-client/src/jvm/org/apache/storm/topology/TopologyBuilder.java
+++ b/storm-client/src/jvm/org/apache/storm/topology/TopologyBuilder.java
@@ -585,6 +585,16 @@ public class TopologyBuilder {
return (T) this;
}
+ /**
+ * return the current component configuration.
+ *
+ * @return the current configuration.
+ */
+ @Override
+ public Map<String, Object> getComponentConfiguration() {
+ return parseJson(commons.get(id).get_json_conf());
+ }
+
@Override
public T addResources(Map<String, Double> resources) {
if (resources != null && !resources.isEmpty()) {
http://git-wip-us.apache.org/repos/asf/storm/blob/0267d549/storm-client/src/jvm/org/apache/storm/transactional/TransactionalTopologyBuilder.java
----------------------------------------------------------------------
diff --git a/storm-client/src/jvm/org/apache/storm/transactional/TransactionalTopologyBuilder.java b/storm-client/src/jvm/org/apache/storm/transactional/TransactionalTopologyBuilder.java
index 466bd4c..a6602b1 100644
--- a/storm-client/src/jvm/org/apache/storm/transactional/TransactionalTopologyBuilder.java
+++ b/storm-client/src/jvm/org/apache/storm/transactional/TransactionalTopologyBuilder.java
@@ -230,14 +230,14 @@ public class TransactionalTopologyBuilder {
return this;
}
+ /**
+ * return the current component configuration.
+ *
+ * @return the current configuration.
+ */
@Override
- public SpoutDeclarerImpl addResources(Map<String, Double> resources) {
- if (resources != null) {
- Map<String, Double> currentResources = (Map<String, Double>) spoutConf.computeIfAbsent(
- Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, (k) -> new HashMap<>());
- currentResources.putAll(resources);
- }
- return this;
+ public Map<String, Object> getComponentConfiguration() {
+ return spoutConf;
}
@Override
@@ -245,16 +245,6 @@ public class TransactionalTopologyBuilder {
spoutSharedMemory.add(request);
return this;
}
-
- @SuppressWarnings("unchecked")
- @Override
- public SpoutDeclarer addResource(String resourceName, Number resourceValue) {
- Map<String, Double> resourcesMap = (Map<String, Double>) spoutConf.computeIfAbsent(Config.TOPOLOGY_COMPONENT_RESOURCES_MAP,
- (k) -> new HashMap<>());
-
- resourcesMap.put(resourceName, resourceValue.doubleValue());
- return this;
- }
}
private static class BoltDeclarerImpl extends BaseConfigurationDeclarer<BoltDeclarer> implements BoltDeclarer {
@@ -553,34 +543,25 @@ public class TransactionalTopologyBuilder {
@Override
public BoltDeclarer addConfigurations(Map<String, Object> conf) {
if (conf != null) {
- component.componentConf.putAll(conf);
+ getComponentConfiguration().putAll(conf);
}
return this;
}
+ /**
+ * return the current component configuration.
+ *
+ * @return the current configuration.
+ */
@Override
- public BoltDeclarer addResources(Map<String, Double> resources) {
- if (resources != null) {
- Map<String, Double> currentResources = (Map<String, Double>) component.componentConf.computeIfAbsent(
- Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, (k) -> new HashMap<>());
- currentResources.putAll(resources);
- }
- return this;
+ public Map<String, Object> getComponentConfiguration() {
+ return component.componentConf;
}
+
@Override
public BoltDeclarer addSharedMemory(SharedMemory request) {
component.sharedMemory.add(request);
return this;
}
-
- @SuppressWarnings("unchecked")
- @Override
- public BoltDeclarer addResource(String resourceName, Number resourceValue) {
- Map<String, Double> resourcesMap = (Map<String, Double>) component.componentConf.computeIfAbsent(
- Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, (k) -> new HashMap<>());
-
- resourcesMap.put(resourceName, resourceValue.doubleValue());
- return this;
- }
}
}
http://git-wip-us.apache.org/repos/asf/storm/blob/0267d549/storm-client/src/jvm/org/apache/storm/trident/topology/TridentTopologyBuilder.java
----------------------------------------------------------------------
diff --git a/storm-client/src/jvm/org/apache/storm/trident/topology/TridentTopologyBuilder.java b/storm-client/src/jvm/org/apache/storm/trident/topology/TridentTopologyBuilder.java
index 39c52f9..fcf8174 100644
--- a/storm-client/src/jvm/org/apache/storm/trident/topology/TridentTopologyBuilder.java
+++ b/storm-client/src/jvm/org/apache/storm/trident/topology/TridentTopologyBuilder.java
@@ -366,24 +366,14 @@ public class TridentTopologyBuilder {
return this;
}
+ /**
+ * return the current component configuration.
+ *
+ * @return the current configuration.
+ */
@Override
- public SpoutDeclarer addResources(Map<String, Double> resources) {
- if (resources != null) {
- Map<String, Double> currentResources = (Map<String, Double>) component.componentConf.computeIfAbsent(
- Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, (k) -> new HashMap<>());
- currentResources.putAll(resources);
- }
- return this;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public SpoutDeclarer addResource(String resourceName, Number resourceValue) {
- Map<String, Double> resourcesMap = (Map<String, Double>) component.componentConf.computeIfAbsent(
- Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, (k) -> new HashMap<>());
-
- resourcesMap.put(resourceName, resourceValue.doubleValue());
- return this;
+ public Map<String, Object> getComponentConfiguration() {
+ return component.componentConf;
}
@Override
@@ -779,30 +769,20 @@ public class TridentTopologyBuilder {
return this;
}
+ /**
+ * return the current component configuration.
+ *
+ * @return the current configuration.
+ */
@Override
- public BoltDeclarer addResources(Map<String, Double> resources) {
- if (resources != null) {
- Map<String, Double> currentResources = (Map<String, Double>) component.componentConf.computeIfAbsent(
- Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, (k) -> new HashMap<>());
- currentResources.putAll(resources);
- }
- return this;
+ public Map<String, Object> getComponentConfiguration() {
+ return component.componentConf;
}
- @Override
+ @Override
public BoltDeclarer addSharedMemory(SharedMemory request) {
component.sharedMemory.add(request);
return this;
}
-
- @SuppressWarnings("unchecked")
- @Override
- public BoltDeclarer addResource(String resourceName, Number resourceValue) {
- Map<String, Double> resourcesMap = (Map<String, Double>) component.componentConf.computeIfAbsent(
- Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, (k) -> new HashMap<>());
-
- resourcesMap.put(resourceName, resourceValue.doubleValue());
- return this;
- }
}
}
[2/3] storm git commit: Fix the broken indent
Posted by ka...@apache.org.
Fix the broken indent
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/aab39da1
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/aab39da1
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/aab39da1
Branch: refs/heads/master
Commit: aab39da1d53339a06a33b6e3d42ac66ecab8d2e6
Parents: 0267d54
Author: Kishor Patil <kp...@yahoo-inc.com>
Authored: Mon Feb 19 17:42:14 2018 -0500
Committer: Kishor Patil <kp...@yahoo-inc.com>
Committed: Mon Feb 19 17:42:14 2018 -0500
----------------------------------------------------------------------
.../org/apache/storm/trident/topology/TridentTopologyBuilder.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/aab39da1/storm-client/src/jvm/org/apache/storm/trident/topology/TridentTopologyBuilder.java
----------------------------------------------------------------------
diff --git a/storm-client/src/jvm/org/apache/storm/trident/topology/TridentTopologyBuilder.java b/storm-client/src/jvm/org/apache/storm/trident/topology/TridentTopologyBuilder.java
index fcf8174..0dad62b 100644
--- a/storm-client/src/jvm/org/apache/storm/trident/topology/TridentTopologyBuilder.java
+++ b/storm-client/src/jvm/org/apache/storm/trident/topology/TridentTopologyBuilder.java
@@ -779,7 +779,7 @@ public class TridentTopologyBuilder {
return component.componentConf;
}
- @Override
+ @Override
public BoltDeclarer addSharedMemory(SharedMemory request) {
component.sharedMemory.add(request);
return this;
[3/3] storm git commit: Merge branch 'refactorDeclarers' of
https://github.com/kishorvpatil/incubator-storm into STORM-2961-merge
Posted by ka...@apache.org.
Merge branch 'refactorDeclarers' of https://github.com/kishorvpatil/incubator-storm into STORM-2961-merge
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/461ac628
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/461ac628
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/461ac628
Branch: refs/heads/master
Commit: 461ac628fdacc09e50325a9f5786000d67e89c5e
Parents: dc4011c aab39da
Author: Jungtaek Lim <ka...@gmail.com>
Authored: Wed Feb 21 13:41:08 2018 +0900
Committer: Jungtaek Lim <ka...@gmail.com>
Committed: Wed Feb 21 13:41:08 2018 +0900
----------------------------------------------------------------------
.../coordination/BatchSubtopologyBuilder.java | 21 ++------
.../storm/drpc/LinearDRPCTopologyBuilder.java | 24 +++------
.../topology/BaseConfigurationDeclarer.java | 26 ++++++++++
.../ComponentConfigurationDeclarer.java | 7 +++
.../apache/storm/topology/TopologyBuilder.java | 10 ++++
.../TransactionalTopologyBuilder.java | 51 ++++++--------------
.../topology/TridentTopologyBuilder.java | 48 ++++++------------
7 files changed, 83 insertions(+), 104 deletions(-)
----------------------------------------------------------------------