Search in sources :

Example 6 with DeletableGroupResult

use of org.apache.kafka.common.message.DeleteGroupsResponseData.DeletableGroupResult in project kafka by apache.

the class DeleteGroupsRequest method getErrorResponse.

@Override
public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) {
    Errors error = Errors.forException(e);
    DeletableGroupResultCollection groupResults = new DeletableGroupResultCollection();
    for (String groupId : data.groupsNames()) {
        groupResults.add(new DeletableGroupResult().setGroupId(groupId).setErrorCode(error.code()));
    }
    return new DeleteGroupsResponse(new DeleteGroupsResponseData().setResults(groupResults).setThrottleTimeMs(throttleTimeMs));
}
Also used : Errors(org.apache.kafka.common.protocol.Errors) DeletableGroupResult(org.apache.kafka.common.message.DeleteGroupsResponseData.DeletableGroupResult) DeleteGroupsResponseData(org.apache.kafka.common.message.DeleteGroupsResponseData) DeletableGroupResultCollection(org.apache.kafka.common.message.DeleteGroupsResponseData.DeletableGroupResultCollection)

Example 7 with DeletableGroupResult

use of org.apache.kafka.common.message.DeleteGroupsResponseData.DeletableGroupResult in project kafka by apache.

the class DeleteConsumerGroupsHandler method handleResponse.

@Override
public ApiResult<CoordinatorKey, Void> handleResponse(Node coordinator, Set<CoordinatorKey> groupIds, AbstractResponse abstractResponse) {
    final DeleteGroupsResponse response = (DeleteGroupsResponse) abstractResponse;
    final Map<CoordinatorKey, Void> completed = new HashMap<>();
    final Map<CoordinatorKey, Throwable> failed = new HashMap<>();
    final Set<CoordinatorKey> groupsToUnmap = new HashSet<>();
    for (DeletableGroupResult deletedGroup : response.data().results()) {
        CoordinatorKey groupIdKey = CoordinatorKey.byGroupId(deletedGroup.groupId());
        Errors error = Errors.forCode(deletedGroup.errorCode());
        if (error != Errors.NONE) {
            handleError(groupIdKey, error, failed, groupsToUnmap);
            continue;
        }
        completed.put(groupIdKey, null);
    }
    return new ApiResult<>(completed, failed, new ArrayList<>(groupsToUnmap));
}
Also used : DeletableGroupResult(org.apache.kafka.common.message.DeleteGroupsResponseData.DeletableGroupResult) HashMap(java.util.HashMap) DeleteGroupsResponse(org.apache.kafka.common.requests.DeleteGroupsResponse) Errors(org.apache.kafka.common.protocol.Errors) HashSet(java.util.HashSet)

Aggregations

DeletableGroupResult (org.apache.kafka.common.message.DeleteGroupsResponseData.DeletableGroupResult)7 DeleteGroupsResponseData (org.apache.kafka.common.message.DeleteGroupsResponseData)6 DeletableGroupResultCollection (org.apache.kafka.common.message.DeleteGroupsResponseData.DeletableGroupResultCollection)6 DeleteGroupsResponse (org.apache.kafka.common.requests.DeleteGroupsResponse)5 Test (org.junit.jupiter.api.Test)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 ApiVersion (org.apache.kafka.common.message.ApiVersionsResponseData.ApiVersion)2 Errors (org.apache.kafka.common.protocol.Errors)2 MockTime (org.apache.kafka.common.utils.MockTime)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 MockClient (org.apache.kafka.clients.MockClient)1 Cluster (org.apache.kafka.common.Cluster)1 Time (org.apache.kafka.common.utils.Time)1