Github user harshach commented on a diff in the pull request:

    https://github.com/apache/storm/pull/772#discussion_r41083801
  
    --- Diff: 
external/storm-hbase/src/main/java/org/apache/storm/hbase/bolt/HBaseBolt.java 
---
    @@ -53,21 +61,62 @@ public HBaseBolt withConfigKey(String configKey) {
             return this;
         }
     
    +    public HBaseBolt withBatchSize(int batchSize) {
    +        this.batchSize = batchSize;
    +        return this;
    +    }
    +
    +    public HBaseBolt withFlushIntervalSecs(int flushIntervalSecs) {
    +        this.flushIntervalSecs = flushIntervalSecs;
    +        return this;
    +    }
    +
    +    @Override
    +    public Map<String, Object> getComponentConfiguration() {
    +        Map<String, Object> conf = super.getComponentConfiguration();
    +        if (conf == null)
    +            conf = new Config();
    +
    +        if (flushIntervalSecs > 0) {
    +            LOG.info("Enabling tick tuple with interval [" + 
flushIntervalSecs + "]");
    +            conf.put(Config.TOPOLOGY_TICK_TUPLE_FREQ_SECS, 
flushIntervalSecs);
    +        }
    +
    +        return conf;
    +    }
    +
    +
         @Override
         public void execute(Tuple tuple) {
    -        byte[] rowKey = this.mapper.rowKey(tuple);
    -        ColumnList cols = this.mapper.columns(tuple);
    -        List<Mutation> mutations = 
hBaseClient.constructMutationReq(rowKey, cols, writeToWAL? Durability.SYNC_WAL 
: Durability.SKIP_WAL);
    +        boolean flush = false;
    +        if (TupleUtils.isTick(tuple)) {
    +            LOG.debug("TICK received! current batch status [" + 
tupleBatch.size() + "/" + batchSize + "]");
    +            flush = true;
    +        } else {
    +            byte[] rowKey = this.mapper.rowKey(tuple);
    +            ColumnList cols = this.mapper.columns(tuple);
    +            List<Mutation> mutations = 
hBaseClient.constructMutationReq(rowKey, cols, writeToWAL? Durability.SYNC_WAL 
: Durability.SKIP_WAL);
    +            batchMutations.addAll(mutations);
    +            tupleBatch.add(tuple);
    +            if (tupleBatch.size() >= batchSize)
    --- End diff --
    
    @ptgoetz there is another community who doesn't want curly braces :). Will 
send a updated PR.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to