//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCloseIndexAndLabelScanSnapshots() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCloseIndexAndLabelScanSnapshots()
        {
            // Given
            LabelScanStore        labelScanStore  = mock(typeof(LabelScanStore));
            IndexingService       indexingService = mock(typeof(IndexingService));
            ExplicitIndexProvider explicitIndexes = mock(typeof(ExplicitIndexProvider));

            when(explicitIndexes.AllIndexProviders()).thenReturn(Collections.emptyList());
            DatabaseLayout databaseLayout = mock(typeof(DatabaseLayout));

            when(databaseLayout.MetadataStore()).thenReturn(mock(typeof(File)));
            LogFiles logFiles = mock(typeof(LogFiles));

            FilesInStoreDirAre(databaseLayout, _standardStoreDirFiles, _standardStoreDirDirectories);
            StorageEngine       storageEngine = mock(typeof(StorageEngine));
            NeoStoreFileListing fileListing   = new NeoStoreFileListing(databaseLayout, logFiles, labelScanStore, indexingService, explicitIndexes, storageEngine);

            ResourceIterator <File> scanSnapshot  = ScanStoreFilesAre(labelScanStore, new string[] { "blah/scan.store", "scan.more" });
            ResourceIterator <File> indexSnapshot = IndexFilesAre(indexingService, new string[] { "schema/index/my.index" });

            ResourceIterator <StoreFileMetadata> result = fileListing.Builder().excludeLogFiles().build();

            // When
            result.Close();

            // Then
            verify(scanSnapshot).close();
            verify(indexSnapshot).close();
        }
 private long[] ReadNodesForLabel(LabelScanStore labelScanStore)
 {
     using (LabelScanReader reader = labelScanStore.NewReader())
     {
         return(PrimitiveLongCollections.asArray(reader.NodesWithLabel(_labelId)));
     }
 }
Beispiel #3
0
 public NeoStoreFileListing(DatabaseLayout databaseLayout, LogFiles logFiles, LabelScanStore labelScanStore, IndexingService indexingService, ExplicitIndexProvider explicitIndexProviders, StorageEngine storageEngine)
 {
     this._databaseLayout           = databaseLayout;
     this._logFiles                 = logFiles;
     this._storageEngine            = storageEngine;
     this._neoStoreFileIndexListing = new NeoStoreFileIndexListing(labelScanStore, indexingService, explicitIndexProviders);
     this._additionalProviders      = new CopyOnWriteArraySet <StoreFileProvider>();
 }
Beispiel #4
0
 public DynamicIndexStoreView(NeoStoreIndexStoreView neoStoreIndexStoreView, LabelScanStore labelScanStore, LockService locks, NeoStores neoStores, LogProvider logProvider)
 {
     this._neoStores = neoStores;
     this._neoStoreIndexStoreView = neoStoreIndexStoreView;
     this.Locks           = locks;
     this._labelScanStore = labelScanStore;
     this._log            = logProvider.getLog(this.GetType());
 }
Beispiel #5
0
        private static void ConsistencyCheckLabelScanStore(LabelScanStore labelScanStore, ConsistencyReporter report, ProgressListener listener)
        {
            ConsistencyReporter.FormattingDocumentedHandler handler = report.FormattingHandler(RecordType.LABEL_SCAN_DOCUMENT);
            ReporterFactory proxyFactory = new ReporterFactory(handler);

            labelScanStore.ConsistencyCheck(proxyFactory);
            handler.UpdateSummary();
            listener.Add(1);
        }
        private static ResourceIterator <File> ScanStoreFilesAre(LabelScanStore labelScanStore, string[] fileNames)
        {
            List <File> files = new List <File>();

            MockFiles(fileNames, files, false);
            ResourceIterator <File> snapshot = spy(asResourceIterator(Files.GetEnumerator()));

            when(labelScanStore.SnapshotStoreFiles()).thenReturn(snapshot);
            return(snapshot);
        }
