コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void rebuildReplicatedIdGeneratorsOnRecovery() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RebuildReplicatedIdGeneratorsOnRecovery()
        {
            DefaultFileSystemAbstraction fileSystem = FileSystemRule.get();
            File stickyGenerator      = new File(TestDirectory.databaseDir(), "stickyGenerator");
            File nodeStoreIdGenerator = TestDirectory.databaseLayout().idNodeStore();

            StoreFactory storeFactory = new StoreFactory(TestDirectory.databaseLayout(), Config.defaults(), GetIdGenerationFactory(fileSystem), PageCacheRule.getPageCache(fileSystem), fileSystem, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            using (NeoStores neoStores = storeFactory.OpenAllNeoStores(true))
            {
                NodeStore nodeStore = neoStores.NodeStore;
                for (int i = 0; i < 50; i++)
                {
                    NodeRecord nodeRecord = nodeStore.NewRecord();
                    nodeRecord.InUse = true;
                    nodeRecord.Id    = nodeStore.NextId();
                    if (i == 47)
                    {
                        FileUtils.copyFile(nodeStoreIdGenerator, stickyGenerator);
                    }
                    nodeStore.UpdateRecord(nodeRecord);
                }
            }

            FileUtils.copyFile(stickyGenerator, nodeStoreIdGenerator);
            using (NeoStores reopenedStores = storeFactory.OpenAllNeoStores())
            {
                reopenedStores.MakeStoreOk();
                assertEquals(51L, reopenedStores.NodeStore.nextId());
            }
        }
コード例 #2
0
ファイル: StoreFactoryTest.cs プロジェクト: Neo4Net/Neo4Net
        private StoreFactory StoreFactory(Config config, params OpenOption[] openOptions)
        {
            LogProvider    logProvider    = NullLogProvider.Instance;
            DatabaseLayout databaseLayout = _testDirectory.databaseLayout();
            RecordFormats  recordFormats  = selectForStoreOrConfig(config, databaseLayout, _fsRule, _pageCache, logProvider);

            return(new StoreFactory(databaseLayout, config, _idGeneratorFactory, _pageCache, _fsRule.get(), recordFormats, logProvider, EmptyVersionContextSupplier.EMPTY, openOptions));
        }
コード例 #3
0
ファイル: PropertyStoreTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            _fileSystemAbstraction = FsRule.get();
            _storeFile             = TestDirectory.databaseLayout().propertyStore();
            _idFile = TestDirectory.databaseLayout().idPropertyStore();

            _fileSystemAbstraction.mkdir(_storeFile.ParentFile);
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void openingThroughStoreAccessShouldNotTriggerRecovery() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void OpeningThroughStoreAccessShouldNotTriggerRecovery()
        {
            using (EphemeralFileSystemAbstraction snapshot = ProduceUncleanStore())
            {
                assertTrue("Store should be unclean", IsUnclean(snapshot));

                PageCache pageCache = PageCacheRule.getPageCache(snapshot);
                (new StoreAccess(snapshot, pageCache, TestDirectory.databaseLayout(), Config.defaults())).initialize().close();
                assertTrue("Store should be unclean", IsUnclean(snapshot));
            }
        }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SetUp()
        {
            _databaseLayout       = _testDirectory.databaseLayout();
            _storeDir             = _databaseLayout.databaseDirectory();
            _nativeLabelIndex     = _databaseLayout.labelScanStore();
            _migrationLayout      = _testDirectory.databaseLayout("migrationDir");
            _luceneLabelScanStore = _testDirectory.databaseDir().toPath().resolve(Paths.get("schema", "label", "lucene")).toFile();

            _fileSystem    = _fileSystemRule.get();
            _pageCache     = _pageCacheRule.getPageCache(_fileSystemRule);
            _indexMigrator = new NativeLabelScanStoreMigrator(_fileSystem, _pageCache, Config.defaults());
            _fileSystem.mkdirs(_luceneLabelScanStore);
        }
コード例 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void provideAccessOnlyToActiveDatabase()
        internal virtual void ProvideAccessOnlyToActiveDatabase()
        {
            DataSourceManager  manager     = CreateDataSourceManager();
            NeoStoreDataSource dataSource1 = mock(typeof(NeoStoreDataSource));
            NeoStoreDataSource dataSource2 = mock(typeof(NeoStoreDataSource));

            when(dataSource1.DatabaseLayout).thenReturn(_testDirectory.databaseLayout());
            when(dataSource2.DatabaseLayout).thenReturn(_testDirectory.databaseLayout("somethingElse"));
            manager.Register(dataSource1);
            manager.Register(dataSource2);

            assertEquals(dataSource1, manager.DataSource);
        }
コード例 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void firstRecordOtherThanZeroIfNotFirst()
        public virtual void FirstRecordOtherThanZeroIfNotFirst()
        {
            File             storeDir = TestDirectory.databaseDir();
            GraphDatabaseAPI db       = ( GraphDatabaseAPI )_factory.newImpermanentDatabase(storeDir);
            Transaction      tx       = Db.beginTx();
            Node             node     = Db.createNode();

            node.SetProperty("name", "Yo");
            tx.Success();
            tx.Close();
            Db.shutdown();

            db = ( GraphDatabaseAPI )_factory.newImpermanentDatabase(storeDir);
            tx = Db.beginTx();
            Properties(db).setProperty("test", "something");
            tx.Success();
            tx.Close();
            Db.shutdown();

            Config       config       = Config.defaults();
            StoreFactory storeFactory = new StoreFactory(TestDirectory.databaseLayout(), config, new DefaultIdGeneratorFactory(Fs.get()), PageCacheRule.getPageCache(Fs.get()), Fs.get(), NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);
            NeoStores    neoStores    = storeFactory.OpenAllNeoStores();
            long         prop         = neoStores.MetaDataStore.GraphNextProp;

            assertTrue(prop != 0);
            neoStores.Close();
        }
コード例 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            _databaseLayout = _testDirectory.databaseLayout();
            _storeDir       = _databaseLayout.databaseDirectory();
            _fileSystem     = _fileSystemRule.get();
            (new TestGraphDatabaseFactory()).setFileSystem(_fileSystem).newImpermanentDatabase(_storeDir).shutdown();
        }
