You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by da...@apache.org on 2015/12/21 15:46:46 UTC

[18/23] storm git commit: making edits based on comments and removing unneccessary null checks

making edits based on comments and removing unneccessary null checks


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

Branch: refs/heads/master
Commit: 068a8c21e9e4f5e213fca9eab86398685036ac9e
Parents: 45f637f
Author: Boyang Jerry Peng <je...@yahoo-inc.com>
Authored: Wed Dec 16 16:06:47 2015 -0600
Committer: Boyang Jerry Peng <je...@yahoo-inc.com>
Committed: Wed Dec 16 16:06:47 2015 -0600

----------------------------------------------------------------------
 .../storm/scheduler/SupervisorDetails.java      |  8 ++-----
 .../storm/scheduler/TopologyDetails.java        | 22 +++++++-------------
 .../storm/scheduler/resource/RAS_Node.java      |  2 +-
 .../storm/scheduler/resource/RAS_Nodes.java     |  8 +++----
 4 files changed, 14 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/068a8c21/storm-core/src/jvm/backtype/storm/scheduler/SupervisorDetails.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/scheduler/SupervisorDetails.java b/storm-core/src/jvm/backtype/storm/scheduler/SupervisorDetails.java
index 5943ecf..94afb62 100644
--- a/storm-core/src/jvm/backtype/storm/scheduler/SupervisorDetails.java
+++ b/storm-core/src/jvm/backtype/storm/scheduler/SupervisorDetails.java
@@ -120,17 +120,13 @@ public class SupervisorDetails {
 
     public Double getTotalMemory() {
         Double totalMemory = getTotalResource(Config.SUPERVISOR_MEMORY_CAPACITY_MB);
-        if (totalMemory == null) {
-            throw new IllegalStateException("default value for " + Config.SUPERVISOR_MEMORY_CAPACITY_MB + " is not set!");
-        }
+        assert totalMemory != null;
         return totalMemory;
     }
 
     public Double getTotalCPU() {
         Double totalCPU = getTotalResource(Config.SUPERVISOR_CPU_CAPACITY);
-        if (totalCPU == null) {
-            throw new IllegalStateException("default value for " + Config.SUPERVISOR_CPU_CAPACITY + " is not set!");
-        }
+        assert totalCPU != null;
         return totalCPU;
     }
 }