Beispiel #7
0
        private void Start(IList <NodeLabelUpdate> existingData, bool usePersistentStore, bool readOnly)
        {
            _life    = new LifeSupport();
            _monitor = new TrackingMonitor();

            _store = CreateLabelScanStore(FileSystemRule.get(), TestDirectory.databaseLayout(), asStream(existingData), usePersistentStore, readOnly, _monitor);
            _life.add(_store);

            _life.start();
            assertTrue(_monitor.initCalled);
        }
Beispiel #8
0
        private static void GatherLabelScanStoreFiles(GraphDatabaseAPI db, ISet <Path> labelScanStoreFiles)
        {
            Path           databaseDirectory = Db.databaseLayout().databaseDirectory().toPath();
            LabelScanStore labelScanStore    = Db.DependencyResolver.resolveDependency(typeof(LabelScanStore));

            using (ResourceIterator <File> files = labelScanStore.SnapshotStoreFiles())
            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                Path relativePath = databaseDirectory.relativize(Files.next().toPath().toAbsolutePath());
                labelScanStoreFiles.Add(relativePath);
            }
        }
Beispiel #9
0
            internal StoreSizeProvider(FileSystemAbstraction fs, NeoStoreDataSource ds)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.DependencyResolver deps = ds.getDependencyResolver();
                DependencyResolver deps = ds.DependencyResolver;

                this.Fs       = requireNonNull(fs);
                this.LogFiles = deps.ResolveDependency(typeof(LogFiles));
                this.ExplicitIndexProviderLookup = deps.ResolveDependency(typeof(ExplicitIndexProvider));
                this.IndexProviderMap            = deps.ResolveDependency(typeof(IndexProviderMap));
                this.LabelScanStore = deps.ResolveDependency(typeof(LabelScanStore));
                this.DatabaseLayout = ds.DatabaseLayout;
            }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void checkLabelScanStoreAccessible(org.neo4j.kernel.api.labelscan.LabelScanStore labelScanStore) throws java.io.IOException
        private static void CheckLabelScanStoreAccessible(LabelScanStore labelScanStore)
        {
            int labelId = 1;

            using (LabelScanWriter labelScanWriter = labelScanStore.NewWriter())
            {
                labelScanWriter.Write(NodeLabelUpdate.labelChanges(1, new long[] {}, new long[] { labelId }));
            }
            using (LabelScanReader labelScanReader = labelScanStore.NewReader())
            {
                assertEquals(1, labelScanReader.NodesWithLabel(labelId).next());
            }
        }
Beispiel #11
0
 internal ConsistencyCheckTasks(ProgressMonitorFactory.MultiPartBuilder multiPartBuilder, StoreProcessor defaultProcessor, StoreAccess nativeStores, Statistics statistics, CacheAccess cacheAccess, LabelScanStore labelScanStore, IndexAccessors indexes, TokenHolders tokenHolders, MultiPassStore.Factory multiPass, ConsistencyReporter reporter, int numberOfThreads)
 {
     this._multiPartBuilder = multiPartBuilder;
     this._defaultProcessor = defaultProcessor;
     this._nativeStores     = nativeStores;
     this._statistics       = statistics;
     this._cacheAccess      = cacheAccess;
     this._tokenHolders     = tokenHolders;
     this._multiPass        = multiPass;
     this._reporter         = reporter;
     this._labelScanStore   = labelScanStore;
     this._indexes          = indexes;
     this._numberOfThreads  = numberOfThreads;
 }
