protected bool Equals(OffsetRequest other) { return(this.VersionId == other.VersionId && this.CorrelationId == other.CorrelationId && string.Equals(this.ClientId, other.ClientId) && this.ReplicaId == other.ReplicaId && this.RequestInfo.DictionaryEqual(other.RequestInfo)); }
protected bool Equals(OffsetRequest other) { return this.VersionId == other.VersionId && this.CorrelationId == other.CorrelationId && string.Equals(this.ClientId, other.ClientId) && this.ReplicaId == other.ReplicaId && this.RequestInfo.DictionaryEqual(other.RequestInfo); }
/// <summary> /// Get a list of valid offsets (up to maxSize) before the given time. /// </summary> /// <param name="request"></param> /// <returns></returns> internal OffsetResponse GetOffsetsBefore(OffsetRequest request) { return OffsetResponse.ReadFrom(this.SendRequest(request).Buffer); }
/// <summary> /// Get the earliest or latest offset of a given topic, partition. /// </summary> /// <param name="topicAndPartition">Topic and partition of which the offset is needed.</param> /// <param name="earliestOrLatest">A value to indicate earliest or latest offset.</param> /// <param name="consumerId">Id of the consumer which could be a consumer client, SimpleConsumerShell or a follower broker.</param> /// <returns>Requested offset.</returns> public long EarliestOrLatestOffset(TopicAndPartition topicAndPartition, long earliestOrLatest, int consumerId) { var request = new OffsetRequest( new Dictionary<TopicAndPartition, PartitionOffsetRequestInfo> { { topicAndPartition, new PartitionOffsetRequestInfo(earliestOrLatest, 1) } }, clientId: this.ClientId, replicaId: consumerId); var partitionErrorAndOffset = this.GetOffsetsBefore(request).PartitionErrorAndOffsets[topicAndPartition]; long offset; if (partitionErrorAndOffset.Error == ErrorMapping.NoError) { offset = partitionErrorAndOffset.Offsets[0]; } else { throw ErrorMapping.ExceptionFor(partitionErrorAndOffset.Error); } return offset; }
public RequestResponseSerializationTest() { this.producerRequest = SerializationTestUtils.CreateTestProducerRequest(); this.producerResponse = SerializationTestUtils.CreateTestProducerResponse(); this.fetchRequest = SerializationTestUtils.CreateTestFetchRequest(); this.offsetRequest = SerializationTestUtils.CreateTestOffsetRequest(); this.offsetResponse = SerializationTestUtils.CreateTestOffsetResponse(); this.topicMetadataRequest = SerializationTestUtils.CreateTestTopicMetadataRequest(); this.topicMetadataResponse = SerializationTestUtils.CreateTestTopicMetadataResponse(); }