Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBehaveCorrectlyUnderStress() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBehaveCorrectlyUnderStress()
        {
            long   durationInMinutes = parseLong(fromEnv("CHECK_POINT_LOG_ROTATION_STRESS_DURATION", DEFAULT_DURATION_IN_MINUTES));
            File   storeDir          = new File(fromEnv("CHECK_POINT_LOG_ROTATION_STORE_DIRECTORY", _defaultStoreDir));
            long   nodeCount         = parseLong(fromEnv("CHECK_POINT_LOG_ROTATION_NODE_COUNT", DEFAULT_NODE_COUNT));
            int    threads           = parseInt(fromEnv("CHECK_POINT_LOG_ROTATION_WORKER_THREADS", DEFAULT_WORKER_THREADS));
            string pageCacheMemory   = fromEnv("CHECK_POINT_LOG_ROTATION_PAGE_CACHE_MEMORY", DEFAULT_PAGE_CACHE_MEMORY);

            Console.WriteLine("1/6\tBuilding initial store...");
            using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), JobScheduler jobScheduler = new ThreadPoolJobScheduler())
            {
                Config dbConfig = Config.defaults();
                (new ParallelBatchImporter(DatabaseLayout.of(ensureExistsAndEmpty(storeDir)), fileSystem, null, DEFAULT, NullLogService.Instance, ExecutionMonitors.defaultVisible(jobScheduler), EMPTY, dbConfig, RecordFormatSelector.selectForConfig(dbConfig, NullLogProvider.Instance), NO_MONITOR, jobScheduler)).doImport(new NodeCountInputs(nodeCount));
            }

            Console.WriteLine("2/6\tStarting database...");
            GraphDatabaseBuilder builder = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(storeDir);
            GraphDatabaseService db      = builder.SetConfig(GraphDatabaseSettings.pagecache_memory, pageCacheMemory).setConfig(GraphDatabaseSettings.keep_logical_logs, Settings.FALSE).setConfig(GraphDatabaseSettings.check_point_interval_time, CHECK_POINT_INTERVAL_MINUTES + "m").setConfig(GraphDatabaseSettings.tracer, "timer").newGraphDatabase();

            Console.WriteLine("3/6\tWarm up db...");
            using (Workload workload = new Workload(db, defaultRandomMutation(nodeCount, db), threads))
            {
                // make sure to run at least one checkpoint during warmup
                long warmUpTimeMillis = TimeUnit.SECONDS.toMillis(CHECK_POINT_INTERVAL_MINUTES * 2);
                workload.Run(warmUpTimeMillis, Workload.TransactionThroughput_Fields.NONE);
            }

            Console.WriteLine("4/6\tStarting workload...");
            TransactionThroughputChecker throughput = new TransactionThroughputChecker();

            using (Workload workload = new Workload(db, defaultRandomMutation(nodeCount, db), threads))
            {
                workload.Run(TimeUnit.MINUTES.toMillis(durationInMinutes), throughput);
            }

            Console.WriteLine("5/6\tShutting down...");
            Db.shutdown();

            try
            {
                Console.WriteLine("6/6\tPrinting stats and recorded timings...");
                TimerTransactionTracer.printStats(System.out);
                throughput.AssertThroughput(System.out);
            }
            finally
            {
                Console.WriteLine("Done.");
            }

            // let's cleanup disk space when everything went well
            FileUtils.deleteRecursively(storeDir);
        }