GitHub user HeartSaVioR opened a pull request:

    https://github.com/apache/storm/pull/1682

    STORM-2089 Replace Consumer of ISqlTridentDataSource with SqlTridentConsumer

    * issue link: https://issues.apache.org/jira/browse/STORM-2089
    
    This is for handling INSERT for tuples as batch if possible.
    
    I also changed storm-sql-kafka to expose State directly, but this is 
effectively same as current since TridentKafkaState.updateState() does update 
via fully synchronous way.
    (by looping each tuple and calling Future.get() immediately)
    
    ```
        public void updateState(List<TridentTuple> tuples, TridentCollector 
collector) {
            String topic = null;
            for (TridentTuple tuple : tuples) {
                try {
                    topic = topicSelector.getTopic(tuple);
    
                    if(topic != null) {
                        Future<RecordMetadata> result = producer.send(new 
ProducerRecord(topic,
                                mapper.getKeyFromTuple(tuple), 
mapper.getMessageFromTuple(tuple)));
                        try {
                            result.get();
                        } catch (ExecutionException e) {
                            String errorMsg = "Could not retrieve result for 
message with key = "
                                    + mapper.getKeyFromTuple(tuple) + " from 
topic = " + topic;
                            LOG.error(errorMsg, e);
                            throw new FailedException(errorMsg, e);
                        }
                    } else {
                        LOG.warn("skipping key = " + 
mapper.getKeyFromTuple(tuple) + ", topic selector returned null.");
                    }
                } catch (Exception ex) {
                    String errorMsg = "Could not send message with key = " + 
mapper.getKeyFromTuple(tuple)
                            + " to topic = " + topic;
                    LOG.warn(errorMsg, ex);
                    throw new FailedException(errorMsg, ex);
                }
            }
        }
    ```
    
    We could improve it, but it would be better to handle it as another issue 
if needed.
    
    Please review and comment. Thanks!

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/HeartSaVioR/storm STORM-2089

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/storm/pull/1682.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1682
    
----
commit cc30363c7550ac34f9f8fed6abc4713a7680ee36
Author: Jungtaek Lim <kabh...@gmail.com>
Date:   2016-09-13T02:40:13Z

    STORM-2089 Replace Consumer of ISqlTridentDataSource with SqlTridentConsumer
    
    * SqlTridentConsumer contains StateFactory and StateUpdater which is needed 
to store tuples to State via batch
    * Apply the change to storm-sql-kafka

----


---
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