use of org.apache.kafka.common.message.FindCoordinatorRequestData in project kafka by apache.
the class RequestResponseTest method cannotUseFindCoordinatorV0ToFindTransactionCoordinator.
@Test
public void cannotUseFindCoordinatorV0ToFindTransactionCoordinator() {
FindCoordinatorRequest.Builder builder = new FindCoordinatorRequest.Builder(new FindCoordinatorRequestData().setKeyType(CoordinatorType.TRANSACTION.id).setKey("foobar"));
assertThrows(UnsupportedVersionException.class, () -> builder.build((short) 0));
}
use of org.apache.kafka.common.message.FindCoordinatorRequestData in project kafka by apache.
the class AbstractCoordinator method sendFindCoordinatorRequest.
/**
* Discover the current coordinator for the group. Sends a GroupMetadata request to
* one of the brokers. The returned future should be polled to get the result of the request.
* @return A request future which indicates the completion of the metadata request
*/
private RequestFuture<Void> sendFindCoordinatorRequest(Node node) {
// initiate the group metadata request
log.debug("Sending FindCoordinator request to broker {}", node);
FindCoordinatorRequestData data = new FindCoordinatorRequestData().setKeyType(CoordinatorType.GROUP.id()).setKey(this.rebalanceConfig.groupId);
FindCoordinatorRequest.Builder requestBuilder = new FindCoordinatorRequest.Builder(data);
return client.send(node, requestBuilder).compose(new FindCoordinatorResponseHandler());
}
use of org.apache.kafka.common.message.FindCoordinatorRequestData in project kafka by apache.
the class TransactionManager method lookupCoordinator.
private void lookupCoordinator(FindCoordinatorRequest.CoordinatorType type, String coordinatorKey) {
switch(type) {
case GROUP:
consumerGroupCoordinator = null;
break;
case TRANSACTION:
transactionCoordinator = null;
break;
default:
throw new IllegalStateException("Invalid coordinator type: " + type);
}
FindCoordinatorRequestData data = new FindCoordinatorRequestData().setKeyType(type.id()).setKey(coordinatorKey);
FindCoordinatorRequest.Builder builder = new FindCoordinatorRequest.Builder(data);
enqueueRequest(new FindCoordinatorHandler(builder));
}
use of org.apache.kafka.common.message.FindCoordinatorRequestData in project kafka by apache.
the class CoordinatorStrategy method buildRequest.
@Override
public FindCoordinatorRequest.Builder buildRequest(Set<CoordinatorKey> keys) {
unrepresentableKeys = keys.stream().filter(k -> k == null || !isRepresentableKey(k.idValue)).collect(Collectors.toSet());
Set<CoordinatorKey> representableKeys = keys.stream().filter(k -> k != null && isRepresentableKey(k.idValue)).collect(Collectors.toSet());
if (batch) {
ensureSameType(representableKeys);
FindCoordinatorRequestData data = new FindCoordinatorRequestData().setKeyType(type.id()).setCoordinatorKeys(representableKeys.stream().map(k -> k.idValue).collect(Collectors.toList()));
return new FindCoordinatorRequest.Builder(data);
} else {
CoordinatorKey key = requireSingletonAndType(representableKeys);
return new FindCoordinatorRequest.Builder(new FindCoordinatorRequestData().setKey(key.idValue).setKeyType(key.type.id()));
}
}
Aggregations