コード例 #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before()
        public virtual void Before()
        {
            FileSystemAbstraction fs           = this._fs.get();
            StoreFactory          storeFactory = new StoreFactory(_testDirectory.databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory(fs), _pageCacheRule.getPageCache(fs), fs, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            _neoStores = storeFactory.OpenAllNeoStores(true);
        }
コード例 #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldHandleMultipleIdSpaces() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldHandleMultipleIdSpaces()
        {
            // GIVEN
            string           indexName      = "name";
            string           key            = "key";
            DatabaseLayout   databaseLayout = _testDirectory.databaseLayout();
            IndexConfigStore configStore    = new IndexConfigStore(databaseLayout, _fs);

            configStore.Set(typeof(Node), indexName, EXACT_CONFIG);
            using (Lifespan lifespan = new Lifespan())
            {
                Config           dataSourceConfig   = Config.defaults(LuceneDataSource.Configuration.Ephemeral, Settings.TRUE);
                LuceneDataSource originalDataSource = new LuceneDataSource(databaseLayout, dataSourceConfig, configStore, _fs, OperationalMode.single);
                LuceneDataSource dataSource         = lifespan.Add(spy(originalDataSource));

                using (LuceneCommandApplier applier = new LuceneCommandApplier(dataSource, false))
                {
                    // WHEN issuing a command where the index name is mapped to a certain id
                    IndexDefineCommand definitions = definitions(ObjectIntHashMap.newWithKeysValues(indexName, 0), ObjectIntHashMap.newWithKeysValues(key, 0));
                    applier.VisitIndexDefineCommand(definitions);
                    applier.VisitIndexAddNodeCommand(AddNodeToIndex(definitions, indexName, 0L));
                    // and then later issuing a command for that same index, but in another transaction where
                    // the local index name id is a different one
                    definitions = definitions(ObjectIntHashMap.newWithKeysValues(indexName, 1), ObjectIntHashMap.newWithKeysValues(key, 0));
                    applier.VisitIndexDefineCommand(definitions);
                    applier.VisitIndexAddNodeCommand(AddNodeToIndex(definitions, indexName, 1L));
                }

                // THEN both those updates should have been directed to the same index
                verify(dataSource, times(1)).getIndexSearcher(any(typeof(IndexIdentifier)));
            }
        }
コード例 #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before()
        public virtual void Before()
        {
            StoreFactory storeFactory = new StoreFactory(_testDirectory.databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory(_fs.get()), PageCacheRule.getPageCache(_fs.get()), _fs.get(), NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            _neoStores = storeFactory.OpenAllNeoStores(true);
            _store     = _neoStores.PropertyStore;
            _converter = new PropertyPhysicalToLogicalConverter(_store);
        }
コード例 #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPropagateIOExceptions() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPropagateIOExceptions()
        {
            // Given
            TransactionFailureException exceptionThrown = null;

            File storeDir = TestDirectory.storeDir();
            LimitedFileSystemGraphDatabase db = new LimitedFileSystemGraphDatabase(storeDir);

            using (Transaction tx = Db.beginTx())
            {
                Db.createNode();
                tx.Success();
            }

            long logVersion = Db.DependencyResolver.resolveDependency(typeof(LogVersionRepository)).CurrentLogVersion;

            Db.runOutOfDiskSpaceNao();

            // When
            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    Db.createNode();
                    tx.Success();
                }
            }
            catch (TransactionFailureException e)
            {
                exceptionThrown = e;
            }
            finally
            {
                assertNotNull("Expected tx finish to throw TransactionFailureException when filesystem is full.", exceptionThrown);
                assertTrue(Exceptions.contains(exceptionThrown, typeof(IOException)));
            }

            Db.somehowGainMoreDiskSpace();               // to help shutting down the db
            Db.shutdown();

            PageCache pageCache = PageCacheRule.getPageCache(Db.FileSystem);
            File      neoStore  = TestDirectory.databaseLayout().metadataStore();

            assertEquals(logVersion, MetaDataStore.getRecord(pageCache, neoStore, MetaDataStore.Position.LOG_VERSION));
        }
