예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public Void handle(org.neo4j.causalclustering.core.consensus.RaftMessages_NewEntry_Request newEntryRequest) throws Exception
            public override Void Handle(Org.Neo4j.causalclustering.core.consensus.RaftMessages_NewEntry_Request newEntryRequest)
            {
                BoundedNetworkWritableChannel sizeBoundChannel = new BoundedNetworkWritableChannel(Channel.byteBuf(), ByteUnit.gibiBytes(1));

                Marshal.marshal(newEntryRequest.Content(), sizeBoundChannel);
                return(null);
            }
예제 #2
0
        public static sbyte[] CommandBytes(ICollection <StorageCommand> commands)
        {
            ByteBuf commandBuffer = Unpooled.buffer();
            BoundedNetworkWritableChannel channel = new BoundedNetworkWritableChannel(commandBuffer);

            try
            {
                (new LogEntryWriter(channel)).serialize(commands);
            }
            catch (IOException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);                           // TODO: Handle or throw.
            }

            /*
             * This trims down the array to send up to the actual index it was written. Not doing this would send additional
             * zeroes which not only wasteful, but also not handled by the LogEntryReader receiving this.
             */
            sbyte[] commandsBytes = Arrays.copyOf(commandBuffer.array(), commandBuffer.writerIndex());
            commandBuffer.release();

            return(commandsBytes);
        }