@Override public AbstractRequest.Builder createRequest(int timeoutMs) { return new ElectPreferredLeadersRequest.Builder( ElectPreferredLeadersRequest.toRequestData(partitions, timeoutMs)); }
private CreateAclsResponse createCreateAclsResponse() { return new CreateAclsResponse(0, Arrays.asList(new AclCreationResponse(ApiError.NONE), new AclCreationResponse(new ApiError(Errors.INVALID_REQUEST, "Foo bar")))); }
public short apiVersion() { // Use v0 when serializing an unhandled ApiVersion response if (isUnsupportedApiVersionsRequest()) return 0; return header.apiVersion(); }
public Send buildResponse(AbstractResponse body) { ResponseHeader responseHeader = header.toResponseHeader(); return body.toSend(connectionId, responseHeader, apiVersion()); }
@Override AbstractRequest.Builder createRequest(int timeoutMs) { if (supportsDisablingTopicCreation) return new MetadataRequest.Builder(topicNamesList, false); else return MetadataRequest.Builder.allTopics(); }
public static ApiVersionsResponse apiVersionsResponse(int throttleTimeMs, byte maxMagic) { if (maxMagic == RecordBatch.CURRENT_MAGIC_VALUE && throttleTimeMs == DEFAULT_THROTTLE_TIME) { return defaultApiVersionsResponse(); } return createApiVersionsResponse(throttleTimeMs, maxMagic); }
private void checkDescribeConfigsResponseVersions() throws Exception { DescribeConfigsResponse response = createDescribeConfigsResponse(); DescribeConfigsResponse deserialized0 = (DescribeConfigsResponse) deserialize(response, response.toStruct((short) 0), (short) 0); verifyDescribeConfigsResponse(response, deserialized0, 0); DescribeConfigsResponse deserialized1 = (DescribeConfigsResponse) deserialize(response, response.toStruct((short) 1), (short) 1); verifyDescribeConfigsResponse(response, deserialized1, 1); }
@Override public Map<Errors, Integer> errorCounts() { return errorCounts(error.error()); }
@Override public JoinGroupRequest build(short version) { if (version < 1) { // v0 had no rebalance timeout but used session timeout implicitly rebalanceTimeout = sessionTimeout; } return new JoinGroupRequest(version, groupId, sessionTimeout, rebalanceTimeout, memberId, protocolType, groupProtocols); }
private void assertThrowsInvalidRecordExceptionForAllVersions(ProduceRequest.Builder builder) { for (short version = builder.oldestAllowedVersion(); version < builder.latestAllowedVersion(); version++) { assertThrowsInvalidRecordException(builder, version); } }
private void checkResponse(AbstractResponse response, int version) throws Exception { // Check that we can serialize, deserialize and serialize again // We don't check for equality or hashCode because it is likely to fail for any response containing a HashMap Struct struct = response.toStruct((short) version); AbstractResponse deserialized = (AbstractResponse) deserialize(response, struct, (short) version); Struct struct2 = deserialized.toStruct((short) version); }
/** * Return the metadata for the next error response. */ public FetchMetadata nextCloseExisting() { return new FetchMetadata(sessionId, INITIAL_EPOCH); }
public static Builder forCurrentMagic(short acks, int timeout, Map<TopicPartition, MemoryRecords> partitionRecords) { return forMagic(RecordBatch.CURRENT_MAGIC_VALUE, acks, timeout, partitionRecords, null); }
@Override public boolean matches(AbstractRequest body) { return body instanceof ProduceRequest && ((ProduceRequest) body).hasIdempotentRecords(); } }, produceResponse(tp0, -1, Errors.CLUSTER_AUTHORIZATION_FAILED, 0));
@Override public StopReplicaRequest build(short version) { return new StopReplicaRequest(controllerId, controllerEpoch, brokerEpoch, deletePartitions, partitions, version); }
@Override public WriteTxnMarkersRequest build(short version) { return new WriteTxnMarkersRequest(version, markers); } }
@Override public boolean matches(AbstractRequest body) { return body instanceof InitProducerIdRequest && ((InitProducerIdRequest) body).transactionalId() == null; } }, new InitProducerIdResponse(0, error, producerId, producerEpoch));
@Override public boolean matches(AbstractRequest body) { return body instanceof ProduceRequest && ((ProduceRequest) body).hasIdempotentRecords(); } }, produceResponse(tp0, -1, Errors.UNSUPPORTED_FOR_MESSAGE_FORMAT, 0));