@@ -104,18 +104,19 @@ public GroupsService(Properties config) {
104
104
public void listGroups (GroupsCommandOptions opts ) throws Exception {
105
105
Collection <GroupListing > resources = adminClient .listGroups ()
106
106
.all ().get (30 , TimeUnit .SECONDS );
107
- printGroupDetails (resources , opts .groupType (), opts .protocol (), opts .hasConsumerOption (), opts .hasShareOption ());
107
+ printGroupDetails (resources , opts .groupType (), opts .protocol (), opts .hasConsumerOption (), opts .hasShareOption (), opts . hasStreamsOption () );
108
108
}
109
109
110
110
private void printGroupDetails (Collection <GroupListing > groups ,
111
111
Optional <GroupType > groupTypeFilter ,
112
112
Optional <String > protocolFilter ,
113
113
boolean consumerGroupFilter ,
114
- boolean shareGroupFilter ) {
114
+ boolean shareGroupFilter ,
115
+ boolean streamsGroupFilter ) {
115
116
List <List <String >> lineItems = new ArrayList <>();
116
117
int maxLen = 20 ;
117
118
for (GroupListing group : groups ) {
118
- if (combinedFilter (group , groupTypeFilter , protocolFilter , consumerGroupFilter , shareGroupFilter )) {
119
+ if (combinedFilter (group , groupTypeFilter , protocolFilter , consumerGroupFilter , shareGroupFilter , streamsGroupFilter )) {
119
120
List <String > lineItem = new ArrayList <>();
120
121
lineItem .add (group .groupId ());
121
122
lineItem .add (group .type ().map (GroupType ::toString ).orElse ("" ));
@@ -145,7 +146,8 @@ private boolean combinedFilter(GroupListing group,
145
146
Optional <GroupType > groupTypeFilter ,
146
147
Optional <String > protocolFilter ,
147
148
boolean consumerGroupFilter ,
148
- boolean shareGroupFilter ) {
149
+ boolean shareGroupFilter ,
150
+ boolean streamsGroupFilter ) {
149
151
boolean pass = true ;
150
152
Optional <GroupType > groupType = group .type ();
151
153
String protocol = group .protocol ();
@@ -159,6 +161,8 @@ private boolean combinedFilter(GroupListing group,
159
161
pass = protocol .equals ("consumer" ) || protocol .isEmpty () || groupType .filter (gt -> gt == GroupType .CONSUMER ).isPresent ();
160
162
} else if (shareGroupFilter ) {
161
163
pass = groupType .filter (gt -> gt == GroupType .SHARE ).isPresent ();
164
+ } else if (streamsGroupFilter ) {
165
+ pass = groupType .filter (gt -> gt == GroupType .STREAMS ).isPresent ();
162
166
}
163
167
return pass ;
164
168
}
@@ -189,6 +193,8 @@ public static final class GroupsCommandOptions extends CommandDefaultOptions {
189
193
190
194
private final OptionSpecBuilder shareOpt ;
191
195
196
+ private final OptionSpecBuilder streamsOpt ;
197
+
192
198
public GroupsCommandOptions (String [] args ) {
193
199
super (args );
194
200
bootstrapServerOpt = parser .accepts ("bootstrap-server" , "REQUIRED: The Kafka server to connect to." )
@@ -204,7 +210,7 @@ public GroupsCommandOptions(String[] args) {
204
210
listOpt = parser .accepts ("list" , "List the groups." );
205
211
206
212
groupTypeOpt = parser .accepts ("group-type" , "Filter the groups based on group type. "
207
- + "Valid types are: 'classic', 'consumer' and 'share '." )
213
+ + "Valid types are: 'classic', 'consumer', 'share' and 'streams '." )
208
214
.withRequiredArg ()
209
215
.describedAs ("type" )
210
216
.ofType (String .class );
@@ -217,6 +223,7 @@ public GroupsCommandOptions(String[] args) {
217
223
consumerOpt = parser .accepts ("consumer" , "Filter the groups to show all kinds of consumer groups, including classic and simple consumer groups. "
218
224
+ "This matches group type 'consumer', and group type 'classic' where the protocol type is 'consumer' or empty." );
219
225
shareOpt = parser .accepts ("share" , "Filter the groups to show share groups." );
226
+ streamsOpt = parser .accepts ("streams" , "Filter the groups to show streams groups." );
220
227
221
228
try {
222
229
options = parser .parse (args );
@@ -275,6 +282,10 @@ public boolean hasShareOption() {
275
282
return has (shareOpt );
276
283
}
277
284
285
+ public boolean hasStreamsOption () {
286
+ return has (streamsOpt );
287
+ }
288
+
278
289
public void checkArgs () {
279
290
if (args .length == 0 )
280
291
CommandLineUtils .printUsageAndExit (parser , "This tool helps to list groups of all types." );
@@ -293,8 +304,9 @@ public void checkArgs() {
293
304
}
294
305
295
306
// check invalid args
296
- CommandLineUtils .checkInvalidArgs (parser , options , consumerOpt , groupTypeOpt , protocolOpt , shareOpt );
297
- CommandLineUtils .checkInvalidArgs (parser , options , shareOpt , consumerOpt , groupTypeOpt , protocolOpt );
307
+ CommandLineUtils .checkInvalidArgs (parser , options , consumerOpt , groupTypeOpt , protocolOpt , shareOpt , streamsOpt );
308
+ CommandLineUtils .checkInvalidArgs (parser , options , shareOpt , consumerOpt , groupTypeOpt , protocolOpt , streamsOpt );
309
+ CommandLineUtils .checkInvalidArgs (parser , options , streamsOpt , consumerOpt , groupTypeOpt , protocolOpt , shareOpt );
298
310
}
299
311
}
300
312
}
0 commit comments