Interface AdminApiHandler<K,V>
- All Known Implementing Classes:
AbortTransactionHandler,AdminApiHandler.Batched,AdminApiHandler.Unbatched,AlterConsumerGroupOffsetsHandler,DeleteConsumerGroupOffsetsHandler,DeleteConsumerGroupsHandler,DeleteRecordsHandler,DescribeConsumerGroupsHandler,DescribeProducersHandler,DescribeTransactionsHandler,FenceProducersHandler,ListConsumerGroupOffsetsHandler,ListOffsetsHandler,ListTransactionsHandler,RemoveMembersFromConsumerGroupHandler
public interface AdminApiHandler<K,V>
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic classAnAdminApiHandlerthat will group multiple keys into a single request when possible.static classstatic classAnAdminApiHandlerthat will create one request per key, not performing any grouping based on the targeted broker. -
Method Summary
Modifier and TypeMethodDescriptionapiName()Get a user-friendly name for the API this handler is implementing.buildRequest(int brokerId, Set<K> keys) Build the requests necessary for the given keys.handleResponse(org.apache.kafka.common.Node broker, Set<K> keys, org.apache.kafka.common.requests.AbstractResponse response) Callback that is invoked when a request returns successfully.handleUnsupportedVersionException(int brokerId, org.apache.kafka.common.errors.UnsupportedVersionException exception, Set<K> keys) Callback that is invoked when a fulfillment request hits an UnsupportedVersionException.Get the lookup strategy that is responsible for finding the brokerId which will handle each respective key.
-
Method Details
-
apiName
String apiName()Get a user-friendly name for the API this handler is implementing. -
buildRequest
Build the requests necessary for the given keys. The set of keys is derived byAdminApiDriverduring the lookup stage as the set of keys which all map to the same destination broker. Handlers can choose to issue a single request for all of the provided keys (seeAdminApiHandler.Batched, issue one request per key (seeAdminApiHandler.Unbatched, or implement their own custom grouping logic if necessary.- Parameters:
brokerId- the target brokerId for the requestkeys- the set of keys that should be handled by this request- Returns:
- a collection of
AdminApiHandler.RequestAndKeysfor the requests containing the given keys
-
handleResponse
AdminApiHandler.ApiResult<K,V> handleResponse(org.apache.kafka.common.Node broker, Set<K> keys, org.apache.kafka.common.requests.AbstractResponse response) Callback that is invoked when a request returns successfully. The handler should parse the response, check for errors, and return a result which indicates which keys (if any) have either been completed or failed with an unrecoverable error. It is also possible that the response indicates an incorrect target brokerId (e.g. in the case of a NotLeader error when the request is bound for a partition leader). In this case the key will be "unmapped" from the target brokerId and lookup will be retried. Note that keys which received a retriable error should be left out of the result. They will be retried automatically.- Parameters:
broker- the broker that the associated request was sent tokeys- the set of keys from the associated requestresponse- the response received from the broker- Returns:
- result indicating key completion, failure, and unmapping
-
handleUnsupportedVersionException
default Map<K,Throwable> handleUnsupportedVersionException(int brokerId, org.apache.kafka.common.errors.UnsupportedVersionException exception, Set<K> keys) Callback that is invoked when a fulfillment request hits an UnsupportedVersionException. Keys for which the exception cannot be handled and the request shouldn't be retried must be mapped to an error and returned. The request will then be retried for the remainder of the keys.- Returns:
- The failure mappings for the keys for which the exception cannot be handled and the request shouldn't be retried. If the exception cannot be handled all initial keys will be in the returned map.
-
lookupStrategy
AdminApiLookupStrategy<K> lookupStrategy()Get the lookup strategy that is responsible for finding the brokerId which will handle each respective key.- Returns:
- non-null lookup strategy
-