Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDecodeSplitChunk()
        public virtual void ShouldDecodeSplitChunk()
        {
            // first part of the chunk contains size header and some bytes
            ByteBuf input1 = buffer();

            input1.writeShort(9);
            input1.writeByte(1);
            input1.writeByte(11);
            input1.writeByte(2);
            // nothing should be available for reading
            assertFalse(_channel.writeInbound(input1));

            // second part contains just a single byte
            ByteBuf input2 = buffer();

            input2.writeByte(22);
            // nothing should be available for reading
            assertFalse(_channel.writeInbound(input2));

            // third part contains couple more bytes
            ByteBuf input3 = buffer();

            input3.writeByte(3);
            input3.writeByte(33);
            input3.writeByte(4);
            // nothing should be available for reading
            assertFalse(_channel.writeInbound(input3));

            // fourth part contains couple more bytes, and the chunk is now complete
            ByteBuf input4 = buffer();

            input4.writeByte(44);
            input4.writeByte(5);
            // there should be something to read now
            assertTrue(_channel.writeInbound(input4));

            assertTrue(_channel.finish());

            // there should only be a single chunk available for reading
            assertEquals(1, _channel.inboundMessages().size());
            // it should have no size header and expected body
            assertByteBufEquals(wrappedBuffer(new sbyte[] { 1, 11, 2, 22, 3, 33, 4, 44, 5 }), _channel.readInbound());
        }
Exemplo n.º 2
0
        internal static ByteBuf SerializeTerms(RaftLogEntry[] raftLogEntries, ByteBufAllocator byteBufAllocator)
        {
            int     capacity = (sizeof(sbyte) * 8) + (sizeof(int) * 8) + (sizeof(long) * 8) * raftLogEntries.Length;
            ByteBuf buffer   = byteBufAllocator.buffer(capacity, capacity);

            buffer.writeByte(ContentType.RaftLogEntryTerms.get());
            buffer.writeInt(raftLogEntries.Length);
            foreach (RaftLogEntry raftLogEntry in raftLogEntries)
            {
                buffer.writeLong(raftLogEntry.Term());
            }
            return(buffer);
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDecodeFullChunk()
        public virtual void ShouldDecodeFullChunk()
        {
            // whole chunk with header and body arrives at once
            ByteBuf input = buffer();

            input.writeShort(7);
            input.writeByte(1);
            input.writeByte(11);
            input.writeByte(2);
            input.writeByte(22);
            input.writeByte(3);
            input.writeByte(33);
            input.writeByte(4);

            // after buffer is written there should be something to read on the other side
            assertTrue(_channel.writeInbound(input));
            assertTrue(_channel.finish());

            // there should only be a single chunk available for reading
            assertEquals(1, _channel.inboundMessages().size());
            // it should have no size header and expected body
            assertByteBufEquals(input.slice(2, 7), _channel.readInbound());
        }
Exemplo n.º 4
0
 protected internal override void Encode(ChannelHandlerContext ctx, ResponseMessageType response, ByteBuf @out)
 {
     @out.writeByte(response.messageType());
 }
Exemplo n.º 5
0
 protected internal override void Encode(ChannelHandlerContext ctx, GetStoreIdRequest msg, ByteBuf @out)
 {
     @out.writeByte(0);
 }
Exemplo n.º 6
0
 protected internal override void Encode(ChannelHandlerContext ctx, CoreSnapshotRequest msg, ByteBuf @out)
 {
     @out.writeByte(0);
 }
Exemplo n.º 7
0
 public override WritableChannel Put(sbyte value)
 {
     @delegate.writeByte(value);
     return(this);
 }
Exemplo n.º 8
0
 protected internal override void Encode(ChannelHandlerContext ctx, ContentType msg, ByteBuf @out)
 {
     @out.writeByte(msg.get());
 }
Exemplo n.º 9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.storageengine.api.WritableChannel put(byte value) throws MessageTooBigException
        public override WritableChannel Put(sbyte value)
        {
            CheckSize(Byte.BYTES);
            @delegate.writeByte(value);
            return(this);
        }