Example #1
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 #2
0
        public CoreStateMachinesModule(MemberId myself, PlatformModule platformModule, File clusterStateDirectory, Config config, RaftReplicator replicator, RaftMachine raftMachine, Dependencies dependencies, LocalDatabase localDatabase)
        {
            StateStorage <IdAllocationState>        idAllocationState;
            StateStorage <ReplicatedLockTokenState> lockTokenState;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.lifecycle.LifeSupport life = platformModule.life;
            LifeSupport life = platformModule.Life;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.io.fs.FileSystemAbstraction fileSystem = platformModule.fileSystem;
            FileSystemAbstraction fileSystem  = platformModule.FileSystem;
            LogService            logging     = platformModule.Logging;
            LogProvider           logProvider = logging.InternalLogProvider;

            lockTokenState = life.Add(new DurableStateStorage <>(fileSystem, clusterStateDirectory, LOCK_TOKEN_NAME, new ReplicatedLockTokenState.Marshal(new MemberId.Marshal()), config.Get(replicated_lock_token_state_size), logProvider));

            idAllocationState = life.Add(new DurableStateStorage <>(fileSystem, clusterStateDirectory, ID_ALLOCATION_NAME, new IdAllocationState.Marshal(), config.Get(id_alloc_state_size), logProvider));

            ReplicatedIdAllocationStateMachine idAllocationStateMachine = new ReplicatedIdAllocationStateMachine(idAllocationState);

            IDictionary <IdType, int> allocationSizes = GetIdTypeAllocationSizeFromConfig(config);

            ReplicatedIdRangeAcquirer idRangeAcquirer = new ReplicatedIdRangeAcquirer(replicator, idAllocationStateMachine, allocationSizes, myself, logProvider);

            IdTypeConfigurationProvider = new EnterpriseIdTypeConfigurationProvider(config);
            CommandIndexTracker commandIndexTracker = dependencies.SatisfyDependency(new CommandIndexTracker());

            FreeIdCondition         = new IdReusabilityCondition(commandIndexTracker, raftMachine, myself);
            this.IdGeneratorFactory = CreateIdGeneratorFactory(fileSystem, idRangeAcquirer, logProvider, IdTypeConfigurationProvider);

            TokenRegistry relationshipTypeTokenRegistry = new TokenRegistry(Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_RELATIONSHIP_TYPE);

            System.Func <StorageEngine>           storageEngineSupplier       = () => localDatabase.DataSource().DependencyResolver.resolveDependency(typeof(StorageEngine));
            ReplicatedRelationshipTypeTokenHolder relationshipTypeTokenHolder = new ReplicatedRelationshipTypeTokenHolder(relationshipTypeTokenRegistry, replicator, this.IdGeneratorFactory, storageEngineSupplier);

            TokenRegistry propertyKeyTokenRegistry = new TokenRegistry(Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_PROPERTY_KEY);
            ReplicatedPropertyKeyTokenHolder propertyKeyTokenHolder = new ReplicatedPropertyKeyTokenHolder(propertyKeyTokenRegistry, replicator, this.IdGeneratorFactory, storageEngineSupplier);

            TokenRegistry labelTokenRegistry            = new TokenRegistry(Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_LABEL);
            ReplicatedLabelTokenHolder labelTokenHolder = new ReplicatedLabelTokenHolder(labelTokenRegistry, replicator, this.IdGeneratorFactory, storageEngineSupplier);

            ReplicatedLockTokenStateMachine replicatedLockTokenStateMachine = new ReplicatedLockTokenStateMachine(lockTokenState);

            VersionContextSupplier      versionContextSupplier = platformModule.VersionContextSupplier;
            ReplicatedTokenStateMachine labelTokenStateMachine = new ReplicatedTokenStateMachine(labelTokenRegistry, logProvider, versionContextSupplier);

            ReplicatedTokenStateMachine propertyKeyTokenStateMachine = new ReplicatedTokenStateMachine(propertyKeyTokenRegistry, logProvider, versionContextSupplier);

            ReplicatedTokenStateMachine relationshipTypeTokenStateMachine = new ReplicatedTokenStateMachine(relationshipTypeTokenRegistry, logProvider, versionContextSupplier);

            PageCursorTracerSupplier          cursorTracerSupplier     = platformModule.Tracers.pageCursorTracerSupplier;
            ReplicatedTransactionStateMachine replicatedTxStateMachine = new ReplicatedTransactionStateMachine(commandIndexTracker, replicatedLockTokenStateMachine, config.Get(state_machine_apply_max_batch_size), logProvider, cursorTracerSupplier, versionContextSupplier);

            dependencies.SatisfyDependencies(replicatedTxStateMachine);

            LocksFactory lockFactory = createLockFactory(config, logging);

            LocksSupplier = () => CreateLockManager(lockFactory, config, platformModule.Clock, replicator, myself, raftMachine, replicatedLockTokenStateMachine);

            RecoverConsensusLogIndex consensusLogIndexRecovery = new RecoverConsensusLogIndex(localDatabase, logProvider);

            CoreStateMachines = new CoreStateMachines(replicatedTxStateMachine, labelTokenStateMachine, relationshipTypeTokenStateMachine, propertyKeyTokenStateMachine, replicatedLockTokenStateMachine, idAllocationStateMachine, new DummyMachine(), localDatabase, consensusLogIndexRecovery);

            CommitProcessFactory = (appender, applier, ignored) =>
            {
                localDatabase.RegisterCommitProcessDependencies(appender, applier);
                return(new ReplicatedTransactionCommitProcess(replicator));
            };

            this.TokenHolders = new TokenHolders(propertyKeyTokenHolder, labelTokenHolder, relationshipTypeTokenHolder);
            dependencies.SatisfyDependencies(TokenHolders);
        }