Repository navigation
feature #520: Thread safe User API exposure of ALL Consumer APIs #346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Antony Stubbs (astubbs)
wants to merge
43
commits into
confluentinc:improvements/commit-command-actor
from
astubbs:features/consumer-interface
Closed
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
d5661ce
step
astubbs c0380f3
compile, remove stale
astubbs 28b225c
basic test of facade
astubbs ebfd06e
facade test skeleton, basics seem to work so far
astubbs c98b6a6
consumer interface subject updates and license
astubbs b3d49b4
START: restricted consumer facade api
astubbs c09585f
Merge remote-tracking branch 'origin/master' into features/consumer-i…
astubbs fb2dc91
split: consumer facade
astubbs c765c4a
START: API Interface tree, including partial Consumer
astubbs 2904294
Merge branch 'improvements/commit-command-actor' into features/consum…
astubbs 08bc72d
Merge branch 'features/consumer-interface' into feature/api-interface
astubbs 2050ff4
Revert "START: Isolate consumer commit message actor replacement from…
astubbs 7a7a700
step
astubbs 546dc2f
Merge branch 'improvements/commit-command-actor' into features/consum…
astubbs 1792d9c
Merge branch 'improvements/commit-command-actor' into features/consum…
astubbs cfc912d
extract ConsumerFacade methods which aren't supported
astubbs 14e23a9
license
astubbs 0d56a69
Merge branch 'features/consumer-interface' into feature/api-interface
astubbs 4bb4ed6
swallow api-interface branch
astubbs c3e8e6b
review, sort
astubbs 626aee0
review
astubbs 661adae
review - docs
astubbs 9be1172
Merge branch 'improvements/commit-command-actor' into features/consum…
astubbs 5ca7432
license
astubbs 698bd86
tests running
astubbs cfd0df6
one: subscribe string
astubbs d6cb6c8
ActorImpl ordering
astubbs c83cd29
actor: print actor class name in logs
astubbs db52462
actor: start through process
astubbs 6cb9c4e
fix
astubbs 93e218d
one: Close resources separately if not started yet
astubbs 0a720f9
one: actor: wait for state before commanding
astubbs ebef0b4
step: ConsumerFacadeTest runs, get's valid test exception
astubbs ba3da13
Merge branch 'improvements/rebalance-messages' into features/consumer…
astubbs 04ce2eb
assignment() passes
astubbs c04b8d5
seek runs, works, need to handle truncation properly
astubbs 4371f0c
flesh out some more tests
astubbs 14fb978
mark tests
astubbs e086ae8
big step: introduce fuzzy consumer interface, use interfaces for all …
astubbs 87598d7
review
astubbs 8b2d338
Merge remote-tracking branch 'astubbs/improvements/commit-command-act…
astubbs c515b10
review
astubbs e67833f
review
astubbs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
parallel-consumer-core/src/main/java/io/confluent/parallelconsumer/ConsumerApiAccess.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package io.confluent.parallelconsumer; | ||
|
|
||
| /*- | ||
| * Copyright (C) 2020-2022 Confluent, Inc. | ||
| */ | ||
|
|
||
| import io.confluent.parallelconsumer.internal.ConsumerFacadeForPC; | ||
| import io.confluent.parallelconsumer.internal.ConsumerFacadeStrictImpl; | ||
| import io.confluent.parallelconsumer.internal.FullConsumerFacadeImpl; | ||
| import io.confluent.parallelconsumer.internal.PCConsumerAPIStrict; | ||
| import org.apache.kafka.clients.consumer.Consumer; | ||
|
|
||
| /** | ||
| * Get access to the underlying {@link Consumer} interface. | ||
| * | ||
| * @author Antony Stubbs | ||
| * @see FullConsumerFacadeImpl | ||
| * @see PCConsumerAPIStrict | ||
| * @see ConsumerFacadeStrictImpl | ||
| */ | ||
| public interface ConsumerApiAccess<K, V> { | ||
|
|
||
| /** | ||
| * All consumer style methods, including ones that can't run. For which, you can either choose to no-op or throw an | ||
| * exception. | ||
| * todo docs | ||
| * <p> | ||
| * An implementation of the Kafka Consumer API, with unsupported functions which throw exceptions. Useful for when you | ||
| * want to let something else use PC, where it's unaware of it's capabilities, yet you know it won't call unsupported | ||
| * methods. | ||
| * | ||
| * @see FullConsumerFacadeImpl | ||
| * @see #partialStrictKafkaConsumer() | ||
| */ | ||
| FullConsumerFacadeImpl<K, V> fullConsumerFacade(); | ||
|
|
||
| /** | ||
| * The {@link PCConsumerAPIStrict} APIs, plus a set of implementations of {@link Consumer}, which are implemented, | ||
| * but not in the strict contract of the Kafka Consumer API. | ||
| * | ||
| * @see ConsumerFacadeForPC | ||
| */ | ||
| // todo def needs a better name | ||
| ConsumerFacadeForPC consumerFacadeForPC(); | ||
|
|
||
| /** | ||
| * Partial implementation of {@link Consumer}, for which methods are implemented in teh strict sense of the | ||
| * contract. | ||
| * <p> | ||
| * Use this if possible instead of {@link #fullConsumerFacade()}, as it only has the functions that are allowed to | ||
| * be called. | ||
| * <p> | ||
| * Use {@link #fullConsumerFacade()} if you need something that "is a" | ||
| * {@link org.apache.kafka.clients.consumer.Consumer}, but won't have unsupported functions called. | ||
| * | ||
| * @see PCConsumerAPIStrict | ||
| */ | ||
| PCConsumerAPIStrict partialStrictKafkaConsumer(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...onsumer-core/src/main/java/io/confluent/parallelconsumer/internal/ConsumerAccessImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package io.confluent.parallelconsumer.internal; | ||
|
|
||
| /*- | ||
| * Copyright (C) 2020-2022 Confluent, Inc. | ||
| */ | ||
|
|
||
| import io.confluent.parallelconsumer.ConsumerApiAccess; | ||
| import io.confluent.parallelconsumer.ParallelConsumer; | ||
| import lombok.Value; | ||
|
|
||
| /** | ||
| * @author Antony Stubbs | ||
| * @see ConsumerApiAccess | ||
| */ | ||
| @Value | ||
| public class ConsumerAccessImpl<K, V> implements ConsumerApiAccess<K, V> { | ||
|
|
||
| BrokerPollSystem<K, V> poller; | ||
|
|
||
| ParallelConsumer<K, V> pcApi; | ||
|
|
||
| @Override | ||
| public FullConsumerFacadeImpl<K, V> fullConsumerFacade() { | ||
| // new or reused? | ||
| return new FullConsumerFacadeImpl<>(pcApi, poller); | ||
| } | ||
|
|
||
| @Override | ||
| public ConsumerFacadeForPC consumerFacadeForPC() { | ||
| return new ConsumerFacadeForPCImpl<>(pcApi, poller); | ||
| } | ||
|
|
||
| @Override | ||
| public PCConsumerAPIStrict partialStrictKafkaConsumer() { | ||
| // new or reused? | ||
| return new ConsumerFacadeStrictImpl<>(poller); | ||
| } | ||
| } |
51 changes: 51 additions & 0 deletions
51
...nsumer-core/src/main/java/io/confluent/parallelconsumer/internal/ConsumerFacadeForPC.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package io.confluent.parallelconsumer.internal; | ||
|
|
||
| /*- | ||
| * Copyright (C) 2020-2022 Confluent, Inc. | ||
| */ | ||
|
|
||
| import org.apache.kafka.clients.consumer.Consumer; | ||
| import org.apache.kafka.common.TopicPartition; | ||
|
|
||
| import java.time.Duration; | ||
| import java.util.Collection; | ||
|
|
||
| /** | ||
| * The set of implementations of {@link Consumer}, which are implemented, but not in the strict contract of the Kafka | ||
| * Consumer API. | ||
| * <p> | ||
| * Typically, this involves interpreting the intent, and making the equivalent call to PC. | ||
| * | ||
| * @author Antony Stubbs | ||
| * @see PCConsumerAPIStrict | ||
| */ | ||
| // todo def needs a better name | ||
| // todo should this extend PCConsumerAPIStrict or not? If not, should there be another interface which does? | ||
| public interface ConsumerFacadeForPC extends PCConsumerAPIStrict { | ||
|
|
||
| /** | ||
| * Like {@link Consumer#pause}, except it pauses ALL PARTITIONS through the PC controller. After enough back | ||
| * pressure is built up, the underlying consumer will pause. | ||
| * <p> | ||
| * Note: this implementation cannot pause individual partitions, only ALL partitions. The parameter is ignored. | ||
| * | ||
| * @param collection ignored | ||
| */ | ||
| void pause(Collection<TopicPartition> collection); | ||
|
|
||
| /** | ||
| * Like {@link Consumer#resume}, except it resumes ALL PARTITIONS through the PC controller. After enough back | ||
| * pressure is released, the underlying consumer will resume. | ||
| * <p> | ||
| * Note: this implementation cannot pause individual partitions, only ALL partitions. The parameter is ignored. | ||
| * | ||
| * @param collection ignored | ||
| */ | ||
| void resume(Collection<TopicPartition> collection); | ||
|
|
||
|
|
||
| void close(); | ||
|
|
||
| void close(final Duration timeout); | ||
|
|
||
| } |
63 changes: 63 additions & 0 deletions
63
...er-core/src/main/java/io/confluent/parallelconsumer/internal/ConsumerFacadeForPCImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package io.confluent.parallelconsumer.internal; | ||
|
|
||
| /*- | ||
| * Copyright (C) 2020-2022 Confluent, Inc. | ||
| */ | ||
|
|
||
| import io.confluent.parallelconsumer.ParallelConsumer; | ||
| import lombok.experimental.FieldDefaults; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.apache.kafka.common.TopicPartition; | ||
|
|
||
| import java.time.Duration; | ||
| import java.util.Collection; | ||
|
|
||
| import static io.confluent.csid.utils.JavaUtils.isEmpty; | ||
| import static lombok.AccessLevel.PRIVATE; | ||
|
|
||
| /** | ||
| * @author Antony Stubbs | ||
| * @see ConsumerFacadeForPC | ||
| */ | ||
| @Slf4j | ||
| @ThreadSafe | ||
| @FieldDefaults(makeFinal = true, level = PRIVATE) | ||
| public class ConsumerFacadeForPCImpl<K, V> extends ConsumerFacadeStrictImpl<K, V> implements ConsumerFacadeForPC { | ||
|
|
||
| ParallelConsumer<K, V> pcApi; | ||
|
|
||
| public ConsumerFacadeForPCImpl(ParallelConsumer<K, V> pcApi, BrokerPollSystem<K, V> poller) { | ||
| super(poller); | ||
| this.pcApi = pcApi; | ||
| } | ||
|
|
||
| @Override | ||
| public void pause(final Collection<TopicPartition> collection) { | ||
| warnInvalidUse(collection); | ||
| pcApi.pauseIfRunning(); | ||
| } | ||
|
|
||
| private static void warnInvalidUse(Collection<?> collection) { | ||
| if (!isEmpty(collection)) { | ||
| log.warn("Pausing specific partitions not supported yet, pausing all"); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void resume(Collection<TopicPartition> collection) { | ||
| warnInvalidUse(collection); | ||
| pcApi.resumeIfPaused(); | ||
| } | ||
|
|
||
| // option to have this shutdown PC? | ||
| @Override | ||
| public void close() { | ||
| throw new UnsupportedOperationException("Not supported yet."); | ||
| } | ||
|
|
||
| @Override | ||
| public void close(final Duration timeout) { | ||
| throw new UnsupportedOperationException("Not supported yet."); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs