internal TransactionToRecordStateVisitor(TransactionRecordState recordState, SchemaState schemaState, SchemaStorage schemaStorage, ConstraintSemantics constraintSemantics)
 {
     this._recordState         = recordState;
     this._schemaState         = schemaState;
     this._schemaStorage       = schemaStorage;
     this._constraintSemantics = constraintSemantics;
 }
Example #2
0
 public virtual void Load(IEnumerable <SchemaRule> rules)
 {
     _cacheUpdateLock.@lock();
     try
     {
         ConstraintSemantics constraintSemantics = _schemaCacheState.constraintSemantics;
         this._schemaCacheState = new SchemaCacheState(constraintSemantics, rules, _indexProviderMap);
     }
     finally
     {
         _cacheUpdateLock.unlock();
     }
 }
Example #3
0
        internal ModularDatabaseCreationContext(string databaseName, PlatformModule platformModule, DatabaseEditionContext editionContext, Procedures procedures, GraphDatabaseFacade facade)
        {
            this._databaseName = databaseName;
            this._config       = platformModule.Config;
            DatabaseIdContext idContext = editionContext.IdContext;

            this._idGeneratorFactory = idContext.IdGeneratorFactory;
            this._idController       = idContext.IdController;
            this._databaseLayout     = platformModule.StoreLayout.databaseLayout(databaseName);
            this._logService         = platformModule.Logging;
            this._scheduler          = platformModule.JobScheduler;
            this._globalDependencies = platformModule.Dependencies;
            this._tokenHolders       = editionContext.CreateTokenHolders();
            this._tokenNameLookup    = new NonTransactionalTokenNameLookup(_tokenHolders);
            this._locks = editionContext.CreateLocks();
            this._statementLocksFactory    = editionContext.CreateStatementLocksFactory();
            this._schemaWriteGuard         = editionContext.SchemaWriteGuard;
            this._transactionEventHandlers = new TransactionEventHandlers(facade);
            this._monitors = new Monitors(platformModule.Monitors);
            this._indexingServiceMonitor = _monitors.newMonitor(typeof(IndexingService.Monitor));
            this._physicalLogMonitor     = _monitors.newMonitor(typeof(LogFileCreationMonitor));
            this._fs = platformModule.FileSystem;
            this._transactionStats = editionContext.CreateTransactionMonitor();
            this._databaseHealth   = new DatabaseHealth(platformModule.PanicEventGenerator, _logService.getInternalLog(typeof(DatabaseHealth)));
            this._transactionHeaderInformationFactory = editionContext.HeaderInformationFactory;
            this._commitProcessFactory  = editionContext.CommitProcessFactory;
            this._autoIndexing          = new InternalAutoIndexing(platformModule.Config, _tokenHolders.propertyKeyTokens());
            this._indexConfigStore      = new IndexConfigStore(_databaseLayout, _fs);
            this._explicitIndexProvider = new DefaultExplicitIndexProvider();
            this._pageCache             = platformModule.PageCache;
            this._constraintSemantics   = editionContext.ConstraintSemantics;
            this._tracers    = platformModule.Tracers;
            this._procedures = procedures;
            this._ioLimiter  = editionContext.IoLimiter;
            this._clock      = platformModule.Clock;
            this._databaseAvailabilityGuard    = editionContext.CreateDatabaseAvailabilityGuard(_clock, _logService, _config);
            this._databaseAvailability         = new DatabaseAvailability(_databaseAvailabilityGuard, _transactionStats, platformModule.Clock, AwaitActiveTransactionDeadlineMillis);
            this._coreAPIAvailabilityGuard     = new CoreAPIAvailabilityGuard(_databaseAvailabilityGuard, editionContext.TransactionStartTimeout);
            this._accessCapability             = editionContext.AccessCapability;
            this._storeCopyCheckPointMutex     = new StoreCopyCheckPointMutex();
            this._recoveryCleanupWorkCollector = platformModule.RecoveryCleanupWorkCollector;
            this._databaseInfo               = platformModule.DatabaseInfo;
            this._versionContextSupplier     = platformModule.VersionContextSupplier;
            this._collectionsFactorySupplier = platformModule.CollectionsFactorySupplier;
            this._kernelExtensionFactories   = platformModule.KernelExtensionFactories;
            this._watcherServiceFactory      = editionContext.WatcherServiceFactory;
            this._facade          = facade;
            this._engineProviders = platformModule.EngineProviders;
        }
Example #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;
            }
        }
Example #5
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);
            }
Example #6
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;
            }
Example #7
0
 public KernelTransactions(Config config, StatementLocksFactory statementLocksFactory, ConstraintIndexCreator constraintIndexCreator, StatementOperationParts statementOperations, SchemaWriteGuard schemaWriteGuard, TransactionHeaderInformationFactory txHeaderFactory, TransactionCommitProcess transactionCommitProcess, AuxiliaryTransactionStateManager auxTxStateManager, TransactionHooks hooks, TransactionMonitor transactionMonitor, AvailabilityGuard databaseAvailabilityGuard, Tracers tracers, StorageEngine storageEngine, Procedures procedures, TransactionIdStore transactionIdStore, SystemNanoClock clock, AtomicReference <CpuClock> cpuClockRef, AtomicReference <HeapAllocation> heapAllocationRef, AccessCapability accessCapability, AutoIndexing autoIndexing, ExplicitIndexStore explicitIndexStore, VersionContextSupplier versionContextSupplier, CollectionsFactorySupplier collectionsFactorySupplier, ConstraintSemantics constraintSemantics, SchemaState schemaState, IndexingService indexingService, TokenHolders tokenHolders, string currentDatabaseName, Dependencies dataSourceDependencies)
 {
     if (!InstanceFieldsInitialized)
     {
         InitializeInstanceFields();
         InstanceFieldsInitialized = true;
     }
     this._config = config;
     this._statementLocksFactory  = statementLocksFactory;
     this._constraintIndexCreator = constraintIndexCreator;
     this._statementOperations    = statementOperations;
     this._schemaWriteGuard       = schemaWriteGuard;
     this._transactionHeaderInformationFactory = txHeaderFactory;
     this._transactionCommitProcess            = transactionCommitProcess;
     this._auxTxStateManager         = auxTxStateManager;
     this._hooks                     = hooks;
     this._transactionMonitor        = transactionMonitor;
     this._databaseAvailabilityGuard = databaseAvailabilityGuard;
     this._tracers                   = tracers;
     this._storageEngine             = storageEngine;
     this._procedures                = procedures;
     this._transactionIdStore        = transactionIdStore;
     this._cpuClockRef               = cpuClockRef;
     this._heapAllocationRef         = heapAllocationRef;
     this._accessCapability          = accessCapability;
     this._autoIndexing              = autoIndexing;
     this._explicitIndexStore        = explicitIndexStore;
     this._indexingService           = indexingService;
     this._tokenHolders              = tokenHolders;
     this._currentDatabaseName       = currentDatabaseName;
     this._dataSourceDependencies    = dataSourceDependencies;
     this._versionContextSupplier    = versionContextSupplier;
     this._clock                     = clock;
     DoBlockNewTransactions();
     this._collectionsFactorySupplier = collectionsFactorySupplier;
     this._constraintSemantics        = constraintSemantics;
     this._schemaState = schemaState;
 }
Example #8
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);
 }