示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void assertMarshalingEquality(io.netty.buffer.ByteBuf buffer, org.neo4j.causalclustering.core.state.machines.tx.TransactionRepresentationReplicatedTransaction replicatedTx) throws java.io.IOException, org.neo4j.causalclustering.messaging.EndOfStreamException
        private void AssertMarshalingEquality(ByteBuf buffer, TransactionRepresentationReplicatedTransaction replicatedTx)
        {
            _marshal.marshal(replicatedTx, new NetworkWritableChannel(buffer));

            ReplicatedContent unmarshal = _marshal.unmarshal(new NetworkReadableClosableChannelNetty4(buffer));

            TransactionRepresentation tx = replicatedTx.Tx();

            sbyte[] extraHeader = tx.AdditionalHeader();
            if (extraHeader == null)
            {
                // hackishly set additional header to empty array...
                (( PhysicalTransactionRepresentation )tx).setHeader(new sbyte[0], tx.MasterId, tx.AuthorId, tx.TimeStarted, tx.LatestCommittedTxWhenStarted, tx.TimeCommitted, tx.LockSessionId);
                extraHeader = tx.AdditionalHeader();
            }
            TransactionRepresentation representation = ReplicatedTransactionFactory.extractTransactionRepresentation(( ReplicatedTransaction )unmarshal, extraHeader);

            assertThat(representation, equalTo(tx));
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void main(String[] args) throws java.io.IOException
        public static void Main(string[] args)
        {
            Args arg = Args.parse(args);

            string from = arg.Get("from");

            Console.WriteLine("From is " + from);
            string to = arg.Get("to");

            Console.WriteLine("to is " + to);

            File logDirectory = new File(from);

            Console.WriteLine("logDirectory = " + logDirectory);
            Config config = Config.defaults(stringMap());

            using (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction())
            {
                LogProvider            logProvider     = Instance;
                CoreLogPruningStrategy pruningStrategy = (new CoreLogPruningStrategyFactory(config.Get(raft_log_pruning_strategy), logProvider)).newInstance();
                SegmentedRaftLog       log             = new SegmentedRaftLog(fileSystem, logDirectory, config.Get(raft_log_rotation_size), CoreReplicatedContentMarshal.marshaller(), logProvider, config.Get(raft_log_reader_pool_size), Clocks.systemClock(), new ThreadPoolJobScheduler(), pruningStrategy);

                long totalCommittedEntries = log.AppendIndex();                         // Not really, but we need to have a way to pass in the commit index
                for (int i = 0; i <= totalCommittedEntries; i++)
                {
                    ReplicatedContent content = readLogEntry(log, i).content();
                    if (content is ReplicatedTransaction)
                    {
                        ReplicatedTransaction tx = ( ReplicatedTransaction )content;
                        ReplicatedTransactionFactory.extractTransactionRepresentation(tx, new sbyte[0]).accept(element =>
                        {
                            Console.WriteLine(element);
                            return(false);
                        });
                    }
                }
            }
        }