You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@twill.apache.org by chtyim <gi...@git.apache.org> on 2017/01/04 02:23:13 UTC
[GitHub] twill pull request #16: [TWILL-199] Handle offset error and return next offs...
Github user chtyim commented on a diff in the pull request:
https://github.com/apache/twill/pull/16#discussion_r94521381
--- Diff: twill-core/src/main/java/org/apache/twill/internal/kafka/client/SimpleKafkaConsumer.java ---
@@ -273,17 +274,19 @@ private MessageCallback wrapCallback(final MessageCallback callback,
final AtomicBoolean stopped = new AtomicBoolean();
return new MessageCallback() {
@Override
- public void onReceived(final Iterator<FetchedMessage> messages) {
+ public long onReceived(final Iterator<FetchedMessage> messages) {
if (stopped.get()) {
- return;
+ return Long.MIN_VALUE;
}
- Futures.getUnchecked(executor.submit(new Runnable() {
+ return Futures.getUnchecked(executor.submit(new Callable<Long>() {
+ long nextOffset = Long.MIN_VALUE;
@Override
- public void run() {
+ public Long call() {
if (stopped.get()) {
- return;
+ return nextOffset;
}
- callback.onReceived(messages);
+ nextOffset = callback.onReceived(messages);
--- End diff --
Just `return callback.onReceived(messages)`. No need to store it to a local variable.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---