//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailOnUnsortedLabelsFromFullStoreChangeStream() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailOnUnsortedLabelsFromFullStoreChangeStream()
        {
            // given
            PageCache pageCache = _pageCacheRule.getPageCache(_fileSystemRule.get());
            IList <NodeLabelUpdate> existingData = new List <NodeLabelUpdate>();

            existingData.Add(NodeLabelUpdate.labelChanges(1, new long[0], new long[] { 2, 1 }));
            FullStoreChangeStream changeStream         = asStream(existingData);
            NativeLabelScanStore  nativeLabelScanStore = null;

            try
            {
                nativeLabelScanStore = new NativeLabelScanStore(pageCache, _testDirectory.databaseLayout(), _fileSystemRule.get(), changeStream, false, new Monitors(), immediate());
                nativeLabelScanStore.Init();

                // when
                nativeLabelScanStore.Start();
                fail("Expected native label scan store to fail on ");
            }
            catch (System.ArgumentException e)
            {
                // then
                assertThat(e.Message, Matchers.containsString("unsorted label"));
                assertThat(e.Message, Matchers.stringContainsInOrder(Iterables.asIterable("2", "1")));
            }
            finally
            {
                if (nativeLabelScanStore != null)
                {
                    nativeLabelScanStore.Shutdown();
                }
            }
        }
Exemplo n.º 2
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();
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void createDirtyIndex(org.neo4j.io.pagecache.PageCache pageCache) throws java.io.IOException
        private void CreateDirtyIndex(PageCache pageCache)
        {
            NativeLabelScanStore nativeLabelScanStore = null;

            try
            {
                nativeLabelScanStore = new NativeLabelScanStore(pageCache, _testDirectory.databaseLayout(), _fileSystemRule.get(), _throwingStream, false, new Monitors(), immediate());

                nativeLabelScanStore.Init();
                nativeLabelScanStore.Start();
            }
            catch (System.ArgumentException)
            {
                if (nativeLabelScanStore != null)
                {
                    nativeLabelScanStore.Shutdown();
                }
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void labelScanStoreIsDirtyWhenIndexIsNotClean() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void LabelScanStoreIsDirtyWhenIndexIsNotClean()
        {
            PageCache pageCache = _pageCacheRule.getPageCache(_fileSystemRule.get());

            CreateDirtyIndex(pageCache);

            Monitors         monitors = new Monitors();
            RecordingMonitor monitor  = new RecordingMonitor();

            monitors.AddMonitorListener(monitor);

            NativeLabelScanStore nativeLabelScanStore = new NativeLabelScanStore(pageCache, _testDirectory.databaseLayout(), _fileSystemRule.get(), EMPTY, true, monitors, ignore());

            nativeLabelScanStore.Init();
            nativeLabelScanStore.Start();

            assertTrue(nativeLabelScanStore.Dirty);
            nativeLabelScanStore.Shutdown();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void doNotRebuildIfOpenedInReadOnlyModeAndIndexIsNotClean() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DoNotRebuildIfOpenedInReadOnlyModeAndIndexIsNotClean()
        {
            PageCache pageCache = _pageCacheRule.getPageCache(_fileSystemRule.get());

            CreateDirtyIndex(pageCache);

            Monitors         monitors = new Monitors();
            RecordingMonitor monitor  = new RecordingMonitor();

            monitors.AddMonitorListener(monitor);

            NativeLabelScanStore nativeLabelScanStore = new NativeLabelScanStore(pageCache, _testDirectory.databaseLayout(), _fileSystemRule.get(), EMPTY, true, monitors, ignore());

            nativeLabelScanStore.Init();
            nativeLabelScanStore.Start();

            assertTrue(monitor.NotValid);
            assertFalse(monitor.RebuiltConflict);
            assertFalse(monitor.RebuildingConflict);
            nativeLabelScanStore.Shutdown();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustBeDirtyIfFailedDuringRebuild() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustBeDirtyIfFailedDuringRebuild()
        {
            // given
            PageCache pageCache = _pageCacheRule.getPageCache(_fileSystemRule.get());

            CreateDirtyIndex(pageCache);

            // when
            RecordingMonitor monitor  = new RecordingMonitor();
            Monitors         monitors = new Monitors();

            monitors.AddMonitorListener(monitor);

            NativeLabelScanStore nativeLabelScanStore = new NativeLabelScanStore(pageCache, _testDirectory.databaseLayout(), _fileSystemRule.get(), EMPTY, false, monitors, immediate());

            nativeLabelScanStore.Init();
            nativeLabelScanStore.Start();

            // then
            assertTrue(monitor.NotValid);
            assertTrue(monitor.RebuildingConflict);
            assertTrue(monitor.RebuiltConflict);
            nativeLabelScanStore.Shutdown();
        }
Exemplo n.º 7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void shouldStartFromGivenId(int sparsity) throws java.io.IOException
        private void ShouldStartFromGivenId(int sparsity)
        {
            // given
            NativeLabelScanStore store = Life.add(new NativeLabelScanStore(Storage.pageCache(), DatabaseLayout.of(Storage.directory().directory()), Storage.fileSystem(), EMPTY, false, new Monitors(), immediate()));
            int      labelId           = 1;
            int      highNodeId        = 100_000;
            BitArray expected          = new BitArray(highNodeId);

            using (LabelScanWriter writer = store.NewWriter())
            {
                int updates = highNodeId / sparsity;
                for (int i = 0; i < updates; i++)
                {
                    int nodeId = Random.Next(highNodeId);
                    writer.Write(labelChanges(nodeId, EMPTY_LONG_ARRAY, new long[] { labelId }));
                    expected.Set(nodeId, true);
                }
            }

            // when
            long fromId         = Random.Next(highNodeId);
            int  nextExpectedId = expected.nextSetBit(toIntExact(fromId + 1));

            using (LabelScanReader reader = store.NewReader(), PrimitiveLongResourceIterator ids = reader.NodesWithAnyOfLabels(fromId, new int[] { labelId }))
            {
                // then
                while (nextExpectedId != -1)
                {
                    assertTrue(ids.hasNext());
                    long nextId = ids.next();
                    assertEquals(nextExpectedId, toIntExact(nextId));
                    nextExpectedId = expected.nextSetBit(nextExpectedId + 1);
                }
                assertFalse(ids.hasNext());
            }
        }
Exemplo n.º 8
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()
        {
            PageCache pageCache = _pageCacheRule.getPageCache(_fileSystem);

            _store = _life.add(new NativeLabelScanStore(pageCache, _directory.databaseLayout(), _fileSystem, Org.Neo4j.Kernel.Impl.Api.scan.FullStoreChangeStream_Fields.Empty, false, new Monitors(), RecoveryCleanupWorkCollector.immediate(), Math.Min(pageCache.PageSize(), 256 << _random.Next(5))));
        }
Exemplo n.º 9
0
 public LabelIndexTreeMonitor(NativeLabelScanStore outerInstance) : base(outerInstance)
 {
     this._outerInstance = outerInstance;
 }