public static Schema currentRequestSchema(int apiKey) { return requestSchema(apiKey, latestVersion(apiKey)); }
public static Schema currentResponseSchema(int apiKey) { return schemaFor(Protocol.RESPONSES, apiKey, latestVersion(apiKey)); }
public static Struct parseRequest(int apiKey, int version, ByteBuffer buffer) { return (Struct) requestSchema(apiKey, version).read(buffer); }
public static Schema responseSchema(int apiKey, int version) { return schemaFor(Protocol.RESPONSES, apiKey, version); }
public static Struct parseResponse(int apiKey, ByteBuffer buffer) { return (Struct) currentResponseSchema(apiKey).read(buffer); }
public RequestHeader(short apiKey, String client, int correlation) { this(apiKey, ProtoUtils.latestVersion(apiKey), client, correlation); }
/** * Constructor for version 0. * @param groupId * @param offsetData */ @Deprecated public OffsetCommitRequest(String groupId, Map<TopicPartition, PartitionData> offsetData) { super(new Struct(ProtoUtils.requestSchema(ApiKeys.OFFSET_COMMIT.id, 0))); initCommonFields(groupId, offsetData, 0); this.groupId = groupId; this.generationId = DEFAULT_GENERATION_ID; this.consumerId = DEFAULT_CONSUMER_ID; this.offsetData = offsetData; }
public static Schema requestSchema(int apiKey, int version) { return schemaFor(Protocol.REQUESTS, apiKey, version); }
/** * Handle any completed receives and update the response list with the responses received. * @param responses The list of responses to update * @param now The current time */ private void handleCompletedReceives(List<ClientResponse> responses, long now) { for (NetworkReceive receive : this.selector.completedReceives()) { int source = receive.source(); ClientRequest req = inFlightRequests.completeNext(source); ResponseHeader header = ResponseHeader.parse(receive.payload()); short apiKey = req.request().header().apiKey(); Struct body = (Struct) ProtoUtils.currentResponseSchema(apiKey).read(receive.payload()); correlate(req.request().header(), header); if (apiKey == ApiKeys.METADATA.id) { handleMetadataResponse(req.request().header(), body, now); } else { // need to add body/header to response here responses.add(new ClientResponse(req, now, false, body)); } } }
public static OffsetCommitRequest parse(ByteBuffer buffer, int versionId) { Schema schema = ProtoUtils.requestSchema(ApiKeys.OFFSET_COMMIT.id, versionId); return new OffsetCommitRequest(((Struct) schema.read(buffer))); }