Ejemplo n.º 1
0
 protected override void DeserializeContent(KafkaReader reader)
 {
     ReplicaId       = reader.ReadInt32();
     MaxWaitTime     = reader.ReadInt32();
     MinBytes        = reader.ReadInt32();
     TopicPartitions = reader.ReadArray <FetchRequestTopicPartition>();
 }
Ejemplo n.º 2
0
 public void FetchFrom(KafkaReader reader)
 {
     Partition      = reader.ReadInt32();
     MessageSetSize = reader.ReadInt32();
     MessageSet     = new MessageSet(MessageSetSize);
     MessageSet.FetchFrom(reader);
 }
Ejemplo n.º 3
0
 protected override void DeserializeContent(KafkaReader reader)
 {
     ErrorCode       = (ErrorCode)reader.ReadInt16();
     CoordinatorId   = reader.ReadInt32();
     CoordinatorHost = reader.ReadString();
     CoordinatorPort = reader.ReadInt32();
 }
Ejemplo n.º 4
0
 public void FetchFrom(KafkaReader reader)
 {
     PartitionErrorCode = (ErrorCode)reader.ReadInt16();
     PartitionId        = reader.ReadInt32();
     Leader             = reader.ReadInt32();
     Replicas           = reader.ReadInt32Array();
     Isr = reader.ReadInt32Array();
 }
Ejemplo n.º 5
0
 public void Deserialize(Stream stream)
 {
     using (var reader = new KafkaReader(stream)) {
         Size          = reader.ReadInt32();
         CorrelationId = reader.ReadInt32();
         DeserializeContent(reader);
     }
 }
Ejemplo n.º 6
0
 public void FetchFrom(KafkaReader reader)
 {
     Partition           = reader.ReadInt32();
     ErrorCode           = (ErrorCode)reader.ReadInt16();
     HighwaterMarkOffset = reader.ReadInt64();
     MessageSetSize      = reader.ReadInt32();
     MessageSet          = new MessageSet(MessageSetSize);
     // Min length per MessageSet: 8 + 4 + ( 4 + 1 + 1 + 4 + key.length + 4 + value.length) is 26
     // It means 2 msg has minimal MessageBody = 26*2 = 52
     MessageSet.FetchFrom(reader);
 }
Ejemplo n.º 7
0
 public void Deserialize(Stream stream)
 {
     using (var reader = new KafkaReader(stream)) {
         Size = reader.ReadInt32();
         var apiKey = (ApiKey)reader.ReadInt16();
         if (ApiKey != apiKey)
         {
             throw new InvalidOperationException("Request type definition error");
         }
         ApiVersion    = reader.ReadInt16();
         CorrelationId = reader.ReadInt32();
         ClientId      = reader.ReadString();
         DeserializeContent(reader);
     }
 }
Ejemplo n.º 8
0
        public static Response DeserializeFrom(Stream stream, ApiKey apiKey)
        {
            using (var reader = new KafkaReader(stream)) {
                var size         = reader.ReadInt32();
                var typeName     = apiKey.ToString().Replace("Request", "Response");
                var fullTypeNaem = (Int32)apiKey < 10 ? "Chuye.Kafka.Protocol." + typeName
                    : "Chuye.Kafka.Protocol.Management." + typeName;
                var type     = Type.GetType(fullTypeNaem);
                var instance = (Response)Activator.CreateInstance(type);

                instance.Size          = size;
                instance.CorrelationId = reader.ReadInt32();
                instance.DeserializeContent(reader);
                return(instance);
            }
        }
Ejemplo n.º 9
0
 public void FetchFrom(KafkaReader reader)
 {
     Partition = reader.ReadInt32();
     Offset    = reader.ReadInt64();
     Metadata  = reader.ReadString();
     ErrorCode = (ErrorCode)reader.ReadInt16();
 }
Ejemplo n.º 10
0
 protected override void DeserializeContent(KafkaReader reader)
 {
     ConsumerGroup             = reader.ReadString();
     ConsumerGroupGenerationId = reader.ReadInt32();
     ConsumerId      = reader.ReadString();
     TopicPartitions = reader.ReadArray <OffsetCommitRequestTopicPartitionV1>();
 }
Ejemplo n.º 11
0
 public void FetchFrom(KafkaReader reader)
 {
     Partition = reader.ReadInt32();
     Offset    = reader.ReadInt64();
     TimeStamp = reader.ReadInt64();
     Metadata  = reader.ReadString();
 }
Ejemplo n.º 12
0
 public void FetchFrom(KafkaReader reader)
 {
     Offset      = reader.ReadInt64();   //move 8
     MessageSize = reader.ReadInt32();   //move 4
     Message     = new MessageSetItem();
     Message.FetchFrom(reader);
 }
Ejemplo n.º 13
0
 protected override void DeserializeContent(KafkaReader reader)
 {
     GroupId          = reader.ReadString();
     GenerationId     = reader.ReadInt32();
     MemberId         = reader.ReadString();
     GroupAssignments = reader.ReadArray <SyncGroupGroupAssignment>();
 }
Ejemplo n.º 14
0
 protected override void DeserializeContent(KafkaReader reader)
 {
     GroupId        = reader.ReadString();
     SessionTimeout = reader.ReadInt32();
     MemberId       = reader.ReadString();
     ProtocolType   = reader.ReadString();
     GroupProtocols = reader.ReadArray <JoinGroupRequestGroupProtocol>();
 }
