Example #1
0
 public static FetchResponse ReadFromStream(BinaryStream stream)
 {
     var request = new FetchResponse();
     request.Partition = stream.Reader.ReadInt32();
     var length = stream.Reader.ReadInt32();
     request.Data = stream.Reader.ReadBytes(length);
     return request;
 }
Example #2
0
        public static FetchResponse ReadFromStream(BinaryStream stream)
        {
            var request = new FetchResponse();

            request.Partition = stream.Reader.ReadInt32();
            var length = stream.Reader.ReadInt32();

            request.Data = stream.Reader.ReadBytes(length);
            return(request);
        }
Example #3
0
        public static MultiFetchResponse ReadFromStream(BinaryStream stream)
        {
            var request = new MultiFetchResponse();
            var length  = stream.Reader.ReadInt32();

            request.FetchResponses = new List <FetchResponse>(length);
            for (int i = 0; i < length; i++)
            {
                request.FetchResponses.Add(FetchResponse.ReadFromStream(stream));
            }

            return(request);
        }
Example #4
0
        public Response HandleLoadMessages(BinaryStream buffer)
        {
            var request = FetchRequest.ReadFromStream(buffer);

            if (!_storage.ValidatePartitionNumber(request.Topic, request.Partition))
                return null;

            var block = _storage.ReadMessagesBlock(request.Topic, request.Partition, request.Offset, request.BlockSize);

            var response = new FetchResponse();
            response.Partition = request.Partition;
            response.Data = (block.Length == 0) ? new byte[0] : block.Data;

            return response;
        }