示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.kernel.impl.transaction.TransactionRepresentation read(org.jboss.netty.buffer.ChannelBuffer buffer, ByteBuffer temporaryBuffer) throws java.io.IOException
            public override TransactionRepresentation Read(ChannelBuffer buffer, ByteBuffer temporaryBuffer)
            {
                NetworkReadableClosableChannel channel = new NetworkReadableClosableChannel(buffer);

                int  authorId = channel.Int;
                int  masterId = channel.Int;
                long latestCommittedTxWhenStarted = channel.Long;
                long timeStarted   = channel.Long;
                long timeCommitted = channel.Long;

                int headerLength = channel.Int;

                sbyte[] header = new sbyte[headerLength];
                channel.Get(header, headerLength);

                LogEntryCommand        entryRead;
                IList <StorageCommand> commands = new LinkedList <StorageCommand>();

                while ((entryRead = ( LogEntryCommand )Reader.readLogEntry(channel)) != null)
                {
                    commands.Add(entryRead.Command);
                }

                PhysicalTransactionRepresentation toReturn = new PhysicalTransactionRepresentation(commands);

                toReturn.SetHeader(header, masterId, authorId, timeStarted, latestCommittedTxWhenStarted, timeCommitted, -1);
                return(toReturn);
            }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public <PAYLOAD> Response<PAYLOAD> deserializeResponse(org.jboss.netty.handler.queue.BlockingReadHandler<org.jboss.netty.buffer.ChannelBuffer> reader, ByteBuffer input, long timeout, Deserializer<PAYLOAD> payloadDeserializer, ResourceReleaser channelReleaser, final org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader<org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel> entryReader) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        public virtual Response <PAYLOAD> DeserializeResponse <PAYLOAD>(BlockingReadHandler <ChannelBuffer> reader, ByteBuffer input, long timeout, Deserializer <PAYLOAD> payloadDeserializer, ResourceReleaser channelReleaser, LogEntryReader <ReadableClosablePositionAwareChannel> entryReader)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final DechunkingChannelBuffer dechunkingBuffer = new DechunkingChannelBuffer(reader, timeout, internalProtocolVersion, applicationProtocolVersion);
            DechunkingChannelBuffer dechunkingBuffer = new DechunkingChannelBuffer(reader, timeout, _internalProtocolVersion, _applicationProtocolVersion);

            PAYLOAD response = payloadDeserializer.Read(dechunkingBuffer, input);
            StoreId storeId  = ReadStoreId(dechunkingBuffer, input);

            // Response type is what previously was a byte saying how many data sources there were in the
            // coming transaction stream response. For backwards compatibility we keep it as a byte and we introduce
            // the transaction obligation response type as -1
            sbyte responseType = dechunkingBuffer.ReadByte();

            if (responseType == TransactionObligationResponse.RESPONSE_TYPE)
            {
                // It is a transaction obligation response
                long obligationTxId = dechunkingBuffer.ReadLong();
                return(new TransactionObligationResponse <PAYLOAD>(response, storeId, obligationTxId, channelReleaser));
            }

            // It's a transaction stream in this response
            TransactionStream transactions = visitor =>
            {
                NetworkReadableClosableChannel channel = new NetworkReadableClosableChannel(dechunkingBuffer);

                using (PhysicalTransactionCursor <ReadableClosablePositionAwareChannel> cursor = new PhysicalTransactionCursor <ReadableClosablePositionAwareChannel>(channel, entryReader))
                {
                    while (cursor.next() && !visitor.visit(cursor.get()))
                    {
                    }
                }
            };

            return(new TransactionStreamResponse <PAYLOAD>(response, storeId, transactions, channelReleaser));
        }