@Override public ApiVersionsRequest build(short version) { return new ApiVersionsRequest(version); }
public static ApiVersionsRequest parse(ByteBuffer buffer, short version) { return new ApiVersionsRequest(ApiKeys.API_VERSIONS.parseRequest(version, buffer), version); }
public RequestAndSize parseRequest(ByteBuffer buffer) { if (isUnsupportedApiVersionsRequest()) { // Unsupported ApiVersion requests are treated as v0 requests and are not parsed ApiVersionsRequest apiVersionsRequest = new ApiVersionsRequest((short) 0, header.apiVersion()); return new RequestAndSize(apiVersionsRequest, 0); } else { ApiKeys apiKey = header.apiKey(); try { short apiVersion = header.apiVersion(); Struct struct = apiKey.parseRequest(apiVersion, buffer); AbstractRequest body = AbstractRequest.parseRequest(apiKey, apiVersion, struct); return new RequestAndSize(body, struct.sizeOf()); } catch (Throwable ex) { throw new InvalidRequestException("Error getting request for apiKey: " + apiKey + ", apiVersion: " + header.apiVersion() + ", connectionId: " + connectionId + ", listenerName: " + listenerName + ", principal: " + principal, ex); } } }
return new SaslHandshakeRequest(struct, apiVersion); case API_VERSIONS: return new ApiVersionsRequest(struct, apiVersion); case CREATE_TOPICS: return new CreateTopicsRequest(struct, apiVersion);
case SEND_APIVERSIONS_REQUEST: ApiVersionsRequest apiVersionsRequest = new ApiVersionsRequest((short) 0); send(apiVersionsRequest.toSend(node, nextRequestHeader(ApiKeys.API_VERSIONS, apiVersionsRequest.version()))); setSaslState(SaslState.RECEIVE_APIVERSIONS_RESPONSE);
Request(ChannelHandlerContext ctx, ByteBuffer buffer) { this.requestId = buffer.getShort(); buffer.rewind(); header = RequestHeader.parse(buffer); if (header.apiKey() == ApiKeys.API_VERSIONS.id && !Protocol.apiVersionSupported(header.apiKey(), header.apiVersion())) { body = new ApiVersionsRequest(); } else { body = AbstractRequest.getRequest(header.apiKey(), header.apiVersion(), buffer); } this.clientAddress = ((InetSocketAddress) ctx.getChannel().getRemoteAddress()).getAddress(); }