Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            Args arguments = Args.withFlags(TO_FILE).parse(args);

            using (Printer printer = GetPrinter(arguments))
            {
                foreach (string fileAsString in arguments.Orphans())
                {
                    Console.WriteLine("Reading file " + fileAsString);

                    try
                    {
                        using (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction())
                        {
                            (new DumpSegmentedRaftLog(fileSystem, CoreReplicatedContentMarshal.marshaller())).dump(fileAsString, printer.GetFor(fileAsString));
                        }
                    }
                    catch (Exception e) when(e is IOException || e is DisposedException || e is DamagedLogStorageException)
                    {
                        e.printStackTrace();
                    }
                }
            }
        }
Ejemplo n.º 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);
                        });
                    }
                }
            }
        }