Пример #1
0
        private Locks CreateLockManager(LocksFactory locksFactory, Config config, Clock clock, Replicator replicator, MemberId myself, LeaderLocator leaderLocator, ReplicatedLockTokenStateMachine lockTokenStateMachine)
        {
            Locks localLocks = EditionLocksFactories.createLockManager(locksFactory, config, clock);

            return(new LeaderOnlyLockManager(myself, replicator, leaderLocator, localLocks, lockTokenStateMachine));
        }
Пример #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);
        }