protected bool Equals(ProducerRequest other)
 {
     return(this.VersionId == other.VersionId &&
            string.Equals(this.ClientId, other.ClientId) &&
            this.CorrelationId == other.CorrelationId &&
            this.RequiredAcks == other.RequiredAcks &&
            this.AckTimeoutMs == other.AckTimeoutMs &&
            this.Data.DictionaryEqual(other.Data));
 }
Esempio n. 2
0
        public void TestEmptyProduceRequest()
        {
            var props = TestUtils.GetSyncProducerConfig(this.Configs[0].Port);

            var correlationId = 0;
            var clientId = SyncProducerConfig.DefaultClientId;
            var acktimeoutMs = SyncProducerConfig.DefaultAckTimeout;
            short ack = 1;
            var emptyResult = new ProducerRequest(
                correlationId, clientId, ack, acktimeoutMs, new Dictionary<TopicAndPartition, ByteBufferMessageSet>());

            var producer = new SyncProducer(props);
            var response = producer.Send(emptyResult);
            Assert.True(response != null);
            Assert.True(!response.HasError() && response.Status.Count() == 0);
        }
Esempio n. 3
0
        public void TestProduceRequestWithNoResponse()
        {
            var props = TestUtils.GetSyncProducerConfig(this.Configs[0].Port);

            var correlationId = 0;
            var clientId = SyncProducerConfig.DefaultClientId;
            var ackTimeoutMs = SyncProducerConfig.DefaultAckTimeout;
            var ack = (short)0;
            var emptyRequest = new ProducerRequest(
                correlationId, clientId, ack, ackTimeoutMs, new Dictionary<TopicAndPartition, ByteBufferMessageSet>());
            var producer = new SyncProducer(props);
            var response = producer.Send(emptyRequest);
            Assert.True(response == null);
        }
Esempio n. 4
0
        public ProducerResponse Send(ProducerRequest producerRequest)
        {
            var requestSize = producerRequest.SizeInBytes;
            this.producerRequestStats.GetProducerRequestStats(this.BrokerInfo).RequestSizeHist.Update(requestSize);
            this.producerRequestStats.GetProducerRequestAllBrokersStats().RequestSizeHist.Update(requestSize);

            Receive response = null;
            var specificTimer = this.producerRequestStats.GetProducerRequestStats(this.BrokerInfo).RequestTimer;
            var aggregateTimer = this.producerRequestStats.GetProducerRequestAllBrokersStats().RequestTimer;

            aggregateTimer.Time(() => specificTimer.Time(() =>
                {
                    response = this.DoSend(producerRequest, producerRequest.RequiredAcks != 0);
                }));

            if (producerRequest.RequiredAcks != 0)
            {
                return ProducerResponse.ReadFrom(response.Buffer);
            }
            else
            {
                return null;
            }
        }
Esempio n. 5
0
 protected bool Equals(ProducerRequest other)
 {
     return this.VersionId == other.VersionId 
         && string.Equals(this.ClientId, other.ClientId)
         && this.CorrelationId == other.CorrelationId 
         && this.RequiredAcks == other.RequiredAcks 
         && this.AckTimeoutMs == other.AckTimeoutMs 
         && this.Data.DictionaryEqual(other.Data);
 }
 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();
 }