Github user harshach commented on a diff in the pull request:
https://github.com/apache/storm/pull/1538#discussion_r69647671
--- Diff:
external/storm-kafka/src/jvm/storm/kafka/trident/TridentKafkaState.java ---
@@ -76,24 +77,36 @@ public void prepare(Map stormConf) {
producer = new Producer(config);
}
+ @SuppressWarnings({"rawtypes", "unchecked"})
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 {
+ producer.send(batchList);
+ LOG.debug("Sending the Batch " + batchList);
--- End diff --
lets not log the entire batchList . Probably useful to add the
batchList.size
---
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.
---