Esempio n. 1
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private org.neo4j.kernel.impl.store.id.IdGeneratorFactory createIdGeneratorFactory(org.neo4j.io.fs.FileSystemAbstraction fileSystem, final org.neo4j.causalclustering.core.state.machines.id.ReplicatedIdRangeAcquirer idRangeAcquirer, final org.neo4j.logging.LogProvider logProvider, org.neo4j.kernel.impl.store.id.configuration.IdTypeConfigurationProvider idTypeConfigurationProvider)
        private IdGeneratorFactory CreateIdGeneratorFactory(FileSystemAbstraction fileSystem, ReplicatedIdRangeAcquirer idRangeAcquirer, LogProvider logProvider, IdTypeConfigurationProvider idTypeConfigurationProvider)
        {
            return(new ReplicatedIdGeneratorFactory(fileSystem, idRangeAcquirer, logProvider, idTypeConfigurationProvider));
        }
Esempio n. 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);
        }