Ejemplo n.º 1
0
 internal IndexProxyCreator(IndexSamplingConfig samplingConfig, IndexStoreView storeView, IndexProviderMap providerMap, TokenNameLookup tokenNameLookup, LogProvider logProvider)
 {
     this._samplingConfig  = samplingConfig;
     this._storeView       = storeView;
     this._providerMap     = providerMap;
     this._tokenNameLookup = tokenNameLookup;
     this._logProvider     = logProvider;
 }
        private StoreIndexDescriptor[] CreateIndexRules(IDictionary <string, int> labelNameIdMap, int propertyId)
        {
            IndexProvider           lookup             = IndexProviderMap.lookup(SchemaIndex.providerName());
            IndexProviderDescriptor providerDescriptor = lookup.ProviderDescriptor;

//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            return(labelNameIdMap.Values.Select(index => IndexDescriptorFactory.forSchema(SchemaDescriptorFactory.forLabel(index, propertyId), providerDescriptor).withId(index)).ToArray(StoreIndexDescriptor[] ::new));
        }
Ejemplo n.º 3
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;
            }
Ejemplo n.º 4
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;
            }
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public IndexAccessors(org.neo4j.kernel.impl.api.index.IndexProviderMap providers, org.neo4j.kernel.impl.store.RecordStore<org.neo4j.kernel.impl.store.record.DynamicRecord> schemaStore, org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig samplingConfig) throws java.io.IOException
        public IndexAccessors(IndexProviderMap providers, RecordStore <DynamicRecord> schemaStore, IndexSamplingConfig samplingConfig)
        {
            IEnumerator <StoreIndexDescriptor> indexes = (new SchemaStorage(schemaStore)).indexesGetAll();

            for ( ; ;)
            {
                try
                {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    if (indexes.hasNext())
                    {
                        // we intentionally only check indexes that are online since
                        // - populating indexes will be rebuilt on next startup
                        // - failed indexes have to be dropped by the user anyways
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                        StoreIndexDescriptor indexDescriptor = indexes.next();
                        if (indexDescriptor.IndexWithoutOwningConstraint)
                        {
                            _notOnlineIndexRules.Add(indexDescriptor);
                        }
                        else
                        {
                            if (InternalIndexState.ONLINE == Provider(providers, indexDescriptor).getInitialState(indexDescriptor))
                            {
                                _onlineIndexRules.Add(indexDescriptor);
                            }
                            else
                            {
                                _notOnlineIndexRules.Add(indexDescriptor);
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                catch (Exception)
                {
                    // ignore; inconsistencies of the schema store are specifically handled elsewhere.
                }
            }

            foreach (StoreIndexDescriptor indexRule in _onlineIndexRules)
            {
                long indexId = indexRule.Id;
                _accessors.put(indexId, Provider(providers, indexRule).getOnlineAccessor(indexRule, samplingConfig));
            }
        }
Ejemplo n.º 6
0
            internal SchemaCacheState(ConstraintSemantics constraintSemantics, IEnumerable <SchemaRule> rules, IndexProviderMap indexProviderMap)
            {
                this.ConstraintSemantics = constraintSemantics;
                this.IndexProviderMap    = indexProviderMap;
                this.ConstraintsConflict = new HashSet <ConstraintDescriptor>();
                this.IndexDescriptorById = new LongObjectHashMap <CapableIndexDescriptor>();
                this.ConstraintRuleById  = new LongObjectHashMap <ConstraintRule>();

                this.IndexDescriptorsConflict           = new Dictionary <SchemaDescriptor, CapableIndexDescriptor>();
                this.IndexDescriptorsByLabel            = new IntObjectHashMap <ISet <CapableIndexDescriptor> >();
                this.IndexDescriptorsByRelationshipType = new IntObjectHashMap <ISet <CapableIndexDescriptor> >();
                this.IndexDescriptorsByName             = new Dictionary <string, CapableIndexDescriptor>();
                this.DependantState  = new ConcurrentDictionary <Type, object>();
                this.IndexByProperty = new IntObjectHashMap <IList <CapableIndexDescriptor> >();
                Load(rules);
            }
Ejemplo n.º 7
0
            internal SchemaCacheState(SchemaCacheState schemaCacheState)
            {
                this.ConstraintSemantics = schemaCacheState.ConstraintSemantics;
                this.IndexDescriptorById = LongObjectHashMap.newMap(schemaCacheState.IndexDescriptorById);
                this.ConstraintRuleById  = LongObjectHashMap.newMap(schemaCacheState.ConstraintRuleById);
                this.ConstraintsConflict = new HashSet <ConstraintDescriptor>(schemaCacheState.ConstraintsConflict);

                this.IndexDescriptorsConflict = new Dictionary <SchemaDescriptor, CapableIndexDescriptor>(schemaCacheState.IndexDescriptorsConflict);
                this.IndexDescriptorsByLabel  = new IntObjectHashMap <ISet <CapableIndexDescriptor> >(schemaCacheState.IndexDescriptorsByLabel.size());
                schemaCacheState.IndexDescriptorsByLabel.forEachKeyValue((k, v) => IndexDescriptorsByLabel.put(k, new HashSet <>(v)));
                this.IndexDescriptorsByRelationshipType = new IntObjectHashMap <ISet <CapableIndexDescriptor> >(schemaCacheState.IndexDescriptorsByRelationshipType.size());
                schemaCacheState.IndexDescriptorsByRelationshipType.forEachKeyValue((k, v) => IndexDescriptorsByRelationshipType.put(k, new HashSet <>(v)));
                this.IndexDescriptorsByName = new Dictionary <string, CapableIndexDescriptor>(schemaCacheState.IndexDescriptorsByName);
                this.DependantState         = new ConcurrentDictionary <Type, object>();
                this.IndexByProperty        = new IntObjectHashMap <IList <CapableIndexDescriptor> >(schemaCacheState.IndexByProperty.size());
                schemaCacheState.IndexByProperty.forEachKeyValue((k, v) => IndexByProperty.put(k, new List <>(v)));
                this.IndexProviderMap = schemaCacheState.IndexProviderMap;
            }
Ejemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogUserReadableLabelAndPropertyNames() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLogUserReadableLabelAndPropertyNames()
        {
            //noinspection deprecation
            GraphDatabaseAPI db = DbRule.GraphDatabaseAPI;

            string labelName = "User";
            string property  = "name";

            // when
            CreateIndex(db, labelName, property);

            // then
            AssertableLogProvider.LogMatcherBuilder match = inLog(typeof(IndexPopulationJob));
            IndexProviderMap        indexProviderMap      = Db.DependencyResolver.resolveDependency(typeof(IndexProviderMap));
            IndexProvider           defaultProvider       = indexProviderMap.DefaultProvider;
            IndexProviderDescriptor providerDescriptor    = defaultProvider.ProviderDescriptor;

            _logProvider.assertAtLeastOnce(match.info("Index population started: [%s]", ":User(name) [provider: {key=" + providerDescriptor.Key + ", version=" + providerDescriptor.Version + "}]"));

            assertEventually((ThrowingSupplier <object, Exception>)() => null, new LogMessageMatcher(this, match, providerDescriptor), 1, TimeUnit.MINUTES);
        }
Ejemplo n.º 9
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 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();
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Snapshot constructor. This is only used by the <seealso cref="snapshot()"/> method.
 /// </summary>
 private SchemaCache(SchemaCacheState schemaCacheState)
 {
     this._cacheUpdateLock  = new InaccessibleLock("Schema cache snapshots are read-only.");
     this._indexProviderMap = null;
     this._schemaCacheState = schemaCacheState;
 }
Ejemplo n.º 12
0
 public SchemaCache(ConstraintSemantics constraintSemantics, IEnumerable <SchemaRule> initialRules, IndexProviderMap indexProviderMap)
 {
     this._cacheUpdateLock  = (new StampedLock()).asWriteLock();
     this._indexProviderMap = indexProviderMap;
     this._schemaCacheState = new SchemaCacheState(constraintSemantics, initialRules, indexProviderMap);
 }
Ejemplo n.º 13
0
        public static IndexingService CreateIndexingService(Config config, JobScheduler scheduler, IndexProviderMap providerMap, IndexStoreView storeView, TokenNameLookup tokenNameLookup, IEnumerable <SchemaRule> schemaRules, LogProvider internalLogProvider, LogProvider userLogProvider, IndexingService.Monitor monitor, SchemaState schemaState, bool readOnly)
        {
            IndexSamplingConfig            samplingConfig        = new IndexSamplingConfig(config);
            MultiPopulatorFactory          multiPopulatorFactory = MultiPopulatorFactory.ForConfig(config);
            IndexMapReference              indexMapRef           = new IndexMapReference();
            IndexSamplingControllerFactory factory = new IndexSamplingControllerFactory(samplingConfig, storeView, scheduler, tokenNameLookup, internalLogProvider);
            IndexSamplingController        indexSamplingController = factory.Create(indexMapRef);
            IndexProxyCreator              proxySetup = new IndexProxyCreator(samplingConfig, storeView, providerMap, tokenNameLookup, internalLogProvider);

            return(new IndexingService(proxySetup, providerMap, indexMapRef, storeView, schemaRules, indexSamplingController, tokenNameLookup, scheduler, schemaState, multiPopulatorFactory, internalLogProvider, userLogProvider, monitor, readOnly));
        }
Ejemplo n.º 14
0
 private IndexProvider Provider(IndexProviderMap providers, StoreIndexDescriptor indexRule)
 {
     return(providers.Lookup(indexRule.ProviderDescriptor()));
 }