-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
KIP 848 ListGroups API #4777
Closed
mahajanadhitya
wants to merge
11
commits into
dev_kip848_mock_handler_and_integration_tests
from
feature/ListGroupsAPI
Closed
KIP 848 ListGroups API #4777
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
aa99639
[KIP-848] integration tests passing
emasab 9deaa8b
[KIP-848] ListGroups v5 with group type filter
mahajanadhitya e98a232
Addressed first round of comments
mahajanadhitya 7faf7e0
feature/ListGroupsAPI KIP 848 (#13)
mahajanadhitya be275b3
PR Comments Change I (#14)
mahajanadhitya 24f248a
PR Comments Change 2
mahajanadhitya 67f1043
PR Changes 3 (#18)
mahajanadhitya 94037a0
PR changes 4 (#23)
mahajanadhitya 46c37fb
Refactor Changes
mahajanadhitya 6ba0894
Doxygen Error Fix
mahajanadhitya ad1655b
Address remaining comments
emasab 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 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 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 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 |
---|---|---|
|
@@ -73,7 +73,8 @@ static void usage(const char *reason, ...) { | |
fprintf(stderr, | ||
"List groups usage examples\n" | ||
"\n" | ||
"Usage: %s <options> <state1> <state2> ...\n" | ||
"Usage: %s <options> state_cnt group_type_cnt [<state1> " | ||
"<state2>] [<group_type1> <group_type2>] ...\n" | ||
"\n" | ||
"Options:\n" | ||
" -b <brokers> Bootstrap server list to connect to.\n" | ||
|
@@ -145,12 +146,15 @@ static int print_groups_info(const rd_kafka_ListConsumerGroups_result_t *list) { | |
int is_simple_consumer_group = | ||
rd_kafka_ConsumerGroupListing_is_simple_consumer_group( | ||
group); | ||
rd_kafka_consumer_group_type_t group_type = | ||
rd_kafka_ConsumerGroupListing_type(group); | ||
|
||
printf("Group \"%s\", is simple %" PRId32 | ||
", " | ||
"state %s", | ||
"state %s, type %s", | ||
group_id, is_simple_consumer_group, | ||
rd_kafka_consumer_group_state_name(state)); | ||
rd_kafka_consumer_group_state_name(state), | ||
rd_kafka_consumer_group_type_name(group_type)); | ||
printf("\n"); | ||
} | ||
for (i = 0; i < result_error_cnt; i++) { | ||
|
@@ -171,7 +175,7 @@ int64_t parse_int(const char *what, const char *str) { | |
if (end != str + strlen(str)) { | ||
fprintf(stderr, "%% Invalid input for %s: %s: not an integer\n", | ||
what, str); | ||
exit(1); | ||
usage("Not a valid Integer"); | ||
pranavrth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
return (int64_t)n; | ||
|
@@ -184,24 +188,37 @@ int64_t parse_int(const char *what, const char *str) { | |
static void | ||
cmd_list_consumer_groups(rd_kafka_conf_t *conf, int argc, char **argv) { | ||
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. Running |
||
rd_kafka_t *rk; | ||
const char **states_str = NULL; | ||
char errstr[512]; | ||
rd_kafka_AdminOptions_t *options; | ||
rd_kafka_event_t *event = NULL; | ||
rd_kafka_error_t *error = NULL; | ||
int i; | ||
int retval = 0; | ||
int states_cnt = 0; | ||
int retval = 0; | ||
int states_cnt = 0; | ||
int group_types_cnt = 0; | ||
pranavrth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rd_kafka_consumer_group_state_t *states; | ||
rd_kafka_consumer_group_type_t *group_types; | ||
|
||
states_cnt = parse_int("state count", argv[0]); | ||
group_types_cnt = parse_int("group type count", argv[1]); | ||
if (states_cnt < 0 || group_types_cnt < 0) | ||
usage("Length of attributes/options cannot be negative"); | ||
if (states_cnt + group_types_cnt + 2 != argc) | ||
usage( | ||
"Number of arguments do not match states_cnt and " | ||
"types_cnt"); | ||
|
||
if (argc >= 1) { | ||
states_str = (const char **)&argv[0]; | ||
states_cnt = argc; | ||
} | ||
states = calloc(states_cnt, sizeof(rd_kafka_consumer_group_state_t)); | ||
for (i = 0; i < states_cnt; i++) { | ||
states[i] = parse_int("state code", states_str[i]); | ||
states[i] = (rd_kafka_consumer_group_state_t)parse_int( | ||
"state code", argv[2 + i]); | ||
} | ||
|
||
group_types = | ||
calloc(group_types_cnt, sizeof(rd_kafka_consumer_group_type_t)); | ||
for (i = 0; i < group_types_cnt; i++) { | ||
group_types[i] = (rd_kafka_consumer_group_type_t)parse_int( | ||
"group type code", argv[i + states_cnt + 2]); | ||
} | ||
|
||
/* | ||
|
@@ -235,10 +252,22 @@ cmd_list_consumer_groups(rd_kafka_conf_t *conf, int argc, char **argv) { | |
options, states, states_cnt))) { | ||
fprintf(stderr, "%% Failed to set states: %s\n", | ||
rd_kafka_error_string(error)); | ||
rd_kafka_error_destroy(error); | ||
goto exit; | ||
} | ||
free(states); | ||
if ((error = rd_kafka_AdminOptions_set_match_consumer_group_types( | ||
options, group_types, group_types_cnt))) { | ||
fprintf(stderr, "%% Failed to set group types: %s\n", | ||
rd_kafka_error_string(error)); | ||
goto exit; | ||
} | ||
free(group_types); | ||
|
||
printf( | ||
"The response depends on the specific broker version used, " | ||
"all request attributes may not be used if the broker version" | ||
"does not support them.\n" | ||
"==============================\n"); | ||
pranavrth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
rd_kafka_ListConsumerGroups(rk, options, queue); | ||
rd_kafka_AdminOptions_destroy(options); | ||
|
@@ -273,6 +302,8 @@ cmd_list_consumer_groups(rd_kafka_conf_t *conf, int argc, char **argv) { | |
|
||
|
||
exit: | ||
if (error) | ||
rd_kafka_error_destroy(error); | ||
if (event) | ||
rd_kafka_event_destroy(event); | ||
rd_kafka_queue_destroy(queue); | ||
|
This file contains 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
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.
We don't need this files changes.