http://git-wip-us.apache.org/repos/asf/storm/blob/068a8c21/storm-core/src/jvm/backtype/storm/scheduler/TopologyDetails.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/scheduler/TopologyDetails.java b/storm-core/src/jvm/backtype/storm/scheduler/TopologyDetails.java
index 357bec7..479986d 100644
--- a/storm-core/src/jvm/backtype/storm/scheduler/TopologyDetails.java
+++ b/storm-core/src/jvm/backtype/storm/scheduler/TopologyDetails.java
@@ -418,17 +418,12 @@ public class TopologyDetails {
      */
     public void addDefaultResforExec(ExecutorDetails exec) {
         Double topologyComponentCpuPcorePercent = Utils.getDouble(this.topologyConf.get(Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT), null);
-        if (topologyComponentCpuPcorePercent == null) {
-            LOG.warn("default value for " + Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT + " needs to be set!");
-        }
         Double topologyComponentResourcesOffheapMemoryMb = Utils.getDouble(this.topologyConf.get(Config.TOPOLOGY_COMPONENT_RESOURCES_OFFHEAP_MEMORY_MB), null);
-        if (topologyComponentResourcesOffheapMemoryMb == null) {
-            LOG.warn("default value for " + Config.TOPOLOGY_COMPONENT_RESOURCES_OFFHEAP_MEMORY_MB + " needs to be set!");
-        }
         Double topologyComponentResourcesOnheapMemoryMb = Utils.getDouble(this.topologyConf.get(Config.TOPOLOGY_COMPONENT_RESOURCES_ONHEAP_MEMORY_MB), null);
-        if (topologyComponentResourcesOnheapMemoryMb == null) {
-            LOG.warn("default value for " + Config.TOPOLOGY_COMPONENT_RESOURCES_ONHEAP_MEMORY_MB + " needs to be set!");
-        }
+
+        assert topologyComponentCpuPcorePercent != null;
+        assert topologyComponentResourcesOffheapMemoryMb != null;
+        assert topologyComponentResourcesOnheapMemoryMb != null;
 
         Map<String, Double> defaultResourceList = new HashMap<>();
         defaultResourceList.put(Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT, topologyComponentCpuPcorePercent);
@@ -447,13 +442,10 @@ public class TopologyDetails {
      */
     private void initConfigs() {
         this.topologyWorkerMaxHeapSize = Utils.getDouble(this.topologyConf.get(Config.TOPOLOGY_WORKER_MAX_HEAP_SIZE_MB), null);
-        if (this.topologyWorkerMaxHeapSize == null) {
-            LOG.warn("default value for " + Config.TOPOLOGY_WORKER_MAX_HEAP_SIZE_MB + " needs to be set!");
-        }
         this.topologyPriority = Utils.getInt(this.topologyConf.get(Config.TOPOLOGY_PRIORITY), null);
-        if (this.topologyPriority == null) {
-            LOG.warn("default value for " + Config.TOPOLOGY_PRIORITY + " needs to be set!");
-        }
+
+        assert this.topologyWorkerMaxHeapSize != null;
+        assert this.topologyPriority != null;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/storm/blob/068a8c21/storm-core/src/jvm/backtype/storm/scheduler/resource/RAS_Node.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/scheduler/resource/RAS_Node.java b/storm-core/src/jvm/backtype/storm/scheduler/resource/RAS_Node.java
index a38d9f9..16c60cf 100644
--- a/storm-core/src/jvm/backtype/storm/scheduler/resource/RAS_Node.java
+++ b/storm-core/src/jvm/backtype/storm/scheduler/resource/RAS_Node.java
@@ -196,7 +196,7 @@ public class RAS_Node {
      * @param ws the slot to free
      */
     public void free(WorkerSlot ws) {
-        LOG.info("freeing ws {} on node {}", ws, _hostname);
+        LOG.info("freeing WorkerSlot {} on node {}", ws, _hostname);
         if (_freeSlots.contains(ws)) return;
         for (Entry<String, Set<WorkerSlot>> entry : _topIdToUsedSlots.entrySet()) {
             Set<WorkerSlot> slots = entry.getValue();

http://git-wip-us.apache.org/repos/asf/storm/blob/068a8c21/storm-core/src/jvm/backtype/storm/scheduler/resource/RAS_Nodes.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/scheduler/resource/RAS_Nodes.java b/storm-core/src/jvm/backtype/storm/scheduler/resource/RAS_Nodes.java
index abba0b0..bdf0cca 100644
--- a/storm-core/src/jvm/backtype/storm/scheduler/resource/RAS_Nodes.java
+++ b/storm-core/src/jvm/backtype/storm/scheduler/resource/RAS_Nodes.java
@@ -53,9 +53,9 @@ public class RAS_Nodes {
             LOG.debug("resources_mem: {}, resources_CPU: {}", sup.getTotalMemory(), sup.getTotalCPU());
             nodeIdToNode.put(sup.getId(), new RAS_Node(id, sup.getAllPorts(), isAlive, sup, cluster, topologies));
         }
-        for (Map.Entry<String, SchedulerAssignment> entry : cluster.getAssignments().entrySet()) {
-            String topId = entry.getValue().getTopologyId();
-            for (WorkerSlot workerSlot : entry.getValue().getSlots()) {
+        for (SchedulerAssignment assignment : cluster.getAssignments().values()) {
+            String topId = assignment.getTopologyId();
+            for (WorkerSlot workerSlot : assignment.getSlots()) {
                 String id = workerSlot.getNodeId();
                 RAS_Node node = nodeIdToNode.get(id);
                 if (node == null) {
@@ -69,7 +69,7 @@ public class RAS_Nodes {
                     node.addOrphanedSlot(workerSlot);
                 }
                 if (node.assignInternal(workerSlot, topId, true)) {
-                    LOG.warn("Bad scheduling state, " + workerSlot + " assigned multiple workers, unassigning everything...");
+                    LOG.warn("Bad scheduling state, {} assigned multiple workers, unassigning everything...", workerSlot);
                     node.free(workerSlot);
                 }
             }