Ejemplo n.º 1
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.º 2
0
 public void FetchFrom(KafkaReader reader)
 {
     Partition = reader.ReadInt32();
     Offset    = reader.ReadInt64();
     Metadata  = reader.ReadString();
     ErrorCode = (ErrorCode)reader.ReadInt16();
 }
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 FetchFrom(KafkaReader reader)
 {
     ErrorCode    = (ErrorCode)reader.ReadInt16();
     GroupId      = reader.ReadString();
     State        = reader.ReadString();
     ProtocolType = reader.ReadString();
     Protocol     = reader.ReadString();
     Members      = reader.ReadArray <DescribeGroupsResponseMember>();
 }
Ejemplo n.º 6
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.º 7
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.º 8
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.º 9
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.º 10
0
 protected override void DeserializeContent(KafkaReader reader)
 {
     //Possible Error Codes:
     //* GROUP_COORDINATOR_NOT_AVAILABLE (15)
     //* NOT_COORDINATOR_FOR_GROUP (16)
     //* ILLEGAL_GENERATION (22)
     //* UNKNOWN_MEMBER_ID (25)
     //* REBALANCE_IN_PROGRESS (27)
     //* GROUP_AUTHORIZATION_FAILED (30)
     ErrorCode        = (ErrorCode)reader.ReadInt16();
     MemberAssignment = new SyncGroupMemberAssignment();
     MemberAssignment.FetchFrom(reader);
 }
Ejemplo n.º 11
0
        public void Int16Tests(short expectedValue, byte[] givenBytes)
        {
            for (var offset = 0; offset <= 2; offset++)
            {
                // arrange
                var binaryReader = new KafkaReader(OffsetBytes(givenBytes, offset));

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

                // assert
                Assert.That(actualValue, Is.EqualTo(expectedValue));
            }
        }
Ejemplo n.º 12
0
        public void FetchFrom(KafkaReader reader)
        {
            //Version = reader.ReadInt16();
            //Topics = reader.ReadStrings();
            //UserData = reader.ReadBytes();

            var protocolMetadata = reader.ReadBytes();

            if (protocolMetadata == null)
            {
                return;
            }
            using (var stream = new MemoryStream(protocolMetadata))
                using (var reader2 = new KafkaReader(stream)) {
                    Version  = reader2.ReadInt16();
                    Topics   = reader2.ReadStrings();
                    UserData = reader2.ReadBytes();
                }
        }
Ejemplo n.º 13
0
        public void FetchFrom(KafkaReader reader)
        {
            //Version = reader.ReadInt16();
            //PartitionAssignments = reader.ReadArray<SyncGroupPartitionAssignment>();
            //UserData = reader.ReadBytes();

            var memberAssignment = reader.ReadBytes();

            if (memberAssignment == null || memberAssignment.Length == 0)
            {
                return;
            }

            using (var stream = new MemoryStream(memberAssignment))
                using (var reader2 = new KafkaReader(stream)) {
                    Version = reader2.ReadInt16();
                    PartitionAssignments = reader2.ReadArray <SyncGroupPartitionAssignment>();
                    UserData             = reader2.ReadBytes();
                }
        }
Ejemplo n.º 14
0
 protected override void DeserializeContent(KafkaReader reader)
 {
     RequiredAcks    = (AcknowlegeStrategy)reader.ReadInt16();
     Timeout         = reader.ReadInt32();
     TopicPartitions = reader.ReadArray <ProduceRequestTopicPartition>();
 }
Ejemplo n.º 15
0
 public void FetchFrom(KafkaReader reader)
 {
     TopicErrorCode     = (ErrorCode)reader.ReadInt16();
     TopicName          = reader.ReadString();
     PartitionMetadatas = reader.ReadArray <PartitionMetadata>();
 }
Ejemplo n.º 16
0
 public void FetchFrom(KafkaReader reader)
 {
     Partition = reader.ReadInt32();
     ErrorCode = (ErrorCode)reader.ReadInt16();
 }
Ejemplo n.º 17
0
 protected override void DeserializeContent(KafkaReader reader)
 {
     ErrorCode = (ErrorCode)reader.ReadInt16();
 }
Ejemplo n.º 18
0
 protected override void DeserializeContent(KafkaReader reader)
 {
     ErrorCode = (ErrorCode)reader.ReadInt16();
     Groups    = reader.ReadArray <ListGroupsResponseGroup>();
 }