Ejemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: protected void handleRequest(org.jboss.netty.buffer.ChannelBuffer buffer, final org.jboss.netty.channel.Channel channel)
        protected internal virtual void HandleRequest(ChannelBuffer buffer, Channel channel)
        {
            sbyte?continuation = ReadContinuationHeader(buffer, channel);

            if (continuation == null)
            {
                return;
            }
            if (continuation.Value == ChunkingChannelBuffer.CONTINUATION_MORE)
            {
                PartialRequest partialRequest = _partialRequests[channel];
                if (partialRequest == null)
                {
                    // This is the first chunk in a multi-chunk request
                    RequestType    type         = GetRequestContext(buffer.readByte());
                    RequestContext context      = ReadContext(buffer);
                    ChannelBuffer  targetBuffer = MapSlave(channel, context);
                    partialRequest            = new PartialRequest(this, type, context, targetBuffer);
                    _partialRequests[channel] = partialRequest;
                }
                partialRequest.Add(buffer);
            }
            else
            {
                PartialRequest partialRequest = _partialRequests.Remove(channel);
                RequestType    type;
                RequestContext context;
                ChannelBuffer  targetBuffer;
                ChannelBuffer  bufferToReadFrom;
                ChannelBuffer  bufferToWriteTo;
                if (partialRequest == null)
                {
                    // This is the one and single chunk in the request
                    type             = GetRequestContext(buffer.readByte());
                    context          = ReadContext(buffer);
                    targetBuffer     = MapSlave(channel, context);
                    bufferToReadFrom = buffer;
                    bufferToWriteTo  = targetBuffer;
                }
                else
                {
                    // This is the last chunk in a multi-chunk request
                    type         = partialRequest.Type;
                    context      = partialRequest.Context;
                    targetBuffer = partialRequest.Buffer;
                    partialRequest.Add(buffer);
                    bufferToReadFrom = targetBuffer;
                    bufferToWriteTo  = ChannelBuffers.dynamicBuffer();
                }

                bufferToWriteTo.clear();
                ChunkingChannelBuffer chunkingBuffer = NewChunkingBuffer(bufferToWriteTo, channel, _chunkSize, InternalProtocolVersion, _applicationProtocolVersion);
                SubmitSilent(_targetCallExecutor, new TargetCaller(this, type, channel, context, chunkingBuffer, bufferToReadFrom));
            }
        }
Ejemplo n.º 2
0
            // NOTICE: this assumes a "smart" ChannelBuffer that continues to next chunk
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public Void read(org.jboss.netty.buffer.ChannelBuffer buffer, ByteBuffer temporaryBuffer) throws java.io.IOException
            public override Void Read(ChannelBuffer buffer, ByteBuffer temporaryBuffer)
            {
                int pathLength;

                while (0 != (pathLength = buffer.readUnsignedShort()))
                {
                    string path    = ReadString(buffer, pathLength);
                    bool   hasData = buffer.readByte() == 1;
                    Writer.write(path, hasData ? new BlockLogReader(buffer) : null, temporaryBuffer, hasData, 1);
                }
                Writer.Dispose();
                return(null);
            }
Ejemplo n.º 3
0
            // NOTICE: this assumes a "smart" ChannelBuffer that continues to next chunk
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public Void read(org.jboss.netty.buffer.ChannelBuffer buffer, ByteBuffer temporaryBuffer) throws java.io.IOException
            public override Void Read(ChannelBuffer buffer, ByteBuffer temporaryBuffer)
            {
                int pathLength;

                while (0 != (pathLength = buffer.readUnsignedShort()))
                {
                    string path       = ReadString(buffer, pathLength);
                    bool   hasData    = buffer.readByte() == 1;
                    int    recordSize = hasData ? buffer.readInt() : Org.Neo4j.Kernel.impl.store.format.RecordFormat_Fields.NO_RECORD_SIZE;
                    Writer.write(path, hasData ? new BlockLogReader(buffer) : null, temporaryBuffer, hasData, recordSize);
                }
                Writer.Dispose();
                return(null);
            }
Ejemplo n.º 4
0
        public static bool ReadBoolean(ChannelBuffer buffer)
        {
            sbyte value = buffer.readByte();

            switch (value)
            {
            case 0:
                return(false);

            case 1:
                return(true);

            default:
                throw new ComException("Invalid boolean value " + value);
            }
        }
Ejemplo n.º 5
0
        protected internal static string BeginningOfBufferAsHexString(ChannelBuffer buffer, int maxBytesToPrint)
        {
            // read buffer from pos 0 - writeIndex
            int prevIndex = buffer.readerIndex();

            buffer.readerIndex(0);
            try
            {
                MemoryStream byteArrayStream = new MemoryStream(buffer.readableBytes());
                PrintStream  stream          = new PrintStream(byteArrayStream);
                HexPrinter   printer         = (new HexPrinter(stream)).withLineNumberDigits(4);
                for (int i = 0; buffer.readable() && i < maxBytesToPrint; i++)
                {
                    printer.append(buffer.readByte());
                }
                stream.flush();
                return(byteArrayStream.ToString());
            }
            finally
            {
                buffer.readerIndex(prevIndex);
            }
        }
Ejemplo n.º 6
0
 public override sbyte ReadByte()
 {
     return(_buffer.readByte());
 }