コード例 #13
0
ファイル: RebuildCountsTest.cs プロジェクト: Neo4Net/Neo4Net
        private void DeleteCounts(FileSystemAbstraction snapshot)
        {
            DatabaseLayout databaseLayout = TestDirectory.databaseLayout();
            File           alpha          = databaseLayout.CountStoreA();
            File           beta           = databaseLayout.CountStoreB();

            assertTrue(snapshot.DeleteFile(alpha));
            assertTrue(snapshot.DeleteFile(beta));
        }
コード例 #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
            _backupLayout          = TestDirectory.databaseLayout("backups");
            _backupDir             = _backupLayout.databaseDirectory().toPath();
            _fs                    = new DefaultFileSystemAbstraction();
            _jobScheduler          = new ThreadPoolJobScheduler();
            _pageCache             = StandalonePageCacheFactory.createPageCache(_fs, _jobScheduler);
            _backupProtocolService = _backupProtocolService();
            _backupTool            = new BackupTool(_backupProtocolService, mock(typeof(PrintStream)));
        }
コード例 #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void fileWatcherFileNameFilter()
        internal virtual void FileWatcherFileNameFilter()
        {
            DatabaseLayout layout = _testDirectory.databaseLayout();

            System.Predicate <string> filter = CommunityEditionModule.CommunityFileWatcherFileNameFilter();
            assertFalse(filter(layout.MetadataStore().Name));
            assertFalse(filter(layout.NodeStore().Name));
            assertTrue(filter(TransactionLogFiles.DEFAULT_NAME + ".1"));
            assertTrue(filter(IndexConfigStore.INDEX_DB_FILE_NAME + ".any"));
        }