Ejemplo n.º 15
0
 public void FetchFrom(KafkaReader reader)
 {
     Crc        = reader.ReadInt32();                //move 4
     MagicByte  = reader.ReadByte();                 //move 1
     Attributes = (MessageCodec)reader.ReadByte();   //move 1
     Key        = reader.ReadBytes();                //move 4 + len(bytes) if not null
     Value      = reader.ReadBytes();                //move 4 + len(bytes) if not null
 }
Ejemplo n.º 16
0
 protected override void DeserializeContent(KafkaReader reader)
 {
     ErrorCode     = (ErrorCode)reader.ReadInt16();
     GenerationId  = reader.ReadInt32();
     GroupProtocol = reader.ReadString();
     LeaderId      = reader.ReadString();
     MemberId      = reader.ReadString();
     Members       = reader.ReadArray <JoinGroupResponseMember>();
 }
Ejemplo n.º 17
0
        public static Request DeserializeFrom(Stream stream)
        {
            using (var reader = new KafkaReader(stream)) {
                var size   = reader.ReadInt32();
                var apiKey = (ApiKey)reader.ReadInt16();

                var typeName     = apiKey.ToString();
                var fullTypeNaem = (Int32)apiKey < 10 ? "Chuye.Kafka.Protocol." + typeName
                    : "Chuye.Kafka.Protocol.Management." + typeName;
                var type     = Type.GetType(fullTypeNaem);
                var instance = (Request)Activator.CreateInstance(type);;

                instance.Size          = size;
                instance.ApiKey        = apiKey;
                instance.ApiVersion    = reader.ReadInt16();
                instance.CorrelationId = reader.ReadInt32();
                instance.ClientId      = reader.ReadString();
                instance.DeserializeContent(reader);
                return(instance);
            }
        }
Ejemplo n.º 18
0
        public void Int32Tests(int expectedValue, byte[] givenBytes)
        {
            for (var offset = 0; offset <= 4; offset++)
            {
                // arrange
                var binaryReader = new KafkaReader(OffsetBytes(givenBytes, offset));

                // act
                var actualValue = binaryReader.ReadInt32();

                // assert
                Assert.That(actualValue, Is.EqualTo(expectedValue));
            }
        }
Ejemplo n.º 19
0
 public static Boolean TryFetchFrom(KafkaReader reader, Int32 maxBytes, out MessageSetDetail item)
 {
     if (maxBytes < 12)
     {
         item = null;
         return(false);
     }
     item             = new MessageSetDetail();
     item.Offset      = reader.ReadInt64();   //move 8
     item.MessageSize = reader.ReadInt32();   //move 4
     if (item.MessageSize > maxBytes - 12)
     {
         item = null;
         return(false);
     }
     item.Message = new MessageSetItem();
     item.Message.FetchFrom(reader);
     return(true);
 }
Ejemplo n.º 20
0
        private static IKafkaReader ReadHeader(ArraySegment <byte> data, out ApiKey apiKey, out IRequestContext context)
        {
            var reader = new KafkaReader(data);

            try {
                apiKey = (ApiKey)reader.ReadInt16();
                var version       = reader.ReadInt16();
                var correlationId = reader.ReadInt32();
                var clientId      = reader.ReadString();

                context = new RequestContext(correlationId, version, clientId);
            } catch {
                apiKey  = 0;
                context = null;
                reader.Dispose();
                reader = null;
            }
            return(reader);
        }
Ejemplo n.º 21
0
 protected override void DeserializeContent(KafkaReader reader)
 {
     RequiredAcks    = (AcknowlegeStrategy)reader.ReadInt16();
     Timeout         = reader.ReadInt32();
     TopicPartitions = reader.ReadArray <ProduceRequestTopicPartition>();
 }
Ejemplo n.º 22
0
 protected override void DeserializeContent(KafkaReader reader)
 {
     GroupId      = reader.ReadString();
     GenerationId = reader.ReadInt32();
     MemberId     = reader.ReadString();
 }
Ejemplo n.º 23
0
 public void FetchFrom(KafkaReader reader)
 {
     Partition          = reader.ReadInt32();
     Time               = reader.ReadInt64();
     MaxNumberOfOffsets = reader.ReadInt32();
 }
Ejemplo n.º 24
0
 public void FetchFrom(KafkaReader reader)
 {
     Partition = reader.ReadInt32();
     ErrorCode = (ErrorCode)reader.ReadInt16();
 }
Ejemplo n.º 25
0
 public void FetchFrom(KafkaReader reader)
 {
     Partition   = reader.ReadInt32();
     FetchOffset = reader.ReadInt64();
     MaxBytes    = reader.ReadInt32();
 }
Ejemplo n.º 26
0
 public void FetchFrom(KafkaReader reader)
 {
     NodeId = reader.ReadInt32();
     Host   = reader.ReadString();
     Port   = reader.ReadInt32();
 }
Ejemplo n.º 27
0
 protected override void DeserializeContent(KafkaReader reader)
 {
     ReplicaId       = reader.ReadInt32();
     TopicPartitions = reader.ReadArray <OffsetsRequestTopicPartition>();
 }