Github user abellina commented on a diff in the pull request:
https://github.com/apache/storm/pull/1538#discussion_r69455288
--- Diff:
external/storm-kafka/src/jvm/storm/kafka/trident/TridentKafkaState.java ---
@@ -76,24 +77,40 @@ public void prepare(Map stormConf) {
producer = new Producer(config);
}
+ @SuppressWarnings({"rawtypes", "unchecked", "unused"})
public void updateState(List<TridentTuple> tuples, TridentCollector
collector) {
String topic = null;
+ List<KeyedMessage> batchList = new
ArrayList<KeyedMessage>(tuples.size());
+ // Creating Batch
for (TridentTuple tuple : tuples) {
try {
topic = topicSelector.getTopic(tuple);
-
- if(topic != null) {
- producer.send(new KeyedMessage(topic,
mapper.getKeyFromTuple(tuple),
+ if (topic != null) {
+ batchList.add(new KeyedMessage(topic,
mapper.getKeyFromTuple(tuple),
mapper.getMessageFromTuple(tuple)));
+ LOG.debug("Updated Batch");
} else {
- LOG.warn("skipping key = " +
mapper.getKeyFromTuple(tuple) + ", topic selector returned null.");
+ 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;
+ String errorMsg = "Error while filling up List for
Batching";
LOG.warn(errorMsg, ex);
throw new FailedException(errorMsg, ex);
}
}
+ // Sending Batch
+ try {
+ if (batchList != null) {
--- End diff --
will we ever hit this if? Seems like batchList will always be not null.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---