コード例 #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void fileWatcherFileNameFilter()
        public virtual void FileWatcherFileNameFilter()
        {
            DatabaseLayout layout = _testDirectory.databaseLayout();

            System.Predicate <string> filter = EnterpriseCoreEditionModule.FileWatcherFileNameFilter();
            assertFalse(filter(layout.MetadataStore().Name));
            assertFalse(filter(layout.NodeStore().Name));
            assertTrue(filter(TransactionLogFiles.DEFAULT_NAME + ".1"));
            assertTrue(filter(IndexConfigStore.INDEX_DB_FILE_NAME + ".any"));
            assertTrue(filter(layout.MetadataStore().Name + PageCacheWarmer.SUFFIX_CACHEPROF));
        }
コード例 #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLetPageCacheHandleRecordStoresAndNativeLabelScanStoreFiles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLetPageCacheHandleRecordStoresAndNativeLabelScanStoreFiles()
        {
            // GIVEN
            Monitors             monitors       = new Monitors();
            StreamToDiskProvider writerProvider = new StreamToDiskProvider(_directory.databaseDir(), _fs, monitors);

            // WHEN
            foreach (StoreType type in StoreType.values())
            {
                if (type.RecordStore)
                {
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                    File[] files = _directory.databaseLayout().file(type.DatabaseFile).toArray(File[] ::new);
                    foreach (File file in files)
                    {
                        WriteAndVerify(writerProvider, file);
                    }
                }
            }
            WriteAndVerify(writerProvider, _directory.databaseLayout().labelScanStore());
        }
コード例 #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCreatesStoreLockFile() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestCreatesStoreLockFile()
        {
            // Given
            DatabaseLayout databaseLayout = _testDirectory.databaseLayout();

            // When
            BatchInserter inserter = BatchInserters.inserter(databaseLayout.DatabaseDirectory(), _fileSystemRule.get());

            // Then
            assertThat(databaseLayout.StoreLayout.storeLockFile().exists(), equalTo(true));
            inserter.Shutdown();
        }
コード例 #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLetPageCacheHandleRecordStoresAndNativeLabelScanStoreFiles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLetPageCacheHandleRecordStoresAndNativeLabelScanStoreFiles()
        {
            // GIVEN
            ToFileStoreWriter writer     = new ToFileStoreWriter(_directory.databaseDir(), _fs, new StoreCopyClientMonitor_Adapter());
            ByteBuffer        tempBuffer = ByteBuffer.allocate(128);

            // WHEN
            foreach (StoreType type in StoreType.values())
            {
                if (type.RecordStore)
                {
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                    File[] files = _directory.databaseLayout().file(type.DatabaseFile).toArray(File[] ::new);
                    foreach (File file in files)
                    {
                        WriteAndVerify(writer, tempBuffer, file);
                    }
                }
            }
            WriteAndVerify(writer, tempBuffer, _directory.databaseLayout().labelScanStore());
        }
コード例 #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void migrateHighLimit3_0StoreFiles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MigrateHighLimit3_0StoreFiles()
        {
            FileSystemAbstraction fileSystem = _fileSystemRule.get();
            PageCache             pageCache  = _pageCacheRule.getPageCache(fileSystem);

            using (JobScheduler jobScheduler = new ThreadPoolJobScheduler())
            {
                StoreMigrator migrator = new StoreMigrator(fileSystem, pageCache, Config.defaults(), NullLogService.Instance, jobScheduler);

                DatabaseLayout databaseLayout  = _testDirectory.databaseLayout();
                DatabaseLayout migrationLayout = _testDirectory.databaseLayout("migration");

                PrepareNeoStoreFile(fileSystem, databaseLayout, HighLimitV3_0_0.STORE_VERSION, pageCache);

                ProgressReporter progressMonitor = mock(typeof(ProgressReporter));

                migrator.Migrate(databaseLayout, migrationLayout, progressMonitor, HighLimitV3_0_0.STORE_VERSION, HighLimit.StoreVersion);

                int newStoreFilesCount = fileSystem.ListFiles(migrationLayout.DatabaseDirectory()).Length;
                assertThat("Store should be migrated and new store files should be created.", newStoreFilesCount, Matchers.greaterThanOrEqualTo(StoreType.values().length));
            }
        }
