You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by pt...@apache.org on 2016/01/13 18:22:32 UTC

[06/11] storm git commit: resolve conflicts

resolve conflicts


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

Branch: refs/heads/1.x-branch
Commit: bf45b96e496551e9319eae26cde985965afea5cf
Parents: f659ef0
Author: Xin Wang <be...@163.com>
Authored: Sat Jan 9 22:00:19 2016 +0800
Committer: vesense <be...@163.com>
Committed: Wed Jan 13 13:39:00 2016 +0800

----------------------------------------------------------------------
 .../apache/storm/solr/bolt/SolrUpdateBolt.java  | 27 +++-----
 .../apache/storm/solr/config/SolrConfig.java    | 17 +++--
 .../jvm/backtype/storm/utils/TupleUtils.java    | 35 -----------
 .../jvm/org/apache/storm/utils/TupleUtils.java  | 65 ++++++++++++++++++++
 4 files changed, 86 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/bf45b96e/external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java
----------------------------------------------------------------------
diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java b/external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java
index 0c20d6c..8d4affd 100644
--- a/external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java
+++ b/external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java
@@ -53,7 +53,7 @@ public class SolrUpdateBolt extends BaseRichBolt {
     private SolrClient solrClient;
     private OutputCollector collector;
     private List<Tuple> toCommitTuples;
-    private Integer tickTupleInterval = 0;
+    private int tickTupleInterval;
 
     public SolrUpdateBolt(SolrConfig solrConfig, SolrMapper solrMapper) {
         this(solrConfig, solrMapper, null);
@@ -73,15 +73,17 @@ public class SolrUpdateBolt extends BaseRichBolt {
         this.collector = collector;
         this.solrClient = new CloudSolrClient(solrConfig.getZkHostString());
         this.toCommitTuples = new ArrayList<>(capacity());
-        this.tickTupleInterval = solrConfig.getTickTupleInterval();
 
-        //set default tickTupleInterval
-        if (stormConf.containsKey("topology.message.timeout.secs") && tickTupleInterval == 0) {
+        setTickTupleInterval(stormConf);   
+    }
+
+    private void setTickTupleInterval(Map stormConf) {
+        this.tickTupleInterval = solrConfig.getTickTupleInterval();
+        if(stormConf.containsKey(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS)  && tickTupleInterval == 0) {
             Integer topologyTimeout = Utils.getInt(stormConf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS));
             tickTupleInterval = (int)(Math.floor(topologyTimeout / 2));
             LOG.debug("Setting tick tuple interval to [{}] based on topology timeout", tickTupleInterval);
         }
-
     }
 
     private int capacity() {
@@ -94,7 +96,7 @@ public class SolrUpdateBolt extends BaseRichBolt {
     @Override
     public void execute(Tuple tuple) {
         try {
-            if (!TupleUtils.isTick(tuple)) {//Don't add tick tuples to the SolrRequest
+            if (!TupleUtils.isTick(tuple)) {    // Don't add tick tuples to the SolrRequest
                 SolrRequest request = solrMapper.toSolrRequest(tuple);
                 solrClient.request(request, solrMapper.getCollection());
             }
@@ -109,7 +111,7 @@ public class SolrUpdateBolt extends BaseRichBolt {
             collector.ack(tuple);
         } else {
             final boolean isTickTuple = TupleUtils.isTick(tuple);
-            if (!isTickTuple) {
+            if (!isTickTuple) {    // Don't ack tick tuples
                 toCommitTuples.add(tuple);
                 commitStgy.update();
             }
@@ -152,16 +154,7 @@ public class SolrUpdateBolt extends BaseRichBolt {
 
     @Override
     public Map<String, Object> getComponentConfiguration() {
-        Map<String, Object> conf = super.getComponentConfiguration();
-        if (conf == null)
-            conf = new Config();
-
-        if (tickTupleInterval > 0) {
-            LOG.info("Enabling tick tuple with interval [{}]", tickTupleInterval);
-            conf.put(Config.TOPOLOGY_TICK_TUPLE_FREQ_SECS, tickTupleInterval);
-        }
-
-        return conf;
+        return TupleUtils.putTickFreqencyIntoComponentConfig(super.getComponentConfiguration(), tickTupleInterval);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/storm/blob/bf45b96e/external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrConfig.java
----------------------------------------------------------------------
diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrConfig.java b/external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrConfig.java
index f895912..1803a96 100644
--- a/external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrConfig.java
+++ b/external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrConfig.java
@@ -27,14 +27,23 @@ import java.io.Serializable;
  * the bolts should be put in this class.
  */
 public class SolrConfig implements Serializable {
-    private String zkHostString;
-    private int tickTupleInterval;
+    private final String zkHostString;
+    private final int tickTupleInterval;
 
     /**
      * @param zkHostString Zookeeper host string as defined in the {@link CloudSolrClient} constructor
      * */
     public SolrConfig(String zkHostString) {
+       this(zkHostString, 0);
+    }
+
+    /**
+     * @param zkHostString Zookeeper host string as defined in the {@link CloudSolrClient} constructor
+     * @param tickTupleInterval interval for tick tuples
+     * */
+    public SolrConfig(String zkHostString, int tickTupleInterval) {
         this.zkHostString = zkHostString;
+        this.tickTupleInterval = tickTupleInterval;
     }
 
     public String getZkHostString() {
@@ -45,8 +54,4 @@ public class SolrConfig implements Serializable {
         return tickTupleInterval;
     }
 
-    public void setTickTupleInterval(int tickTupleInterval) {
-        this.tickTupleInterval = tickTupleInterval;
-    }
-    
 }

http://git-wip-us.apache.org/repos/asf/storm/blob/bf45b96e/storm-core/src/jvm/backtype/storm/utils/TupleUtils.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/utils/TupleUtils.java b/storm-core/src/jvm/backtype/storm/utils/TupleUtils.java
deleted file mode 100644
index f9fb2c0..0000000
--- a/storm-core/src/jvm/backtype/storm/utils/TupleUtils.java
+++ /dev/null
@@ -1,35 +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 backtype.storm.utils;
-
-import backtype.storm.Constants;
-import backtype.storm.tuple.Tuple;
-
-public final class TupleUtils {
-
-  private TupleUtils() {
-    // No instantiation
-  }
-
-  public static boolean isTick(Tuple tuple) {
-    return tuple != null
-           && Constants.SYSTEM_COMPONENT_ID  .equals(tuple.getSourceComponent())
-           && Constants.SYSTEM_TICK_STREAM_ID.equals(tuple.getSourceStreamId());
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/storm/blob/bf45b96e/storm-core/src/jvm/org/apache/storm/utils/TupleUtils.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/utils/TupleUtils.java b/storm-core/src/jvm/org/apache/storm/utils/TupleUtils.java
new file mode 100644
index 0000000..338d1c2
--- /dev/null
+++ b/storm-core/src/jvm/org/apache/storm/utils/TupleUtils.java
@@ -0,0 +1,65 @@
+/**
+ * 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.utils;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import backtype.storm.Config;
+import backtype.storm.Constants;
+import backtype.storm.tuple.Tuple;
+
+public final class TupleUtils {
+    private static final Logger LOG = LoggerFactory.getLogger(TupleUtils.class);
+
+    private TupleUtils() {
+      // No instantiation
+    }
+
+    public static boolean isTick(Tuple tuple) {
+      return tuple != null
+             && Constants.SYSTEM_COMPONENT_ID.equals(tuple.getSourceComponent())
+             && Constants.SYSTEM_TICK_STREAM_ID.equals(tuple.getSourceStreamId());
+    }
+
+    public static <T> int listHashCode(List<T> alist) {
+      if (alist == null) {
+          return 1;
+      } else {
+          return Arrays.deepHashCode(alist.toArray());
+      }
+    }
+
+    public static Map<String, Object> putTickFreqencyIntoComponentConfig(Map<String, Object> conf, int tickFreqSecs) {
+      if (conf == null) {
+          conf = new Config();
+      }
+
+      if (tickFreqSecs > 0) {
+          LOG.info("Enabling tick tuple with interval [{}]", tickFreqSecs);
+          conf.put(Config.TOPOLOGY_TICK_TUPLE_FREQ_SECS, tickFreqSecs);
+      }
+
+      return conf;
+    }
+
+}