-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-9487: Follow-up PR of Kafka-9445 #8033
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
Changes from 2 commits
c438c5d
decbe53
7ba5423
da685d9
0f115ea
8801c60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,12 +21,11 @@ | |
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * Represents all the query options that a user can provide to state what kind of stores it is expecting. | ||
| * The options would be whether a user would want to enable/disable stale stores | ||
| * or whether it knows the list of partitions that it specifically wants to fetch. | ||
| * If this information is not provided the default behavior is to fetch the stores for all the partitions | ||
| * Represents all the query options that a user can provide to control the kind of stores we would like to fetch. | ||
| * The options could indicate - whether we want stale stores to be included (or) | ||
| * we want to filter for only stores belonging to a partition. | ||
| * If no specific partition is specified the default behavior is to fetch the stores for all the partitions | ||
| * available on that instance for that particular store name. | ||
|
brary marked this conversation as resolved.
Outdated
|
||
| * It contains a partition, which for a point queries can be populated from the {@link KeyQueryMetadata}. | ||
| */ | ||
| public class StoreQueryParams<T> { | ||
|
|
||
|
|
@@ -35,46 +34,42 @@ public class StoreQueryParams<T> { | |
| private final String storeName; | ||
| private final QueryableStoreType<T> queryableStoreType; | ||
|
|
||
| private StoreQueryParams(final String storeName, final QueryableStoreType<T> queryableStoreType) { | ||
| private StoreQueryParams(final String storeName, final QueryableStoreType<T> queryableStoreType, final Integer partition, final boolean staleStores) { | ||
| this.storeName = storeName; | ||
| this.queryableStoreType = queryableStoreType; | ||
| this.partition = partition; | ||
| this.staleStores = staleStores; | ||
| } | ||
|
|
||
| public static <T> StoreQueryParams<T> fromNameAndType(final String storeName, | ||
| final QueryableStoreType<T> queryableStoreType) { | ||
| return new StoreQueryParams<T>(storeName, queryableStoreType); | ||
| return new StoreQueryParams<T>(storeName, queryableStoreType, null, false); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we use a different sentinel than
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually we had a long discussion on keeping this null and adding it in Java doc that null means all partitions. Do you think this is important to start a discussion on the thread again? :)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont worry about it :) .. Happy to budge on stylistic things and leave it to the committers' call |
||
| } | ||
|
|
||
| /** | ||
| * Set a specific partition that should be queried exclusively. | ||
| * | ||
| * @param partition The specific integer partition to be fetched from the stores list by using {@link StoreQueryParams}. | ||
| * | ||
| * @return String storeName | ||
| * @return StoreQueryParams a new {@code StoreQueryParams} instance configured with the specified partition | ||
| */ | ||
| public StoreQueryParams<T> withPartition(final Integer partition) { | ||
| final StoreQueryParams<T> storeQueryParams = StoreQueryParams.fromNameAndType(this.storeName(), this.queryableStoreType()); | ||
| storeQueryParams.partition = partition; | ||
| storeQueryParams.staleStores = this.staleStores; | ||
| return storeQueryParams; | ||
| return new StoreQueryParams<T>(this.storeName(), this.queryableStoreType(), partition, this.staleStores); | ||
|
brary marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| /** | ||
| * Enable querying of stale state stores, i.e., allow to query active tasks during restore as well as standby tasks. | ||
| * | ||
| * @return String storeName | ||
| * @return StoreQueryParams a new {@code StoreQueryParams} instance configured with serving from stale stores enabled | ||
| */ | ||
| public StoreQueryParams<T> enableStaleStores() { | ||
| final StoreQueryParams<T> storeQueryParams = StoreQueryParams.fromNameAndType(this.storeName(), this.queryableStoreType()); | ||
| storeQueryParams.partition = this.partition; | ||
| storeQueryParams.staleStores = true; | ||
| return storeQueryParams; | ||
| return new StoreQueryParams<T>(this.storeName(), this.queryableStoreType(), this.partition, true); | ||
|
brary marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| /** | ||
| * Get the store name for which key is queried by the user. | ||
| * Get the name of the state store that should be queried. | ||
| * | ||
| * @return String storeName | ||
| * @return String state store name | ||
| */ | ||
| public String storeName() { | ||
| return storeName; | ||
|
|
@@ -83,16 +78,16 @@ public String storeName() { | |
| /** | ||
| * Get the queryable store type for which key is queried by the user. | ||
| * | ||
| * @return QueryableStoreType queryableStoreType | ||
| * @return QueryableStoreType type of queryable store | ||
| */ | ||
| public QueryableStoreType<T> queryableStoreType() { | ||
| return queryableStoreType; | ||
| } | ||
|
|
||
| /** | ||
| * Get the partition to be used to fetch list of stores. | ||
| * Get the store partition that will be queried. | ||
| * If the method returns {@code null}, it would mean that no specific partition has been requested, | ||
| * so all the local partitions for the store will be returned. | ||
| * so all the local partitions for the store will be queried. | ||
| * | ||
| * @return Integer partition | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1148,6 +1148,17 @@ public Map<String, List<String>> stateStoreNameToSourceTopics() { | |
| return results; | ||
| } | ||
|
|
||
| public List<String> sourceTopicsForStore(final String storeName) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a side note: Should we also consider the map
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure, do you think it will identify more topic groups? At the end of the day we are identifying a topic groupId to which a store belongs to. On a side note, if we do want to add stateStoreNameToSourceRegex along with stateStoreNameToSourceTopics, then we can probably return a set instead of list in this function and iterate over both of above one by one. |
||
| final List<String> results = new ArrayList<>(); | ||
| for (final Map.Entry<String, Set<String>> entry : stateStoreNameToSourceTopics.entrySet()) { | ||
| if (entry.getKey().equals(storeName)) { | ||
|
brary marked this conversation as resolved.
Outdated
|
||
| results.addAll(maybeDecorateInternalSourceTopics(entry.getValue())); | ||
| return results; | ||
| } | ||
| } | ||
| return Collections.EMPTY_LIST; | ||
| } | ||
|
|
||
| public synchronized Collection<Set<String>> copartitionGroups() { | ||
| // compute transitive closures of copartitionGroups to relieve registering code to know all members | ||
| // of a copartitionGroup at the same time | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.