Exemplo n.º 1
0
        public virtual DatabaseLayout DatabaseLayout(File storeDir)
        {
            DatabaseLayout databaseLayout = StoreLayout.of(storeDir).databaseLayout(DEFAULT_DATABASE_DIRECTORY);

            CreateDirectory(databaseLayout.DatabaseDirectory());
            return(databaseLayout);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldExcludeTheStoreLockFromTheArchiveToAvoidProblemsWithReadingLockedFilesOnWindows() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldExcludeTheStoreLockFromTheArchiveToAvoidProblemsWithReadingLockedFilesOnWindows()
        {
            File lockFile = StoreLayout.of(new File(".")).storeLockFile();

            doAnswer(invocation =>
            {
                Predicate <Path> exclude = invocation.getArgument(4);
                assertThat(exclude.test(Paths.get(lockFile.Name)), @is(true));
                assertThat(exclude.test(Paths.get("some-other-file")), @is(false));
                return(null);
            }).when(_dumper).dump(any(), any(), any(), any(), any());

            Execute("foo.db");
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void prepareDirectory(Class testClass, String test) throws java.io.IOException
        public virtual void PrepareDirectory(Type testClass, string test)
        {
            if (_owningTest == null)
            {
                _owningTest = testClass;
            }
            if (string.ReferenceEquals(test, null))
            {
                test = "static";
            }
            _testDirectory         = PrepareDirectoryForTest(test);
            _storeLayout           = StoreLayout.of(_testDirectory);
            _defaultDatabaseLayout = _storeLayout.databaseLayout(DEFAULT_DATABASE_DIRECTORY);
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void onlyTheLatestTransactionIsKeptAfterIncrementalBackup() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void OnlyTheLatestTransactionIsKeptAfterIncrementalBackup()
        {
            // given database exists with data
            int port = PortAuthority.allocatePort();

            StartDb(port);
            CreateSomeData(_db);

            // and backup client is told to rotate conveniently
            Config config             = Config.builder().withSetting(GraphDatabaseSettings.logical_log_rotation_threshold, "1m").build();
            File   configOverrideFile = _testDirectory.file("neo4j-backup.conf");

            OnlineBackupCommandBuilder.WriteConfigToFile(config, configOverrideFile);

            // and we have a full backup
            string backupName = "backupName" + RecordFormat;
            string address    = "localhost:" + port;

            assertEquals(0, runBackupToolFromOtherJvmToGetExitCode(_backupDir, "--from", address, "--cc-report-dir=" + _backupDir, "--backup-dir=" + _backupDir, "--protocol=common", "--additional-config=" + configOverrideFile, "--name=" + backupName));

            // and the database contains a few more transactions
            Transactions1M(_db);
            Transactions1M(_db);                 // rotation, second tx log file

            // when we perform an incremental backup
            assertEquals(0, runBackupToolFromOtherJvmToGetExitCode(_backupDir, "--from", address, "--cc-report-dir=" + _backupDir, "--backup-dir=" + _backupDir, "--protocol=common", "--additional-config=" + configOverrideFile, "--name=" + backupName));

            // then there has been a rotation
            BackupTransactionLogFilesHelper backupTransactionLogFilesHelper = new BackupTransactionLogFilesHelper();
            LogFiles logFiles = BackupTransactionLogFilesHelper.ReadLogFiles(StoreLayout.of(_backupDir).databaseLayout(backupName));
            long     highestTxIdInLogFiles = logFiles.HighestLogVersion;

            assertEquals(2, highestTxIdInLogFiles);

            // and the original log has not been removed since the transactions are applied at start
            long lowestTxIdInLogFiles = logFiles.LowestLogVersion;

            assertEquals(0, lowestTxIdInLogFiles);
        }
Exemplo n.º 5
0
        public PlatformModule(File providedStoreDir, Config config, DatabaseInfo databaseInfo, GraphDatabaseFacadeFactory.Dependencies externalDependencies)
        {
            this.DatabaseInfo      = databaseInfo;
            this.DataSourceManager = new DataSourceManager(config);
            Dependencies           = new Dependencies();
            Dependencies.satisfyDependency(databaseInfo);

            Clock = Dependencies.satisfyDependency(CreateClock());
            Life  = Dependencies.satisfyDependency(CreateLife());

            this.StoreLayout = StoreLayout.of(providedStoreDir);

            config.AugmentDefaults(GraphDatabaseSettings.neo4j_home, StoreLayout.storeDirectory().Path);
            this.Config = Dependencies.satisfyDependency(config);

            FileSystem = Dependencies.satisfyDependency(CreateFileSystemAbstraction());
            Life.add(new FileSystemLifecycleAdapter(FileSystem));

            // Component monitoring
            Monitors = externalDependencies.Monitors() == null ? new Monitors() : externalDependencies.Monitors();
            Dependencies.satisfyDependency(Monitors);

            JobScheduler = Life.add(Dependencies.satisfyDependency(CreateJobScheduler()));
            StartDeferredExecutors(JobScheduler, externalDependencies.DeferredExecutors());

            // Cleanup after recovery, used by GBPTree, added to life in NeoStoreDataSource
            RecoveryCleanupWorkCollector = new GroupingRecoveryCleanupWorkCollector(JobScheduler);
            Dependencies.satisfyDependency(RecoveryCleanupWorkCollector);

            // Database system information, used by UDC
            UsageData = new UsageData(JobScheduler);
            Dependencies.satisfyDependency(Life.add(UsageData));

            // If no logging was passed in from the outside then create logging and register
            // with this life
            Logging = Dependencies.satisfyDependency(CreateLogService(externalDependencies.UserLogProvider()));

            config.Logger = Logging.getInternalLog(typeof(Config));

            Life.add(Dependencies.satisfyDependency(new StoreLockerLifecycleAdapter(CreateStoreLocker())));

            (new JvmChecker(Logging.getInternalLog(typeof(JvmChecker)), new JvmMetadataRepository())).checkJvmCompatibilityAndIssueWarning();

            string desiredImplementationName = config.Get(GraphDatabaseSettings.tracer);

            Tracers = Dependencies.satisfyDependency(new Tracers(desiredImplementationName, Logging.getInternalLog(typeof(Tracers)), Monitors, JobScheduler, Clock));
            Dependencies.satisfyDependency(Tracers.pageCacheTracer);
            Dependencies.satisfyDependency(FirstImplementor(typeof(LogRotationMonitor), Tracers.transactionTracer, LogRotationMonitor.NULL));
            Dependencies.satisfyDependency(FirstImplementor(typeof(CheckPointerMonitor), Tracers.checkPointTracer, CheckPointerMonitor.NULL));

            VersionContextSupplier = CreateCursorContextSupplier(config);

            CollectionsFactorySupplier = CreateCollectionsFactorySupplier(config, Life);

            Dependencies.satisfyDependency(VersionContextSupplier);
            PageCache = Dependencies.satisfyDependency(CreatePageCache(FileSystem, config, Logging, Tracers, VersionContextSupplier, JobScheduler));

            Life.add(new PageCacheLifecycle(PageCache));

            DiagnosticsManager = Life.add(Dependencies.satisfyDependency(new DiagnosticsManager(Logging.getInternalLog(typeof(DiagnosticsManager)))));
            SystemDiagnostics.registerWith(DiagnosticsManager);

            Dependencies.satisfyDependency(DataSourceManager);

            KernelExtensionFactories = externalDependencies.KernelExtensions();
            EngineProviders          = externalDependencies.ExecutionEngines();
            GlobalKernelExtensions   = Dependencies.satisfyDependency(new GlobalKernelExtensions(new SimpleKernelContext(StoreLayout.storeDirectory(), databaseInfo, Dependencies), KernelExtensionFactories, Dependencies, KernelExtensionFailureStrategies.fail()));

            UrlAccessRule = Dependencies.satisfyDependency(URLAccessRules.combined(externalDependencies.UrlAccessRules()));

            ConnectorPortRegister = new ConnectorPortRegister();
            Dependencies.satisfyDependency(ConnectorPortRegister);

            EventHandlers       = new KernelEventHandlers(Logging.getInternalLog(typeof(KernelEventHandlers)));
            PanicEventGenerator = new DatabasePanicEventGenerator(EventHandlers);

            PublishPlatformInfo(Dependencies.resolveDependency(typeof(UsageData)));
        }