Beispiel #12
0
        public RecordStorageEngine(DatabaseLayout databaseLayout, Config config, PageCache pageCache, FileSystemAbstraction fs, LogProvider logProvider, LogProvider userLogProvider, TokenHolders tokenHolders, SchemaState schemaState, ConstraintSemantics constraintSemantics, JobScheduler scheduler, TokenNameLookup tokenNameLookup, LockService lockService, IndexProviderMap indexProviderMap, IndexingService.Monitor indexingServiceMonitor, DatabaseHealth databaseHealth, ExplicitIndexProvider explicitIndexProvider, IndexConfigStore indexConfigStore, IdOrderingQueue explicitIndexTransactionOrdering, IdGeneratorFactory idGeneratorFactory, IdController idController, Monitors monitors, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, OperationalMode operationalMode, VersionContextSupplier versionContextSupplier)
        {
            this._tokenHolders   = tokenHolders;
            this._schemaState    = schemaState;
            this._lockService    = lockService;
            this._databaseHealth = databaseHealth;
            this._explicitIndexProviderLookup      = explicitIndexProvider;
            this._indexConfigStore                 = indexConfigStore;
            this._constraintSemantics              = constraintSemantics;
            this._explicitIndexTransactionOrdering = explicitIndexTransactionOrdering;

            this._idController = idController;
            StoreFactory factory = new StoreFactory(databaseLayout, config, idGeneratorFactory, pageCache, fs, logProvider, versionContextSupplier);

            _neoStores = factory.OpenAllNeoStores(true);

            try
            {
                _schemaCache   = new SchemaCache(constraintSemantics, Collections.emptyList(), indexProviderMap);
                _schemaStorage = new SchemaStorage(_neoStores.SchemaStore);

                NeoStoreIndexStoreView neoStoreIndexStoreView = new NeoStoreIndexStoreView(lockService, _neoStores);
                bool readOnly = config.Get(GraphDatabaseSettings.read_only) && operationalMode == OperationalMode.single;
                monitors.AddMonitorListener(new LoggingMonitor(logProvider.GetLog(typeof(NativeLabelScanStore))));
                _labelScanStore = new NativeLabelScanStore(pageCache, databaseLayout, fs, new FullLabelStream(neoStoreIndexStoreView), readOnly, monitors, recoveryCleanupWorkCollector);

                _indexStoreView        = new DynamicIndexStoreView(neoStoreIndexStoreView, _labelScanStore, lockService, _neoStores, logProvider);
                this._indexProviderMap = indexProviderMap;
                _indexingService       = IndexingServiceFactory.createIndexingService(config, scheduler, indexProviderMap, _indexStoreView, tokenNameLookup, Iterators.asList(_schemaStorage.loadAllSchemaRules()), logProvider, userLogProvider, indexingServiceMonitor, schemaState, readOnly);

                _integrityValidator = new IntegrityValidator(_neoStores, _indexingService);
                _cacheAccess        = new BridgingCacheAccess(_schemaCache, schemaState, tokenHolders);

                _explicitIndexApplierLookup = new Org.Neo4j.Kernel.Impl.Api.ExplicitIndexApplierLookup_Direct(explicitIndexProvider);

                _labelScanStoreSync = new WorkSync <Supplier <LabelScanWriter>, LabelUpdateWork>(_labelScanStore.newWriter);

                _commandReaderFactory = new RecordStorageCommandReaderFactory();
                _indexUpdatesSync     = new WorkSync <IndexingUpdateService, IndexUpdatesWork>(_indexingService);

                _denseNodeThreshold = config.Get(GraphDatabaseSettings.dense_node_threshold);
                _recordIdBatchSize  = config.Get(GraphDatabaseSettings.record_id_batch_size);
            }
            catch (Exception failure)
            {
                _neoStores.close();
                throw failure;
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void scanStoreStartWithoutExistentIndex() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ScanStoreStartWithoutExistentIndex()
        {
            LabelScanStore labelScanStore = LabelScanStore;
            GroupingRecoveryCleanupWorkCollector workCollector = GroupingRecoveryCleanupWorkCollector;

            labelScanStore.Shutdown();
            workCollector.Shutdown();

            DeleteLabelScanStoreFiles(DbRule.databaseLayout());

            workCollector.Init();
            labelScanStore.Init();
            workCollector.Start();
            labelScanStore.Start();

            CheckLabelScanStoreAccessible(labelScanStore);
        }
Beispiel #14
0
        private static void ConsistencyCheckIndexStructure(LabelScanStore labelScanStore, IndexAccessors indexes, ConsistencyReporter report, ProgressMonitorFactory progressMonitorFactory)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long schemaIndexCount = org.neo4j.helpers.collection.Iterables.count(indexes.onlineRules());
            long       schemaIndexCount = Iterables.count(indexes.OnlineRules());
            const long additionalCount  = 1;              // LabelScanStore
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long totalCount = schemaIndexCount + additionalCount;
            long totalCount = schemaIndexCount + additionalCount;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.helpers.progress.ProgressListener listener = progressMonitorFactory.singlePart("Index structure consistency check", totalCount);
            ProgressListener listener = progressMonitorFactory.SinglePart("Index structure consistency check", totalCount);

            listener.Started();

            ConsistencyCheckLabelScanStore(labelScanStore, report, listener);
            ConsistencyCheckSchemaIndexes(indexes, report, listener);

            listener.Done();
        }
Beispiel #15
0
        private DirectStoreAccess DirectStoreAccess(bool readOnly)
        {
            if (_directStoreAccess == null)
            {
                _life.start();
                JobScheduler scheduler = _life.add(JobSchedulerFactory.createInitialisedScheduler());
                _fileSystem = new DefaultFileSystemAbstraction();
                PageCache   pageCache   = GetPageCache(_fileSystem);
                LogProvider logProvider = NullLogProvider.Instance;
                Config      config      = Config.defaults(GraphDatabaseSettings.read_only, readOnly ? TRUE : FALSE);
                DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(_fileSystem);
                StoreFactory storeFactory = new StoreFactory(_directory.databaseLayout(), config, idGeneratorFactory, pageCache, _fileSystem, logProvider, EmptyVersionContextSupplier.EMPTY);
                _neoStore = storeFactory.OpenAllNeoStores();
                StoreAccess nativeStores;
                if (_keepStatistics)
                {
                    AccessStatistics accessStatistics = new AccessStatistics();
                    _statistics  = new VerboseStatistics(accessStatistics, new DefaultCounts(defaultConsistencyCheckThreadsNumber()), NullLog.Instance);
                    nativeStores = new AccessStatsKeepingStoreAccess(_neoStore, accessStatistics);
                }
                else
                {
                    _statistics  = Statistics.NONE;
                    nativeStores = new StoreAccess(_neoStore);
                }
                nativeStores.Initialize();

                IndexStoreView indexStoreView = new NeoStoreIndexStoreView(LockService.NO_LOCK_SERVICE, nativeStores.RawNeoStores);

                Monitors         monitors       = new Monitors();
                LabelScanStore   labelScanStore = StartLabelScanStore(pageCache, indexStoreView, monitors, readOnly);
                IndexProviderMap indexes        = CreateIndexes(pageCache, _fileSystem, _directory.databaseDir(), config, scheduler, logProvider, monitors);
                TokenHolders     tokenHolders   = new TokenHolders(new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_PROPERTY_KEY), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_LABEL), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_RELATIONSHIP_TYPE));
                tokenHolders.PropertyKeyTokens().InitialTokens      = _neoStore.PropertyKeyTokenStore.Tokens;
                tokenHolders.LabelTokens().InitialTokens            = _neoStore.LabelTokenStore.Tokens;
                tokenHolders.RelationshipTypeTokens().InitialTokens = _neoStore.RelationshipTypeTokenStore.Tokens;
                _directStoreAccess = new DirectStoreAccess(nativeStores, labelScanStore, indexes, tokenHolders);
            }
            return(_directStoreAccess);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void scanStoreRecreateCorruptedIndexOnStartup() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ScanStoreRecreateCorruptedIndexOnStartup()
        {
            LabelScanStore labelScanStore = LabelScanStore;
            GroupingRecoveryCleanupWorkCollector workCollector = GroupingRecoveryCleanupWorkCollector;

            CreateTestNode();
            long[] labels = ReadNodesForLabel(labelScanStore);
            assertEquals("Label scan store see 1 label for node", 1, labels.Length);
            labelScanStore.Force(Org.Neo4j.Io.pagecache.IOLimiter_Fields.Unlimited);
            labelScanStore.Shutdown();
            workCollector.Shutdown();

            CorruptLabelScanStoreFiles(DbRule.databaseLayout());

            workCollector.Init();
            labelScanStore.Init();
            workCollector.Start();
            labelScanStore.Start();

            long[] rebuildLabels = ReadNodesForLabel(labelScanStore);
            assertArrayEquals("Store should rebuild corrupted index", labels, rebuildLabels);
        }
