public override void WriteTo(ByteBuffer buffer)
        {
            buffer.PutShort(this.VersionId);
            buffer.PutInt(this.CorrelationId);
            ApiUtils.WriteShortString(buffer, this.ClientId);
            buffer.PutShort(this.RequiredAcks);
            buffer.PutInt(this.AckTimeoutMs);

            // save the topic structure
            buffer.PutInt(this.dataGroupedByTopic.Value.Count); // the number of topics
            foreach (var kvp in this.dataGroupedByTopic.Value)
            {
                var topic = kvp.Key;
                var topicAndPartitonData = kvp.Value;
                ApiUtils.WriteShortString(buffer, topic); // write the topic
                buffer.PutInt(topicAndPartitonData.Count);
                foreach (var partitionAndData in topicAndPartitonData)
                {
                    var partition            = partitionAndData.Key.Partiton;
                    var partitionMessageData = partitionAndData.Value;
                    var bytes = partitionMessageData.Buffer;
                    buffer.PutInt(partition);
                    buffer.PutInt((int)bytes.Length);
                    buffer.Put(bytes);
                    bytes.Position = 0;
                }
            }
        }
 public override void WriteTo(ByteBuffer buffer)
 {
     buffer.PutShort(this.VersionId);
     buffer.PutInt(this.CorrelationId);
     ApiUtils.WriteShortString(buffer, this.ClientId);
     buffer.PutInt(this.Topics.Count);
     foreach (var topic in this.Topics)
     {
         ApiUtils.WriteShortString(buffer, topic);
     }
 }
Пример #3
0
 public void WriteTo(ByteBuffer buffer)
 {
     /* error code */
     buffer.PutShort(this.ErrorCode);
     /* topic */
     ApiUtils.WriteShortString(buffer, this.Topic);
     /* number of partitions */
     buffer.PutInt(this.PartitionsMetadata.Count());
     foreach (var m in this.PartitionsMetadata)
     {
         m.WriteTo(buffer);
     }
 }
Пример #4
0
        public override void WriteTo(ByteBuffer buffer)
        {
            var groupedStatus = this.statusGroupedByTopic.Value;

            buffer.PutInt(this.CorrelationId);
            buffer.PutInt(groupedStatus.Count); // topic count

            foreach (var topicStatus in groupedStatus)
            {
                var topic            = topicStatus.Key;
                var errorsAndOffsets = topicStatus.Value;
                ApiUtils.WriteShortString(buffer, topic);
                buffer.PutInt(errorsAndOffsets.Count); // partition count
                foreach (var kvp in errorsAndOffsets)
                {
                    buffer.PutInt(kvp.Key.Partiton);
                    buffer.PutShort(kvp.Value.Error);
                    buffer.PutLong(kvp.Value.Offset);
                }
            }
        }
Пример #5
0
 public override void WriteTo(ByteBuffer buffer)
 {
     buffer.PutInt(CorrelationId);
     buffer.PutInt(offsetsGroupedByTopic.Value.Count); // topic count
     foreach (var kvp in offsetsGroupedByTopic.Value)
     {
         var topic = kvp.Key;
         var errorAndOffsetsMap = kvp.Value;
         ApiUtils.WriteShortString(buffer, topic);
         buffer.PutInt(errorAndOffsetsMap.Count);
         foreach (var topicPartitionAndErrorOffset in errorAndOffsetsMap)
         {
             buffer.PutInt(topicPartitionAndErrorOffset.Key.Partiton);
             buffer.PutShort(topicPartitionAndErrorOffset.Value.Error);
             buffer.PutInt(topicPartitionAndErrorOffset.Value.Offsets.Count);
             foreach (var offset in topicPartitionAndErrorOffset.Value.Offsets)
             {
                 buffer.PutLong(offset);
             }
         }
     }
 }
Пример #6
0
 public override void WriteTo(ByteBuffer buffer)
 {
     buffer.PutShort(this.VersionId);
     buffer.PutInt(this.CorrelationId);
     ApiUtils.WriteShortString(buffer, this.ClientId);
     buffer.PutInt(this.ReplicaId);
     buffer.PutInt(this.MaxWait);
     buffer.PutInt(this.MinBytes);
     buffer.PutInt(this.requestInfoGroupedByTopic.Value.Count); // topic count
     foreach (var kvp in this.requestInfoGroupedByTopic.Value)
     {
         var topic = kvp.Key;
         var partitionFetchInfos = kvp.Value;
         ApiUtils.WriteShortString(buffer, topic);
         buffer.PutInt(partitionFetchInfos.Count); // partition count
         foreach (var pfi in partitionFetchInfos)
         {
             buffer.PutInt(pfi.Key.Partiton);
             buffer.PutLong(pfi.Value.Offset);
             buffer.PutInt(pfi.Value.FetchSize);
         }
     }
 }
Пример #7
0
        public override void WriteTo(ByteBuffer buffer)
        {
            buffer.PutShort(this.VersionId);
            buffer.PutInt(this.CorrelationId);
            ApiUtils.WriteShortString(buffer, this.ClientId);
            buffer.PutInt(this.ReplicaId);

            buffer.PutInt(this.requestInfoGroupedByTopic.Value.Count);
            foreach (var topicAndPartitionInfos in this.requestInfoGroupedByTopic.Value)
            {
                var topic          = topicAndPartitionInfos.Key;
                var partitionInfos = topicAndPartitionInfos.Value;
                ApiUtils.WriteShortString(buffer, topic);
                buffer.PutInt(partitionInfos.Count); // partition count
                foreach (var pi in partitionInfos)
                {
                    var partition     = pi.Key.Partiton;
                    var partitionInfo = pi.Value;
                    buffer.PutInt(partition);
                    buffer.PutLong(partitionInfo.Time);
                    buffer.PutInt(partitionInfo.MaxNumOffsets);
                }
            }
        }