예제 #1
0
        private void ConsecutiveAllocationFromSeparateIdGeneratorsForSameIdTypeShouldNotDuplicateForGivenInitialHighId(long initialHighId)
        {
            ISet <long> idAllocations = new HashSet <long>();
            int         idRangeLength = 8;

            FileSystemAbstraction fs = DefaultFileSystemRule.get();
            File generatorFile1      = TestDirectory.file("gen1");
            File generatorFile2      = TestDirectory.file("gen2");

            using (ReplicatedIdGenerator generatorOne = CreateForMemberWithInitialIdAndRangeLength(_memberA, initialHighId, idRangeLength, fs, generatorFile1), ReplicatedIdGenerator generatorTwo = CreateForMemberWithInitialIdAndRangeLength(_memberB, initialHighId, idRangeLength, fs, generatorFile2), )
            {
                // First iteration is bootstrapping the set, so we do it outside the loop to avoid an if check in there
                long newId = generatorOne.NextId();
                idAllocations.Add(newId);

                for (int i = 1; i < idRangeLength - initialHighId; i++)
                {
                    newId = generatorOne.NextId();
                    bool wasNew = idAllocations.Add(newId);
                    assertTrue("Id " + newId + " has already been returned", wasNew);
                    assertTrue("Detected gap in id generation, missing " + (newId - 1), idAllocations.Contains(newId - 1));
                }

                for (int i = 0; i < idRangeLength; i++)
                {
                    newId = generatorTwo.NextId();
                    bool wasNew = idAllocations.Add(newId);
                    assertTrue("Id " + newId + " has already been returned", wasNew);
                    assertTrue("Detected gap in id generation, missing " + (newId - 1), idAllocations.Contains(newId - 1));
                }
            }
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldStartPopulationAgainIfNotCompletedFirstTime()
        public virtual void ShouldStartPopulationAgainIfNotCompletedFirstTime()
        {
            // given
            // label scan store init but no start
            LifeSupport     life    = new LifeSupport();
            TrackingMonitor monitor = new TrackingMonitor();

            life.Add(CreateLabelScanStore(FileSystemRule.get(), TestDirectory.databaseLayout(), EMPTY, true, false, monitor));
            life.Init();
            assertTrue(monitor.NoIndexCalled);
            monitor.Reset();
            life.Shutdown();

            // when
            // starting label scan store again
            life = new LifeSupport();
            life.Add(CreateLabelScanStore(FileSystemRule.get(), TestDirectory.databaseLayout(), EMPTY, true, false, monitor));
            life.Init();

            // then
            // label scan store should recognize it still needs to be rebuilt
            assertTrue(monitor.CorruptedIndex);
            life.Start();
            assertTrue(monitor.RebuildingCalled);
            assertTrue(monitor.RebuiltCalled);
            life.Shutdown();
        }
예제 #3
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()
        {
            _file = TestDirectory.file("idgen");
            _fs   = FileSystemRule.get();
            when(_raftMachine.state()).thenReturn(_state);
            _idReusabilityCondition = IdReusabilityCondition;
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void failToLockSameFolderAcrossIndependentLockers() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void FailToLockSameFolderAcrossIndependentLockers()
        {
            StoreLayout storeLayout = TestDirectory.storeLayout();

            using (GlobalStoreLocker storeLocker = new GlobalStoreLocker(FileSystemRule.get(), storeLayout))
            {
                storeLocker.CheckLock();

                try
                {
                    using (GlobalStoreLocker locker = new GlobalStoreLocker(FileSystemRule.get(), storeLayout))
                    {
                        locker.CheckLock();
                        fail("directory should be locked");
                    }
                }
                catch (StoreLockException)
                {
                    // expected
                }

                try
                {
                    using (GlobalStoreLocker locker = new GlobalStoreLocker(FileSystemRule.get(), storeLayout))
                    {
                        locker.CheckLock();
                        fail("directory should be locked");
                    }
                }
                catch (StoreLockException)
                {
                    // expected
                }
            }
        }
예제 #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void verifyTransactionLogs(java.io.File txDirectory, java.io.File storeDir) throws java.io.IOException
        private void VerifyTransactionLogs(File txDirectory, File storeDir)
        {
            FileSystemAbstraction fileSystem = FileSystemRule.get();
            LogFiles storeDirLogs            = LogFilesBuilder.logFilesBasedOnlyBuilder(storeDir, fileSystem).build();

            assertFalse(storeDirLogs.VersionExists(0));

            LogFiles txDirectoryLogs = LogFilesBuilder.logFilesBasedOnlyBuilder(txDirectory, fileSystem).build();

            assertTrue(txDirectoryLogs.VersionExists(0));
            using (PhysicalLogVersionedStoreChannel physicalLogVersionedStoreChannel = txDirectoryLogs.OpenForVersion(0))
            {
                assertThat(physicalLogVersionedStoreChannel.Size(), greaterThan(0L));
            }
        }
예제 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRestartPopulationIfIndexFileWasNeverFullyInitialized() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRestartPopulationIfIndexFileWasNeverFullyInitialized()
        {
            // given
            File labelScanStoreFile = NativeLabelScanStore.GetLabelScanStoreFile(TestDirectory.databaseLayout());

            FileSystemRule.create(labelScanStoreFile).close();
            TrackingMonitor monitor = new TrackingMonitor();
            LifeSupport     life    = new LifeSupport();

            // when
            life.Add(CreateLabelScanStore(FileSystemRule.get(), TestDirectory.databaseLayout(), EMPTY, true, false, monitor));
            life.Start();

            // then
            assertTrue(monitor.CorruptedIndex);
            assertTrue(monitor.RebuildingCalled);
            life.Shutdown();
        }
예제 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shutdownNonInitialisedNativeScanStoreWithoutException() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShutdownNonInitialisedNativeScanStoreWithoutException()
        {
            string   expectedMessage = "Expected exception message";
            Monitors monitors        = mock(typeof(Monitors));

            when(monitors.NewMonitor(typeof(Org.Neo4j.Kernel.api.labelscan.LabelScanStore_Monitor))).thenReturn(Org.Neo4j.Kernel.api.labelscan.LabelScanStore_Monitor_Fields.Empty);
            doThrow(new Exception(expectedMessage)).when(monitors).addMonitorListener(any());

            LabelScanStore scanStore = GetLabelScanStore(FileSystemRule.get(), TestDirectory.databaseLayout(), EMPTY, true, monitors);

            try
            {
                scanStore.Init();
                fail("Initialisation of store should fail.");
            }
            catch (Exception e)
            {
                assertEquals(expectedMessage, e.Message);
            }

            scanStore.Shutdown();
        }
예제 #8
0
            public override Lifecycle NewInstance(KernelContext context, SchemaIndexHaIT.IndexProviderDependencies deps)
            {
                PageCache pageCache             = deps.PageCache();
                File      databaseDirectory     = context.Directory();
                DefaultFileSystemAbstraction fs = FileSystemRule.get();

                IndexProvider.Monitor monitor   = IndexProvider.Monitor_Fields.EMPTY;
                Config          config          = deps.Config();
                OperationalMode operationalMode = context.DatabaseInfo().OperationalMode;
                RecoveryCleanupWorkCollector recoveryCleanupWorkCollector = deps.RecoveryCleanupWorkCollector();

                FusionIndexProvider fusionIndexProvider = NativeLuceneFusionIndexProviderFactory20.create(pageCache, databaseDirectory, fs, monitor, config, operationalMode, recoveryCleanupWorkCollector);

                if (InjectLatchPredicate.test(deps.Db()))
                {
                    ControlledIndexProvider provider = new ControlledIndexProvider(fusionIndexProvider);
                    PerDbIndexProvider[deps.Db()] = provider;
                    return(provider);
                }
                else
                {
                    return(fusionIndexProvider);
                }
            }
예제 #9
0
 private void InitializeInstanceFields()
 {
     TestDirectory = TestDirectory.testDirectory(FileSystemRule);
     _fsa          = FileSystemRule.get();
 }
예제 #10
0
 protected internal override GraphDatabaseService CreateGraphDatabase()
 {
     return((new TestEnterpriseGraphDatabaseFactory()).setFileSystem(FileSystemRule.get()).newEmbeddedDatabaseBuilder(TestDir.storeDir()).newGraphDatabase());
 }
 public virtual FileSystemAbstraction FileSystem()
 {
     return(_fs.get());
 }
예제 #12
0
 private void InitializeInstanceFields()
 {
     _fsa        = FileSystemRule.get();
     _fileNames  = new FileNames(_root);
     _readerPool = new ReaderPool(0, Instance, _fileNames, _fsa, Clocks.fakeClock());
 }