Beispiel #17
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();
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void launchCustomIndexPopulation(java.util.Map<String,int> labelNameIdMap, int propertyId, Runnable customAction) throws Exception
        private void LaunchCustomIndexPopulation(IDictionary <string, int> labelNameIdMap, int propertyId, ThreadStart customAction)
        {
            NeoStores      neoStores      = NeoStores;
            LabelScanStore labelScanStore = LabelScanStore;
            ThreadToStatementContextBridge transactionStatementContextBridge = TransactionStatementContextBridge;

            using (Transaction transaction = EmbeddedDatabase.beginTx(), KernelTransaction ktx = transactionStatementContextBridge.GetKernelTransactionBoundToThisThread(true))
            {
                DynamicIndexStoreView storeView = DynamicIndexStoreViewWrapper(customAction, neoStores, labelScanStore);

                IndexProviderMap providerMap     = IndexProviderMap;
                JobScheduler     scheduler       = JobScheduler;
                TokenNameLookup  tokenNameLookup = new SilentTokenNameLookup(ktx.TokenRead());

                NullLogProvider nullLogProvider = NullLogProvider.Instance;
                _indexService = IndexingServiceFactory.createIndexingService(Config.defaults(), scheduler, providerMap, storeView, tokenNameLookup, GetIndexRules(neoStores), nullLogProvider, nullLogProvider, IndexingService.NO_MONITOR, SchemaState, false);
                _indexService.start();

                _rules = CreateIndexRules(labelNameIdMap, propertyId);

                _indexService.createIndexes(_rules);
                transaction.Success();
            }
        }
 internal NeoStoreFileIndexListing(LabelScanStore labelScanStore, IndexingService indexingService, ExplicitIndexProvider explicitIndexProviders)
 {
     this._labelScanStore         = labelScanStore;
     this._indexingService        = indexingService;
     this._explicitIndexProviders = explicitIndexProviders;
 }
 internal LabelScanViewNodeStoreWrapper(MultiIndexPopulationConcurrentUpdatesIT outerInstance, StorageReader storageReader, LockService locks, LabelScanStore labelScanStore, Visitor <NodeLabelUpdate, FAILURE> labelUpdateVisitor, Visitor <EntityUpdates, FAILURE> propertyUpdatesVisitor, int[] labelIds, System.Func <int, bool> propertyKeyIdFilter, LabelScanViewNodeStoreScan <FAILURE> @delegate, ThreadStart customAction) : base(storageReader, locks, labelScanStore, labelUpdateVisitor, propertyUpdatesVisitor, labelIds, propertyKeyIdFilter)
 {
     this._outerInstance = outerInstance;
     this.Delegate       = @delegate;
     this.CustomAction   = customAction;
 }
 internal DynamicIndexStoreViewWrapper(MultiIndexPopulationConcurrentUpdatesIT outerInstance, NeoStoreIndexStoreView neoStoreIndexStoreView, LabelScanStore labelScanStore, LockService locks, NeoStores neoStores, ThreadStart customAction) : base(neoStoreIndexStoreView, labelScanStore, locks, neoStores, NullLogProvider.Instance)
 {
     this._outerInstance = outerInstance;
     this.CustomAction   = customAction;
     this.NeoStores      = neoStores;
 }
        private DynamicIndexStoreView DynamicIndexStoreViewWrapper(ThreadStart customAction, NeoStores neoStores, LabelScanStore labelScanStore)
        {
            LockService            locks = LockService.NO_LOCK_SERVICE;
            NeoStoreIndexStoreView neoStoreIndexStoreView = new NeoStoreIndexStoreView(locks, neoStores);

            return(new DynamicIndexStoreViewWrapper(this, neoStoreIndexStoreView, labelScanStore, locks, neoStores, customAction));
        }