{"action":"created","comment":{"url":"https://api.github.com/repos/apache/storm/pulls/comments/55007994","id":55007994,"diff_hunk":"@@ -0,0 +1,605 @@\n+/**\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package org.apache.storm.daemon;\n+\n+import com.codahale.metrics.MetricRegistry;\n+import org.apache.storm.Config;\n+import org.apache.storm.Constants;\n+import org.apache.storm.Thrift;\n+import org.apache.storm.cluster.IStormClusterState;\n+import org.apache.storm.daemon.metrics.MetricsUtils;\n+import org.apache.storm.daemon.metrics.reporters.PreparableReporter;\n+import org.apache.storm.generated.*;\n+import org.apache.storm.generated.StormBase;\n+import org.apache.storm.metric.EventLoggerBolt;\n+import org.apache.storm.metric.MetricsConsumerBolt;\n+import org.apache.storm.metric.SystemBolt;\n+import org.apache.storm.security.auth.IAuthorizer;\n+import org.apache.storm.task.IBolt;\n+import org.apache.storm.testing.NonRichBoltTracker;\n+import org.apache.storm.utils.ConfigUtils;\n+import org.apache.storm.utils.IPredicate;\n+import org.apache.storm.utils.ThriftTopologyUtils;\n+import org.apache.storm.utils.Utils;\n+import org.json.simple.JSONValue;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import java.util.*;\n+\n+public class StormCommon {\n+    // A singleton instance allows us to mock delegated static methods in our\n+    // tests by subclassing.\n+    private static StormCommon _instance = new StormCommon();\n+\n+    /**\n+     * Provide an instance of this class for delegates to use.  To mock out\n+     * delegated methods, provide an instance of a subclass that overrides the\n+     * implementation of the delegated method.\n+     * @param common a StormCommon instance\n+     * @return the previously set instance\n+     */\n+    public static StormCommon setInstance(StormCommon common) {\n+        StormCommon oldInstance = _instance;\n+        _instance = common;\n+        return oldInstance;\n+    }\n+\n+    private static final Logger LOG = LoggerFactory.getLogger(StormCommon.class);\n+\n+    public static final String ACKER_COMPONENT_ID = Acker.ACKER_COMPONENT_ID;\n+    public static final String ACKER_INIT_STREAM_ID = Acker.ACKER_INIT_STREAM_ID;\n+    public static final String ACKER_ACK_STREAM_ID = Acker.ACKER_ACK_STREAM_ID;\n+    public static final String ACKER_FAIL_STREAM_ID = Acker.ACKER_FAIL_STREAM_ID;\n+\n+    public static final String SYSTEM_STREAM_ID = \"__system\";\n+\n+    public static final String EVENTLOGGER_COMPONENT_ID = \"__eventlogger\";\n+    public static final String EVENTLOGGER_STREAM_ID = \"__eventlog\";\n+\n+    public static void startMetricsReporter(PreparableReporter report, Map conf) {\n+        report.prepare(new MetricRegistry(), conf);\n+        report.start();\n+        LOG.info(\"Started statistics report plugin...\");\n+    }\n+\n+    public static void startMetricsReporters(Map conf) {\n+        List<PreparableReporter> reporters = MetricsUtils.getPreparableReporters(conf);\n+        for (PreparableReporter reporter : reporters) {\n+            startMetricsReporter(reporter, conf);\n+        }\n+    }\n+\n+    public static String getTopologyNameById(String topologyId) {\n+        String topologyName = null;\n+        try {\n+            topologyName = topologyIdToName(topologyId);\n+        } catch (InvalidTopologyException e) {\n+            LOG.error(\"Invalid topologyId=\" + topologyId);\n+        }\n+        return topologyName;\n+    }\n+\n+    /**\n+     * Convert topologyId to topologyName. TopologyId = topoloygName-counter-timeStamp\n+     *\n+     * @param topologyId\n+     * @return\n+     */\n+    public static String topologyIdToName(String topologyId) throws InvalidTopologyException {\n+        String ret = null;\n+        int index = topologyId.lastIndexOf('-');\n+        if (index != -1 && index > 2) {\n+            index = topologyId.lastIndexOf('-', index - 1);\n+            if (index != -1 && index > 0)\n+                ret = topologyId.substring(0, index);\n+            else\n+                throw new InvalidTopologyException(topologyId + \" is not a valid topologyId\");\n+        } else\n+            throw new InvalidTopologyException(topologyId + \" is not a valid topologyId\");\n+        return ret;\n+    }\n+\n+    public static String getStormId(IStormClusterState stormClusterState, final String topologyName) {\n+        List<String> activeTopologys = stormClusterState.activeStorms();\n+        IPredicate pred = new IPredicate<String>() {\n+            @Override\n+            public boolean test(String obj) {\n+                return obj != null ? getTopologyNameById(obj).equals(topologyName) : false;\n+            }\n+        };\n+        return Utils.findOne(pred, activeTopologys);\n+    }\n+\n+    public static Map<String, StormBase> topologyBases(IStormClusterState stormClusterState) {\n+        return _instance.topologyBasesImpl(stormClusterState);\n+    }\n+\n+    protected Map<String, StormBase> topologyBasesImpl(IStormClusterState stormClusterState) {\n+        List<String> activeTopologys = stormClusterState.activeStorms();\n+        Map<String, StormBase> stormBases = new HashMap<String, StormBase>();\n+        if (activeTopologys != null) {\n+            for (String topologyId : activeTopologys) {\n+                StormBase base = stormClusterState.stormBase(topologyId, null);\n+                if (base != null) {\n+                    stormBases.put(topologyId, base);\n+                }\n+            }\n+        }\n+        return stormBases;\n+    }\n+\n+    public static void validateDistributedMode(Map conf) {\n+        if (ConfigUtils.isLocalMode(conf)) {\n+            throw new IllegalArgumentException(\"Cannot start server in local mode!\");\n+        }\n+    }\n+\n+    private static void validateIds(StormTopology topology) throws InvalidTopologyException {\n+        List<String> componentIds = new ArrayList<String>();\n+\n+        for (StormTopology._Fields field : Thrift.getTopologyFields()) {\n+            if (ThriftTopologyUtils.isWorkerHook(field) == false) {\n+                Object value = topology.getFieldValue(field);\n+                if (value != null) {\n+                    Map<String, Object> componentMap = (Map<String, Object>) value;\n+                    componentIds.addAll(componentMap.keySet());\n+\n+                    for (String id : componentMap.keySet()) {\n+                        if (Utils.isSystemId(id)) {\n+                            throw new InvalidTopologyException(id + \" is not a valid component id.\");\n+                        }\n+                    }\n+                    for (Object componentObj : componentMap.values()) {\n+                        ComponentCommon common = getComponentCommon(componentObj);\n+                        Set<String> streamIds = common.get_streams().keySet();\n+                        for (String id : streamIds) {\n+                            if (Utils.isSystemId(id)) {\n+                                throw new InvalidTopologyException(id + \" is not a valid stream id.\");\n+                            }\n+                        }\n+                    }\n+                }\n+            }\n+        }\n+\n+        List<String> offending = Utils.getRepeat(componentIds);\n+        if (offending.isEmpty() == false) {\n+            throw new InvalidTopologyException(\"Duplicate component ids: \" + offending);\n+        }\n+    }\n+\n+    private static boolean isEmptyInputs(ComponentCommon common) {\n+        if (common == null) {\n+            return true;\n+        } else if (common.get_inputs() == null) {\n+            return true;\n+        } else {\n+            return common.get_inputs().isEmpty();\n+        }\n+    }\n+\n+    public static Map<String, Object> allComponents(StormTopology topology) {\n+        Map<String, Object> components = new HashMap<String, Object>();\n+        List<StormTopology._Fields> topologyFields = Arrays.asList(Thrift.getTopologyFields());\n+        for (StormTopology._Fields field : topologyFields) {\n+            if (ThriftTopologyUtils.isWorkerHook(field) == false) {\n+                components.putAll(((Map) topology.getFieldValue(field)));\n+            }\n+        }\n+        return components;\n+    }\n+\n+    public static Map componentConf(Object component) {\n+        Map<Object, Object> conf = new HashMap<Object, Object>();\n+        ComponentCommon common = getComponentCommon(component);\n+        if (common != null) {\n+            String jconf = common.get_json_conf();\n+            if (jconf != null) {\n+                conf.putAll((Map<Object, Object>) JSONValue.parse(jconf));\n+            }\n+        }\n+        return conf;\n+    }\n+\n+    public static void validateBasic(StormTopology topology) throws InvalidTopologyException {\n+        validateIds(topology);\n+\n+        List<StormTopology._Fields> spoutFields = Arrays.asList(Thrift.getSpoutFields());\n+        for (StormTopology._Fields field : spoutFields) {\n+            Map<String, Object> spoutComponents = (Map<String, Object>) topology.getFieldValue(field);\n+            if (spoutComponents != null) {\n+                for (Object obj : spoutComponents.values()) {\n+                    ComponentCommon common = getComponentCommon(obj);\n+                    if (isEmptyInputs(common) == false) {\n+                        throw new InvalidTopologyException(\"May not declare inputs for a spout\");\n+                    }\n+                }\n+            }\n+        }\n+\n+        Map<String, Object> componentMap = allComponents(topology);\n+        for (Object componentObj : componentMap.values()) {\n+            Map conf = componentConf(componentObj);\n+            ComponentCommon common = getComponentCommon(componentObj);\n+            if (common != null) {\n+                int parallelismHintNum = Thrift.getParallelismHint(common);\n+                Integer taskNum = Utils.getInt(conf.get(Config.TOPOLOGY_TASKS), 0);\n+                if (taskNum > 0 && parallelismHintNum <= 0) {\n+                    throw new InvalidTopologyException(\"Number of executors must be greater than 0 when number of tasks is greater than 0\");\n+                }\n+            }\n+        }\n+    }\n+\n+    private static Set<String> getStreamOutputFields(Map<String, StreamInfo> streams) {\n+        Set<String> outputFields = new HashSet<String>();\n+        if (streams != null) {\n+            for (StreamInfo streamInfo : streams.values()) {\n+                outputFields.addAll(streamInfo.get_output_fields());\n+            }\n+        }\n+        return outputFields;\n+    }\n+\n+    public static void validateStructure(StormTopology topology) throws InvalidTopologyException {\n+        Map<String, Object> componentMap = allComponents(topology);\n+        for (Map.Entry<String, Object> entry : componentMap.entrySet()) {\n+            String componentId = entry.getKey();\n+            ComponentCommon common = getComponentCommon(entry.getValue());\n+            if (common != null) {\n+                Map<GlobalStreamId, Grouping> inputs = common.get_inputs();\n+                for (Map.Entry<GlobalStreamId, Grouping> input : inputs.entrySet()) {\n+                    String sourceStreamId = input.getKey().get_streamId();\n+                    String sourceComponentId = input.getKey().get_componentId();\n+                    if(componentMap.keySet().contains(sourceComponentId) == false) {\n+                        throw new InvalidTopologyException(\"Component: [\" + componentId + \"] subscribes from non-existent component [\" + sourceComponentId + \"]\");\n+                    }\n+\n+                    ComponentCommon sourceComponent = getComponentCommon(componentMap.get(sourceComponentId));\n+                    if (sourceComponent == null || sourceComponent.get_streams().containsKey(sourceStreamId) == false) {\n+                        throw new InvalidTopologyException(\"Component: [\" + componentId + \"] subscribes from non-existent stream: \" +\n+                                \"[\" + sourceStreamId + \"] of component [\" + sourceComponentId + \"]\");\n+                    }\n+\n+                    Grouping grouping = input.getValue();\n+                    if (Thrift.groupingType(grouping) == Grouping._Fields.FIELDS) {\n+                        List<String> fields = grouping.get_fields();\n+                        Map<String, StreamInfo> streams = sourceComponent.get_streams();\n+                        Set<String> sourceOutputFields = getStreamOutputFields(streams);\n+                        if (sourceOutputFields.containsAll(fields) == false) {\n+                            throw new InvalidTopologyException(\"Component: [\" + componentId + \"] subscribes from stream: [\" + sourceStreamId  +\"] of component \" +\n+                                    \"[\" + sourceComponentId + \"] + with non-existent fields: \" + fields);\n+                        }\n+                    }\n+                }\n+            }\n+        }\n+    }\n+\n+    public static Map<GlobalStreamId, Grouping> ackerInputs(StormTopology topology) {\n+        Map<GlobalStreamId, Grouping> inputs = new HashMap<GlobalStreamId, Grouping>();\n+        Set<String> boltIds = topology.get_bolts().keySet();\n+        Set<String> spoutIds = topology.get_spouts().keySet();\n+\n+        for(String id : spoutIds) {\n+            inputs.put(Utils.getGlobalStreamId(id, ACKER_INIT_STREAM_ID), Thrift.prepareFieldsGrouping(Arrays.asList(\"id\")));\n+        }\n+\n+        for(String id : boltIds) {\n+            inputs.put(Utils.getGlobalStreamId(id, ACKER_ACK_STREAM_ID), Thrift.prepareFieldsGrouping(Arrays.asList(\"id\")));\n+            inputs.put(Utils.getGlobalStreamId(id, ACKER_FAIL_STREAM_ID), Thrift.prepareFieldsGrouping(Arrays.asList(\"id\")));\n+        }\n+        return inputs;\n+    }\n+\n+    public static String clusterId = null;\n+    public static IBolt makeAckerBolt() {\n+        return _instance.makeAckerBoltImpl();\n+    }\n+    public IBolt makeAckerBoltImpl() {\n+        return new Acker();\n+    }\n+\n+    public static void addAcker(Map conf, StormTopology topology) {\n+        int ackerNum = Utils.getInt(conf.get(Config.TOPOLOGY_ACKER_EXECUTORS), Utils.getInt(conf.get(Config.TOPOLOGY_WORKERS)));\n+        Map<GlobalStreamId, Grouping> inputs = ackerInputs(topology);\n+\n+        Map<String, StreamInfo> outputStreams = new HashMap<String, StreamInfo>();\n+        outputStreams.put(ACKER_ACK_STREAM_ID, Thrift.directOutputFields(Arrays.asList(\"id\")));\n+        outputStreams.put(ACKER_FAIL_STREAM_ID, Thrift.directOutputFields(Arrays.asList(\"id\")));\n+\n+        Map<String, Object> ackerConf = new HashMap<String, Object>();\n+        ackerConf.put(Config.TOPOLOGY_TASKS, ackerNum);\n+        ackerConf.put(Config.TOPOLOGY_TICK_TUPLE_FREQ_SECS, Utils.getInt(conf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS)));\n+\n+        Bolt acker = Thrift.prepareSerializedBoltDetails(inputs, makeAckerBolt(), outputStreams, ackerNum, ackerConf);\n+\n+        for(Bolt bolt : topology.get_bolts().values()) {\n+            ComponentCommon common = bolt.get_common();\n+            common.put_to_streams(ACKER_ACK_STREAM_ID, Thrift.outputFields(Arrays.asList(\"id\", \"ack-val\")));\n+            common.put_to_streams(ACKER_FAIL_STREAM_ID, Thrift.outputFields(Arrays.asList(\"id\")));\n+        }\n+\n+        for (SpoutSpec spout : topology.get_spouts().values()) {\n+            ComponentCommon common = spout.get_common();\n+            Map spoutConf = componentConf(spout);\n+            spoutConf.put(Config.TOPOLOGY_TICK_TUPLE_FREQ_SECS, Utils.getInt(conf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS)));\n+            common.set_json_conf(JSONValue.toJSONString(spoutConf));\n+            common.put_to_streams(ACKER_INIT_STREAM_ID, Thrift.outputFields(Arrays.asList(\"id\", \"init-val\", \"spout-task\")));\n+            common.put_to_inputs(Utils.getGlobalStreamId(ACKER_COMPONENT_ID, ACKER_ACK_STREAM_ID), Thrift.prepareDirectGrouping());\n+            common.put_to_inputs(Utils.getGlobalStreamId(ACKER_COMPONENT_ID, ACKER_FAIL_STREAM_ID), Thrift.prepareDirectGrouping());\n+        }\n+\n+        topology.put_to_bolts(ACKER_COMPONENT_ID, acker);\n+    }\n+\n+    public static ComponentCommon getComponentCommon(Object component) {\n+        if (component == null) {\n+            return null;\n+        }\n+\n+        ComponentCommon common = null;\n+        if (component instanceof StateSpoutSpec) {\n+            common = ((StateSpoutSpec) component).get_common();\n+        } else if (component instanceof SpoutSpec) {\n+            common = ((SpoutSpec) component).get_common();\n+        } else if (component instanceof Bolt) {\n+            common = ((Bolt) component).get_common();\n+        }\n+        return common;\n+    }\n+\n+    public static void addMetricStreams(StormTopology topology) {\n+        for (Object component : allComponents(topology).values()) {\n+            ComponentCommon common = getComponentCommon(component);\n+            if (common != null) {\n+                StreamInfo streamInfo = Thrift.outputFields(Arrays.asList(\"task-info\", \"data-points\"));\n+                common.put_to_streams(Constants.METRICS_STREAM_ID, streamInfo);\n+            }\n+        }\n+    }\n+\n+    public static void addSystemStreams(StormTopology topology) {\n+        for (Object component : allComponents(topology).values()) {\n+            ComponentCommon common = getComponentCommon(component);\n+            if (common != null) {\n+                StreamInfo streamInfo = Thrift.outputFields(Arrays.asList(\"event\"));\n+                common.put_to_streams(SYSTEM_STREAM_ID, streamInfo);\n+            }\n+        }\n+    }\n+\n+    public static List<String> eventLoggerBoltFields() {\n+        List<String> fields = Arrays.asList(EventLoggerBolt.FIELD_COMPONENT_ID, EventLoggerBolt.FIELD_MESSAGE_ID, EventLoggerBolt.FIELD_TS,\n+                EventLoggerBolt.FIELD_VALUES);\n+        return fields;\n+    }\n+\n+    public static Map<GlobalStreamId, Grouping> eventLoggerInputs(StormTopology topology) {\n+        Map<GlobalStreamId, Grouping> inputs = new HashMap<GlobalStreamId, Grouping>();\n+        Set<String> allIds = new HashSet<String>();\n+        allIds.addAll(topology.get_bolts().keySet());\n+        allIds.addAll(topology.get_spouts().keySet());\n+\n+        for(String id : allIds) {\n+            inputs.put(Utils.getGlobalStreamId(id, EVENTLOGGER_STREAM_ID), Thrift.prepareFieldsGrouping(Arrays.asList(\"component-id\")));\n+        }\n+        return inputs;\n+    }\n+\n+    public static void addEventLogger(Map conf, StormTopology topology) {\n+        Integer numExecutors = Utils.getInt(conf.get(Config.TOPOLOGY_EVENTLOGGER_EXECUTORS), Utils.getInt(conf.get(Config.TOPOLOGY_WORKERS)));\n+        HashMap<String, Object> componentConf = new HashMap<String, Object>();\n+        componentConf.put(Config.TOPOLOGY_TASKS, numExecutors);\n+        componentConf.put(Config.TOPOLOGY_TICK_TUPLE_FREQ_SECS, Utils.getInt(conf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS)));\n+        Bolt eventLoggerBolt = Thrift.prepareSerializedBoltDetails(eventLoggerInputs(topology), new EventLoggerBolt(), null, numExecutors, componentConf);\n+\n+        for(Object component : allComponents(topology).values()) {\n+            ComponentCommon common = getComponentCommon(component);\n+            if (common != null) {\n+                common.put_to_streams(EVENTLOGGER_STREAM_ID, Thrift.outputFields(eventLoggerBoltFields()));\n+            }\n+        }\n+        topology.put_to_bolts(EVENTLOGGER_COMPONENT_ID, eventLoggerBolt);\n+    }\n+\n+    public static Map<String, Bolt> metricsConsumerBoltSpecs(Map conf, StormTopology topology) {\n+        Map<String, Bolt> metricsConsumerBolts = new HashMap<String, Bolt>();\n+\n+        Set<String> componentIdsEmitMetrics = new HashSet<String>();\n+        componentIdsEmitMetrics.addAll(allComponents(topology).keySet());\n+        componentIdsEmitMetrics.add(Constants.SYSTEM_COMPONENT_ID);\n+\n+        Map<GlobalStreamId, Grouping> inputs = new HashMap<GlobalStreamId, Grouping>();\n+        for (String componentId : componentIdsEmitMetrics) {\n+            inputs.put(Utils.getGlobalStreamId(componentId, Constants.METRICS_STREAM_ID), Thrift.prepareShuffleGrouping());\n+        }\n+\n+        List<Map<String, Object>> registerInfo = (List<Map<String, Object>>) conf.get(Config.TOPOLOGY_METRICS_CONSUMER_REGISTER);\n+        if (registerInfo != null) {\n+            Map<String, Integer> classOccurrencesMap = new HashMap<String, Integer>();\n+            for (Map<String, Object> info : registerInfo) {\n+                String className = (String) info.get(\"class\");\n+                Object argument = info.get(\"argument\");\n+                Integer phintNum = Utils.getInt(info.get(\"parallelism.hint\"), 1);\n+                Map<String, Object> metricsConsumerConf = new HashMap<String, Object>();\n+                metricsConsumerConf.put(Config.TOPOLOGY_TASKS, phintNum);\n+                Bolt metricsConsumerBolt = Thrift.prepareSerializedBoltDetails(inputs, new MetricsConsumerBolt(className, argument), null, phintNum, metricsConsumerConf);\n+\n+                String id = className;\n+                if (classOccurrencesMap.containsKey(className)) {\n+                    // e.g. [\\\"a\\\", \\\"b\\\", \\\"a\\\"]) => [\\\"a\\\", \\\"b\\\", \\\"a#2\\\"]\"\n+                    int occurrenceNum = classOccurrencesMap.get(className);\n+                    occurrenceNum++;\n+                    classOccurrencesMap.put(className, occurrenceNum);\n+                    id = Constants.METRICS_COMPONENT_ID_PREFIX + className + \"#\" + occurrenceNum;\n+                } else {\n+                    classOccurrencesMap.put(className, 1);\n+                }\n+                metricsConsumerBolts.put(id, metricsConsumerBolt);\n+            }\n+        }\n+        return metricsConsumerBolts;\n+    }\n+\n+    public static void addMetricComponents(Map conf, StormTopology topology) {\n+        Map<String, Bolt> metricsConsumerBolts = metricsConsumerBoltSpecs(conf, topology);\n+        for (Map.Entry<String, Bolt> entry : metricsConsumerBolts.entrySet()) {\n+            topology.put_to_bolts(entry.getKey(), entry.getValue());\n+        }\n+    }\n+\n+    public static void addSystemComponents(Map conf, StormTopology topology) {\n+        Map<String, StreamInfo> outputStreams = new HashMap<String, StreamInfo>();\n+        outputStreams.put(Constants.SYSTEM_TICK_STREAM_ID, Thrift.outputFields(Arrays.asList(\"rate_secs\")));\n+        outputStreams.put(Constants.METRICS_TICK_STREAM_ID, Thrift.outputFields(Arrays.asList(\"interval\")));\n+        outputStreams.put(Constants.CREDENTIALS_CHANGED_STREAM_ID, Thrift.outputFields(Arrays.asList(\"creds\")));\n+\n+        Map<String, Object> boltConf = new HashMap<String, Object>();\n+        boltConf.put(Config.TOPOLOGY_TASKS, 0);\n+\n+        Bolt systemBoltSpec = Thrift.prepareSerializedBoltDetails(null, new SystemBolt(), outputStreams, 0, boltConf);\n+        topology.put_to_bolts(Constants.SYSTEM_COMPONENT_ID, systemBoltSpec);\n+    }\n+\n+    public static StormTopology systemTopology(Map stormConf, StormTopology topology) throws InvalidTopologyException {\n+        return _instance.systemTopologyImpl(stormConf, topology);\n+    }\n+\n+    protected StormTopology systemTopologyImpl(Map stormConf, StormTopology topology) throws InvalidTopologyException {\n+        validateBasic(topology);\n+\n+        StormTopology ret = topology.deepCopy();\n+        addAcker(stormConf, ret);\n+        addEventLogger(stormConf, ret);\n+        addMetricComponents(stormConf, ret);\n+        addSystemComponents(stormConf, ret);\n+        addMetricStreams(ret);\n+        addSystemStreams(ret);\n+\n+        validateStructure(ret);\n+\n+        return ret;\n+    }\n+\n+    public static boolean hasAckers(Map stormConf) {","path":"storm-core/src/jvm/org/apache/storm/daemon/StormCommon.java","position":500,"original_position":501,"commit_id":"eca27bc435a7002375a9f8682174afbacf69fc89","original_commit_id":"f6b58a52ad30f35e7a635ffbffdb9fc7c7f2de37","user":{"login":"abhishekagarwal87","id":1477457,"avatar_url":"https://avatars.githubusercontent.com/u/1477457?v=3","gravatar_id":"","url":"https://api.github.com/users/abhishekagarwal87","html_url":"https://github.com/abhishekagarwal87","followers_url":"https://api.github.com/users/abhishekagarwal87/followers","following_url":"https://api.github.com/users/abhishekagarwal87/following{/other_user}","gists_url":"https://api.github.com/users/abhishekagarwal87/gists{/gist_id}","starred_url":"https://api.github.com/users/abhishekagarwal87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abhishekagarwal87/subscriptions","organizations_url":"https://api.github.com/users/abhishekagarwal87/orgs","repos_url":"https://api.github.com/users/abhishekagarwal87/repos","events_url":"https://api.github.com/users/abhishekagarwal87/events{/privacy}","received_events_url":"https://api.github.com/users/abhishekagarwal87/received_events","type":"User","site_admin":false},"body":"hasAckers and hasEventLoggers is only called in executor so they can be moved there or you can move them to ConfigUtils.java since these functions solely operate on conf. ","created_at":"2016-03-04T09:32:33Z","updated_at":"2016-03-04T09:32:33Z","html_url":"https://github.com/apache/storm/pull/1185#discussion_r55007994","pull_request_url":"https://api.github.com/repos/apache/storm/pulls/1185","_links":{"self":{"href":"https://api.github.com/repos/apache/storm/pulls/comments/55007994"},"html":{"href":"https://github.com/apache/storm/pull/1185#discussion_r55007994"},"pull_request":{"href":"https://api.github.com/repos/apache/storm/pulls/1185"}}},"pull_request":{"url":"https://api.github.com/repos/apache/storm/pulls/1185","id":61679504,"html_url":"https://github.com/apache/storm/pull/1185","diff_url":"https://github.com/apache/storm/pull/1185.diff","patch_url":"https://github.com/apache/storm/pull/1185.patch","issue_url":"https://api.github.com/repos/apache/storm/issues/1185","number":1185,"state":"open","locked":false,"title":"[STORM-1269] port backtype.storm.daemon.common to java","user":{"login":"bastiliu","id":7921256,"avatar_url":"https://avatars.githubusercontent.com/u/7921256?v=3","gravatar_id":"","url":"https://api.github.com/users/bastiliu","html_url":"https://github.com/bastiliu","followers_url":"https://api.github.com/users/bastiliu/followers","following_url":"https://api.github.com/users/bastiliu/following{/other_user}","gists_url":"https://api.github.com/users/bastiliu/gists{/gist_id}","starred_url":"https://api.github.com/users/bastiliu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bastiliu/subscriptions","organizations_url":"https://api.github.com/users/bastiliu/orgs","repos_url":"https://api.github.com/users/bastiliu/repos","events_url":"https://api.github.com/users/bastiliu/events{/privacy}","received_events_url":"https://api.github.com/users/bastiliu/received_events","type":"User","site_admin":false},"body":"1. Following clojure defined records in common, \"Assignment, StormBase, SupervisorInfo, ExecutorStats\", were not migrated here. There are corresponding classes of Thrift. So, we can just use the thrift class in the dependency modules after each module's migration.\r\n2. worker-context was not migrated. There is much more worker to convert the worker data between java and clojure now. But it is easy to do this after the worker data is migrated to java. So I recommend to leave the mirgation of worker context as a part of  worker module.","created_at":"2016-03-04T08:11:40Z","updated_at":"2016-03-04T09:32:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1f1687b8d21c95d63e49826c98df8af28c8d95ab","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/storm/pulls/1185/commits","review_comments_url":"https://api.github.com/repos/apache/storm/pulls/1185/comments","review_comment_url":"https://api.github.com/repos/apache/storm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/storm/issues/1185/comments","statuses_url":"https://api.github.com/repos/apache/storm/statuses/eca27bc435a7002375a9f8682174afbacf69fc89","head":{"label":"bastiliu:master","ref":"master","sha":"eca27bc435a7002375a9f8682174afbacf69fc89","user":{"login":"bastiliu","id":7921256,"avatar_url":"https://avatars.githubusercontent.com/u/7921256?v=3","gravatar_id":"","url":"https://api.github.com/users/bastiliu","html_url":"https://github.com/bastiliu","followers_url":"https://api.github.com/users/bastiliu/followers","following_url":"https://api.github.com/users/bastiliu/following{/other_user}","gists_url":"https://api.github.com/users/bastiliu/gists{/gist_id}","starred_url":"https://api.github.com/users/bastiliu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bastiliu/subscriptions","organizations_url":"https://api.github.com/users/bastiliu/orgs","repos_url":"https://api.github.com/users/bastiliu/repos","events_url":"https://api.github.com/users/bastiliu/events{/privacy}","received_events_url":"https://api.github.com/users/bastiliu/received_events","type":"User","site_admin":false},"repo":{"id":46766287,"name":"storm","full_name":"bastiliu/storm","owner":{"login":"bastiliu","id":7921256,"avatar_url":"https://avatars.githubusercontent.com/u/7921256?v=3","gravatar_id":"","url":"https://api.github.com/users/bastiliu","html_url":"https://github.com/bastiliu","followers_url":"https://api.github.com/users/bastiliu/followers","following_url":"https://api.github.com/users/bastiliu/following{/other_user}","gists_url":"https://api.github.com/users/bastiliu/gists{/gist_id}","starred_url":"https://api.github.com/users/bastiliu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bastiliu/subscriptions","organizations_url":"https://api.github.com/users/bastiliu/orgs","repos_url":"https://api.github.com/users/bastiliu/repos","events_url":"https://api.github.com/users/bastiliu/events{/privacy}","received_events_url":"https://api.github.com/users/bastiliu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bastiliu/storm","description":"Mirror of Apache Storm","fork":true,"url":"https://api.github.com/repos/bastiliu/storm","forks_url":"https://api.github.com/repos/bastiliu/storm/forks","keys_url":"https://api.github.com/repos/bastiliu/storm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bastiliu/storm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bastiliu/storm/teams","hooks_url":"https://api.github.com/repos/bastiliu/storm/hooks","issue_events_url":"https://api.github.com/repos/bastiliu/storm/issues/events{/number}","events_url":"https://api.github.com/repos/bastiliu/storm/events","assignees_url":"https://api.github.com/repos/bastiliu/storm/assignees{/user}","branches_url":"https://api.github.com/repos/bastiliu/storm/branches{/branch}","tags_url":"https://api.github.com/repos/bastiliu/storm/tags","blobs_url":"https://api.github.com/repos/bastiliu/storm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bastiliu/storm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bastiliu/storm/git/refs{/sha}","trees_url":"https://api.github.com/repos/bastiliu/storm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bastiliu/storm/statuses/{sha}","languages_url":"https://api.github.com/repos/bastiliu/storm/languages","stargazers_url":"https://api.github.com/repos/bastiliu/storm/stargazers","contributors_url":"https://api.github.com/repos/bastiliu/storm/contributors","subscribers_url":"https://api.github.com/repos/bastiliu/storm/subscribers","subscription_url":"https://api.github.com/repos/bastiliu/storm/subscription","commits_url":"https://api.github.com/repos/bastiliu/storm/commits{/sha}","git_commits_url":"https://api.github.com/repos/bastiliu/storm/git/commits{/sha}","comments_url":"https://api.github.com/repos/bastiliu/storm/comments{/number}","issue_comment_url":"https://api.github.com/repos/bastiliu/storm/issues/comments{/number}","contents_url":"https://api.github.com/repos/bastiliu/storm/contents/{+path}","compare_url":"https://api.github.com/repos/bastiliu/storm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bastiliu/storm/merges","archive_url":"https://api.github.com/repos/bastiliu/storm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bastiliu/storm/downloads","issues_url":"https://api.github.com/repos/bastiliu/storm/issues{/number}","pulls_url":"https://api.github.com/repos/bastiliu/storm/pulls{/number}","milestones_url":"https://api.github.com/repos/bastiliu/storm/milestones{/number}","notifications_url":"https://api.github.com/repos/bastiliu/storm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bastiliu/storm/labels{/name}","releases_url":"https://api.github.com/repos/bastiliu/storm/releases{/id}","deployments_url":"https://api.github.com/repos/bastiliu/storm/deployments","created_at":"2015-11-24T04:12:48Z","updated_at":"2016-02-01T03:19:49Z","pushed_at":"2016-03-04T09:26:13Z","git_url":"git://github.com/bastiliu/storm.git","ssh_url":"git@github.com:bastiliu/storm.git","clone_url":"https://github.com/bastiliu/storm.git","svn_url":"https://github.com/bastiliu/storm","homepage":null,"size":153739,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"672c8951bbee8348a4c686511e4f3f84c00d8385","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":14135470,"name":"storm","full_name":"apache/storm","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/storm","description":"Mirror of Apache Storm","fork":false,"url":"https://api.github.com/repos/apache/storm","forks_url":"https://api.github.com/repos/apache/storm/forks","keys_url":"https://api.github.com/repos/apache/storm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/storm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/storm/teams","hooks_url":"https://api.github.com/repos/apache/storm/hooks","issue_events_url":"https://api.github.com/repos/apache/storm/issues/events{/number}","events_url":"https://api.github.com/repos/apache/storm/events","assignees_url":"https://api.github.com/repos/apache/storm/assignees{/user}","branches_url":"https://api.github.com/repos/apache/storm/branches{/branch}","tags_url":"https://api.github.com/repos/apache/storm/tags","blobs_url":"https://api.github.com/repos/apache/storm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/storm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/storm/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/storm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/storm/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/storm/languages","stargazers_url":"https://api.github.com/repos/apache/storm/stargazers","contributors_url":"https://api.github.com/repos/apache/storm/contributors","subscribers_url":"https://api.github.com/repos/apache/storm/subscribers","subscription_url":"https://api.github.com/repos/apache/storm/subscription","commits_url":"https://api.github.com/repos/apache/storm/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/storm/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/storm/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/storm/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/storm/contents/{+path}","compare_url":"https://api.github.com/repos/apache/storm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/storm/merges","archive_url":"https://api.github.com/repos/apache/storm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/storm/downloads","issues_url":"https://api.github.com/repos/apache/storm/issues{/number}","pulls_url":"https://api.github.com/repos/apache/storm/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/storm/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/storm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/storm/labels{/name}","releases_url":"https://api.github.com/repos/apache/storm/releases{/id}","deployments_url":"https://api.github.com/repos/apache/storm/deployments","created_at":"2013-11-05T08:00:14Z","updated_at":"2016-03-04T08:13:43Z","pushed_at":"2016-03-04T09:26:14Z","git_url":"git://github.com/apache/storm.git","ssh_url":"git@github.com:apache/storm.git","clone_url":"https://github.com/apache/storm.git","svn_url":"https://github.com/apache/storm","homepage":null,"size":158779,"stargazers_count":2907,"watchers_count":2907,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":2177,"mirror_url":"git://git.apache.org/storm.git","open_issues_count":101,"forks":2177,"open_issues":101,"watchers":2907,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/storm/pulls/1185"},"html":{"href":"https://github.com/apache/storm/pull/1185"},"issue":{"href":"https://api.github.com/repos/apache/storm/issues/1185"},"comments":{"href":"https://api.github.com/repos/apache/storm/issues/1185/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/storm/pulls/1185/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/storm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/storm/pulls/1185/commits"},"statuses":{"href":"https://api.github.com/repos/apache/storm/statuses/eca27bc435a7002375a9f8682174afbacf69fc89"}}}}