use of org.apache.kafka.common.message.FindCoordinatorResponseData.Coordinator in project kafka by apache.
the class FindCoordinatorResponse method prepareErrorResponse.
public static FindCoordinatorResponse prepareErrorResponse(Errors error, List<String> keys) {
FindCoordinatorResponseData data = new FindCoordinatorResponseData();
List<FindCoordinatorResponseData.Coordinator> coordinators = new ArrayList<>(keys.size());
for (String key : keys) {
FindCoordinatorResponseData.Coordinator coordinator = new FindCoordinatorResponseData.Coordinator().setErrorCode(error.code()).setErrorMessage(error.message()).setKey(key).setHost(Node.noNode().host()).setPort(Node.noNode().port()).setNodeId(Node.noNode().id());
coordinators.add(coordinator);
}
data.setCoordinators(coordinators);
return new FindCoordinatorResponse(data);
}
use of org.apache.kafka.common.message.FindCoordinatorResponseData.Coordinator 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);
}
Aggregations