|
|
|
@ -41,8 +41,8 @@ public class TbQueueConsumerTask { |
|
|
|
private CountDownLatch completionLatch; |
|
|
|
|
|
|
|
public void setTask(Future<?> task) { |
|
|
|
this.task = task; |
|
|
|
this.completionLatch = new CountDownLatch(1); |
|
|
|
this.task = task; |
|
|
|
} |
|
|
|
|
|
|
|
public void subscribe(Set<TopicPartitionInfo> partitions) { |
|
|
|
@ -63,14 +63,14 @@ public class TbQueueConsumerTask { |
|
|
|
if (isRunning()) { |
|
|
|
try { |
|
|
|
if (!completionLatch.await(30, TimeUnit.SECONDS)) { |
|
|
|
task = null; |
|
|
|
throw new IllegalStateException("timeout of 30 seconds expired"); |
|
|
|
} |
|
|
|
log.trace("[{}] Awaited finish", key); |
|
|
|
} catch (Exception e) { |
|
|
|
log.warn("[{}] Failed to await for consumer to stop", key, e); |
|
|
|
} |
|
|
|
task = null; |
|
|
|
} |
|
|
|
log.trace("[{}] Awaited finish", key); |
|
|
|
} |
|
|
|
|
|
|
|
public boolean isRunning() { |
|
|
|
@ -79,6 +79,7 @@ public class TbQueueConsumerTask { |
|
|
|
|
|
|
|
public void finished() { |
|
|
|
completionLatch.countDown(); |
|
|
|
task = null; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|