Search in sources :

Example 1 with InvalidGroupIdException

use of org.apache.kafka.common.errors.InvalidGroupIdException in project kafka by apache.

the class CoordinatorStrategy method handleResponse.

@Override
public LookupResult<CoordinatorKey> handleResponse(Set<CoordinatorKey> keys, AbstractResponse abstractResponse) {
    Map<CoordinatorKey, Integer> mappedKeys = new HashMap<>();
    Map<CoordinatorKey, Throwable> failedKeys = new HashMap<>();
    for (CoordinatorKey key : unrepresentableKeys) {
        failedKeys.put(key, new InvalidGroupIdException("The given group id '" + key.idValue + "' cannot be represented in a request."));
    }
    for (Coordinator coordinator : ((FindCoordinatorResponse) abstractResponse).coordinators()) {
        CoordinatorKey key;
        if (// old version without batching
        coordinator.key() == null)
            key = requireSingletonAndType(keys);
        else {
            key = (type == CoordinatorType.GROUP) ? CoordinatorKey.byGroupId(coordinator.key()) : CoordinatorKey.byTransactionalId(coordinator.key());
        }
        handleError(Errors.forCode(coordinator.errorCode()), key, coordinator.nodeId(), mappedKeys, failedKeys);
    }
    return new LookupResult<>(failedKeys, mappedKeys);
}
Also used : FindCoordinatorResponse(org.apache.kafka.common.requests.FindCoordinatorResponse) HashMap(java.util.HashMap) InvalidGroupIdException(org.apache.kafka.common.errors.InvalidGroupIdException) Coordinator(org.apache.kafka.common.message.FindCoordinatorResponseData.Coordinator)

Aggregations

HashMap (java.util.HashMap)1 InvalidGroupIdException (org.apache.kafka.common.errors.InvalidGroupIdException)1 Coordinator (org.apache.kafka.common.message.FindCoordinatorResponseData.Coordinator)1 FindCoordinatorResponse (org.apache.kafka.common.requests.FindCoordinatorResponse)1