コード例 #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void buildActiveFilesOnlyContext() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BuildActiveFilesOnlyContext()
        {
            PageCache pageCache = PageCacheRule.getPageCache(_fileSystem);
            TransactionLogFilesContext context = activeFilesBuilder(TestDirectory.databaseLayout(), _fileSystem, pageCache).buildContext();

            assertEquals(_fileSystem, context.FileSystem);
            assertNotNull(context.LogEntryReader);
            assertSame(LogFileCreationMonitor_Fields.NoMonitor, context.LogFileCreationMonitor);
            assertEquals(long.MaxValue, context.RotationThreshold.get());
            assertEquals(0, context.LastCommittedTransactionId);
            assertEquals(0, context.LogVersionRepository.CurrentLogVersion);
        }
コード例 #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void canRunOnBackup() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void CanRunOnBackup()
        {
            ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService));

            DatabaseLayout          backupLayout            = _testDir.databaseLayout("backup");
            Path                    homeDir                 = _testDir.directory("home").toPath();
            CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService);

            when(consistencyCheckService.runFullConsistencyCheck(eq(backupLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(false), any(), any(typeof(ConsistencyFlags)))).thenReturn(ConsistencyCheckService.Result.success(null));

            checkConsistencyCommand.Execute(new string[] { "--backup=" + backupLayout.DatabaseDirectory() });

            verify(consistencyCheckService).runFullConsistencyCheck(eq(backupLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(false), any(), any(typeof(ConsistencyFlags)));
        }
コード例 #23
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void checkStartLogLine(int hoursShift, String timeZoneSuffix) throws java.io.IOException
        private void CheckStartLogLine(int hoursShift, string timeZoneSuffix)
        {
            TimeZone.Default = TimeZone.getTimeZone(ZoneOffset.ofHours(hoursShift));
            File storeDir                 = TestDirectory.storeDir(hoursShift.ToString());
            File databaseDirectory        = TestDirectory.databaseLayout(storeDir).databaseDirectory();
            GraphDatabaseService database = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(databaseDirectory).setConfig(GraphDatabaseSettings.db_timezone, LogTimeZone.SYSTEM.name()).newGraphDatabase();

            database.Shutdown();
            Path   databasePath = storeDir.toPath();
            Path   debugLog     = Paths.get("logs", "debug.log");
            string debugLogLine = GetLogLine(databasePath, debugLog);

            assertTrue(debugLogLine, debugLogLine.Contains(timeZoneSuffix));
        }
コード例 #24
0
ファイル: CountsMigratorTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAccidentallyDeleteStoreFilesIfNoMigrationWasRequired() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotAccidentallyDeleteStoreFilesIfNoMigrationWasRequired()
        {
            // given
            CountsMigrator migrator         = new CountsMigrator(_fs, null, Config.defaults());
            DatabaseLayout sourceLayout     = _directory.databaseLayout();
            File           countsStoreFileA = sourceLayout.CountStoreA();
            File           countsStoreFileB = sourceLayout.CountStoreB();

            _fs.create(countsStoreFileA);
            _fs.create(countsStoreFileB);
            DatabaseLayout migrationLayout      = _directory.databaseLayout("migration");
            string         versionToMigrateFrom = StoreVersion.STANDARD_V3_2.versionString();
            string         versionToMigrateTo   = StoreVersion.STANDARD_V3_4.versionString();

            migrator.Migrate(sourceLayout, migrationLayout, SilentProgressReporter.INSTANCE, versionToMigrateFrom, versionToMigrateTo);
            assertEquals("Invalid test assumption: There should not have been migration for those versions", 0, migrationLayout.ListDatabaseFiles((dir, name) => true).Length);

            // when
            migrator.MoveMigratedFiles(migrationLayout, sourceLayout, versionToMigrateFrom, versionToMigrateTo);

            // then
            assertTrue(_fs.fileExists(countsStoreFileA));
            assertTrue(_fs.fileExists(countsStoreFileB));
        }
コード例 #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void fileWatcherFileNameFilter()
        internal virtual void FileWatcherFileNameFilter()
        {
            DatabaseLayout databaseLayout = _testDirectory.databaseLayout();

            System.Predicate <string> filter = EnterpriseReadReplicaEditionModule.FileWatcherFileNameFilter();
            string metadataStoreName         = databaseLayout.MetadataStore().Name;

            assertFalse(filter(metadataStoreName));
            assertFalse(filter(databaseLayout.NodeStore().Name));
            assertTrue(filter(TransactionLogFiles.DEFAULT_NAME + ".1"));
            assertTrue(filter(IndexConfigStore.INDEX_DB_FILE_NAME + ".any"));
            assertTrue(filter(StoreUtil.BRANCH_SUBDIRECTORY));
            assertTrue(filter(StoreUtil.TEMP_COPY_DIRECTORY_NAME));
            assertTrue(filter(metadataStoreName + PageCacheWarmer.SUFFIX_CACHEPROF));
        }
コード例 #26
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void setupIndexInfrastructure() throws Exception
        private void SetupIndexInfrastructure()
        {
            DatabaseLayout databaseLayout = _testDirectory.databaseLayout();

            _indexStore = new IndexConfigStore(databaseLayout, _fileSystemRule.get());
            _indexStore.set(typeof(Node), INDEX_NAME, MapUtil.stringMap(Org.Neo4j.Graphdb.index.IndexManager_Fields.PROVIDER, "lucene", "type", "fulltext"));
            LuceneDataSource luceneDataSource = new LuceneDataSource(databaseLayout, Config.defaults(), _indexStore, _fileSystemRule.get(), OperationalMode.single);

            try
            {
                luceneDataSource.Init();
                luceneDataSource.GetIndexSearcher(_indexIdentifier);
            }
            finally
            {
                luceneDataSource.Shutdown();
            }
        }
コード例 #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGrowAFileWhileContinuingToMemoryMapNewRegions()
        public virtual void ShouldGrowAFileWhileContinuingToMemoryMapNewRegions()
        {
            // don't run on windows because memory mapping doesn't work properly there
            assumeTrue(!SystemUtils.IS_OS_WINDOWS);

            // given
            const int numberOfRecords = 1000000;

            Config config = Config.defaults(pagecache_memory, MmapSize(numberOfRecords, NodeRecordFormat.RECORD_SIZE));
            FileSystemAbstraction     fileSystemAbstraction = _fileSystemRule.get();
            DefaultIdGeneratorFactory idGeneratorFactory    = new DefaultIdGeneratorFactory(fileSystemAbstraction);
            PageCache    pageCache    = _pageCacheRule.getPageCache(fileSystemAbstraction, config);
            StoreFactory storeFactory = new StoreFactory(_testDirectory.databaseLayout(), config, idGeneratorFactory, pageCache, fileSystemAbstraction, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            NeoStores neoStores = storeFactory.OpenAllNeoStores(true);
            NodeStore nodeStore = neoStores.NodeStore;

            // when
            int  iterations = 2 * numberOfRecords;
            long startingId = nodeStore.NextId();
            long nodeId     = startingId;

            for (int i = 0; i < iterations; i++)
            {
                NodeRecord record = new NodeRecord(nodeId, false, i, 0);
                record.InUse = true;
                nodeStore.UpdateRecord(record);
                nodeId = nodeStore.NextId();
            }

            // then
            NodeRecord record = new NodeRecord(0, false, 0, 0);

            for (int i = 0; i < iterations; i++)
            {
                record.Id = startingId + i;
                nodeStore.GetRecord(i, record, NORMAL);
                assertTrue("record[" + i + "] should be in use", record.InUse());
                assertThat("record[" + i + "] should have nextRelId of " + i, record.NextRel, @is(( long )i));
            }

            neoStores.Close();
        }
コード例 #28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCompletelyRebuildIdGeneratorsAfterCrash()
        public virtual void ShouldCompletelyRebuildIdGeneratorsAfterCrash()
        {
            // GIVEN
            DatabaseLayout databaseLayout = _directory.databaseLayout();
            StoreFactory   storeFactory   = new StoreFactory(databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory(_fileSystemRule.get()), _pageCacheRule.getPageCache(_fileSystemRule.get()), _fileSystemRule.get(), NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);
            long           highId;

            using (NeoStores stores = storeFactory.OpenAllNeoStores(true))
            {
                // a node store with a "high" node
                NodeStore nodeStore = stores.NodeStore;
                nodeStore.HighId = 20;
                nodeStore.UpdateRecord(Node(nodeStore.NextId()));
                highId = nodeStore.HighId;
            }

            // populating its .id file with a bunch of ids
            File nodeIdFile = databaseLayout.IdNodeStore();

            using (IdGeneratorImpl idGenerator = new IdGeneratorImpl(_fileSystemRule.get(), nodeIdFile, 10, 10_000, false, IdType.NODE, () => highId))
            {
                for (long id = 0; id < 15; id++)
                {
                    idGenerator.FreeId(id);
                }

                // WHEN
                using (NeoStores stores = storeFactory.OpenAllNeoStores(true))
                {
                    NodeStore nodeStore = stores.NodeStore;
                    assertFalse(nodeStore.StoreOk);

                    // simulating what recovery does
                    nodeStore.DeleteIdGenerator();
                    // recovery happens here...
                    nodeStore.MakeStoreOk();

                    // THEN
                    assertEquals(highId, nodeStore.NextId());
                }
            }
        }
コード例 #29
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
            DataSourceManager  dataSourceManager = new DataSourceManager(Config.defaults());
            NeoStoreDataSource dataSource        = mock(typeof(NeoStoreDataSource));

            when(dataSource.DatabaseLayout).thenReturn(TestDirectory.databaseLayout());
            dataSourceManager.Register(dataSource);
            KernelData kernelData = new KernelData(_fs, mock(typeof(PageCache)), new File("storeDir"), Config.defaults(), dataSourceManager);

            Dependencies dependencies = new Dependencies();

            dependencies.SatisfyDependency(_clusterStateDirectory);
            dependencies.SatisfyDependency(_raftMachine);
            dependencies.SatisfyDependency(DatabaseInfo.CORE);

            when(dataSource.DependencyResolver).thenReturn(dependencies);
            ManagementData data = new ManagementData(new CausalClusteringBean(), kernelData, ManagementSupport.load());

            _ccBean = ( CausalClustering )(new CausalClusteringBean()).CreateMBean(data);
        }
コード例 #30
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void appendCheckpoint(org.neo4j.kernel.impl.transaction.log.entry.LogEntryVersion logVersion) throws java.io.IOException
        private void AppendCheckpoint(LogEntryVersion logVersion)
        {
            PageCache pageCache = _pageCacheRule.getPageCache(_fs);
            VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            LogFiles       logFiles    = LogFilesBuilder.activeFilesBuilder(_storeDirectory.databaseLayout(), _fs, pageCache).withLogEntryReader(logEntryReader).build();
            LogTailScanner tailScanner = new LogTailScanner(logFiles, logEntryReader, new Monitors());

            LogTailScanner.LogTailInformation tailInformation = tailScanner.TailInformation;

            using (Lifespan lifespan = new Lifespan(logFiles))
            {
                FlushablePositionAwareChannel channel = logFiles.LogFile.Writer;

                LogPosition logPosition = tailInformation.LastCheckPoint.LogPosition;

                // Fake record
                channel.Put(logVersion.byteCode()).put(CHECK_POINT).putLong(logPosition.LogVersion).putLong(logPosition.ByteOffset);

                channel.PrepareForFlush().flush();
            }
        }