Esempio n. 1
0
        public ClusteringModule(DiscoveryServiceFactory discoveryServiceFactory, MemberId myself, PlatformModule platformModule, File clusterStateDirectory, DatabaseLayout databaseLayout)
        {
            LifeSupport           life                  = platformModule.Life;
            Config                config                = platformModule.Config;
            LogProvider           logProvider           = platformModule.Logging.InternalLogProvider;
            LogProvider           userLogProvider       = platformModule.Logging.UserLogProvider;
            Dependencies          dependencies          = platformModule.Dependencies;
            Monitors              monitors              = platformModule.Monitors;
            FileSystemAbstraction fileSystem            = platformModule.FileSystem;
            RemoteMembersResolver remoteMembersResolver = chooseResolver(config, platformModule.Logging);

            _topologyService = discoveryServiceFactory.CoreTopologyService(config, myself, platformModule.JobScheduler, logProvider, userLogProvider, remoteMembersResolver, ResolveStrategy(config, logProvider), monitors);

            life.Add(_topologyService);

            dependencies.SatisfyDependency(_topologyService);                 // for tests

            CoreBootstrapper coreBootstrapper = new CoreBootstrapper(databaseLayout, platformModule.PageCache, fileSystem, config, logProvider, platformModule.Monitors);

            SimpleStorage <ClusterId> clusterIdStorage = new SimpleFileStorage <ClusterId>(fileSystem, clusterStateDirectory, CLUSTER_ID_NAME, new ClusterId.Marshal(), logProvider);

            SimpleStorage <DatabaseName> dbNameStorage = new SimpleFileStorage <DatabaseName>(fileSystem, clusterStateDirectory, DB_NAME, new DatabaseName.Marshal(), logProvider);

            string dbName           = config.Get(CausalClusteringSettings.database);
            int    minimumCoreHosts = config.Get(CausalClusteringSettings.minimum_core_cluster_size_at_formation);

            Duration clusterBindingTimeout = config.Get(CausalClusteringSettings.cluster_binding_timeout);

            _clusterBinder = new ClusterBinder(clusterIdStorage, dbNameStorage, _topologyService, Clocks.systemClock(), () => sleep(100), clusterBindingTimeout, coreBootstrapper, dbName, minimumCoreHosts, platformModule.Monitors);
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailToBootstrapIfClusterIsInNeedOfRecoveryWithCustomLogicalLogsLocation() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailToBootstrapIfClusterIsInNeedOfRecoveryWithCustomLogicalLogsLocation()
        {
            // given
            int nodeCount = 100;
            FileSystemAbstraction fileSystem            = _fileSystemRule.get();
            string customTransactionLogsLocation        = "transaction-logs";
            File   storeInNeedOfRecovery                = ClassicNeo4jStore.builder(_testDirectory.directory(), fileSystem).amountOfNodes(nodeCount).logicalLogsLocation(customTransactionLogsLocation).needToRecover().build().StoreDir;
            AssertableLogProvider assertableLogProvider = new AssertableLogProvider();

            PageCache        pageCache      = _pageCacheRule.getPageCache(fileSystem);
            DatabaseLayout   databaseLayout = DatabaseLayout.of(storeInNeedOfRecovery);
            Config           config         = Config.defaults(GraphDatabaseSettings.logical_logs_location, customTransactionLogsLocation);
            CoreBootstrapper bootstrapper   = new CoreBootstrapper(databaseLayout, pageCache, fileSystem, config, assertableLogProvider, new Monitors());

            // when
            ISet <MemberId> membership = asSet(RandomMember(), RandomMember(), RandomMember());

            try
            {
                bootstrapper.Bootstrap(membership);
                fail();
            }
            catch (Exception e)
            {
                string errorMessage = "Cannot bootstrap. Recovery is required. Please ensure that the store being seeded comes from a cleanly shutdown " +
                                      "instance of Neo4j or a Neo4j backup";
                assertEquals(e.Message, errorMessage);
                assertableLogProvider.AssertExactly(AssertableLogProvider.inLog(typeof(CoreBootstrapper)).error(errorMessage));
            }
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSetAllCoreState() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSetAllCoreState()
        {
            // given
            int nodeCount = 100;
            FileSystemAbstraction fileSystem = _fileSystemRule.get();
            File classicNeo4jStore           = ClassicNeo4jStore.builder(_testDirectory.directory(), fileSystem).amountOfNodes(nodeCount).build().StoreDir;

            PageCache        pageCache      = _pageCacheRule.getPageCache(fileSystem);
            DatabaseLayout   databaseLayout = DatabaseLayout.of(classicNeo4jStore);
            CoreBootstrapper bootstrapper   = new CoreBootstrapper(databaseLayout, pageCache, fileSystem, Config.defaults(), NullLogProvider.Instance, new Monitors());

            BootstrapAndVerify(nodeCount, fileSystem, databaseLayout, pageCache, Config.defaults(), bootstrapper);
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void setAllCoreStateOnDatabaseWithCustomLogFilesLocation() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SetAllCoreStateOnDatabaseWithCustomLogFilesLocation()
        {
            // given
            int nodeCount = 100;
            FileSystemAbstraction fileSystem     = _fileSystemRule.get();
            string customTransactionLogsLocation = "transaction-logs";
            File   classicNeo4jStore             = ClassicNeo4jStore.builder(_testDirectory.directory(), fileSystem).amountOfNodes(nodeCount).logicalLogsLocation(customTransactionLogsLocation).build().StoreDir;

            PageCache        pageCache      = _pageCacheRule.getPageCache(fileSystem);
            DatabaseLayout   databaseLayout = DatabaseLayout.of(classicNeo4jStore);
            Config           config         = Config.defaults(GraphDatabaseSettings.logical_logs_location, customTransactionLogsLocation);
            CoreBootstrapper bootstrapper   = new CoreBootstrapper(databaseLayout, pageCache, fileSystem, config, NullLogProvider.Instance, new Monitors());

            BootstrapAndVerify(nodeCount, fileSystem, databaseLayout, pageCache, config, bootstrapper);
        }
Esempio n. 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void bootstrapAndVerify(long nodeCount, org.neo4j.io.fs.FileSystemAbstraction fileSystem, org.neo4j.io.layout.DatabaseLayout databaseLayout, org.neo4j.io.pagecache.PageCache pageCache, org.neo4j.kernel.configuration.Config config, CoreBootstrapper bootstrapper) throws Exception
        private static void BootstrapAndVerify(long nodeCount, FileSystemAbstraction fileSystem, DatabaseLayout databaseLayout, PageCache pageCache, Config config, CoreBootstrapper bootstrapper)
        {
            // when
            ISet <MemberId> membership = asSet(RandomMember(), RandomMember(), RandomMember());
            CoreSnapshot    snapshot   = bootstrapper.Bootstrap(membership);

            // then
            int recordIdBatchSize = parseInt(record_id_batch_size.DefaultValue);

            assertThat((( IdAllocationState )snapshot.Get(CoreStateType.ID_ALLOCATION)).firstUnallocated(IdType.NODE), allOf(greaterThanOrEqualTo(nodeCount), lessThanOrEqualTo(nodeCount + recordIdBatchSize)));

            /* Bootstrapped state is created in RAFT land at index -1 and term -1. */
            assertEquals(0, snapshot.PrevIndex());
            assertEquals(0, snapshot.PrevTerm());

            /* Lock is initially not taken. */
            assertEquals(new ReplicatedLockTokenState(), snapshot.Get(CoreStateType.LOCK_TOKEN));

            /* Raft has the bootstrapped set of members initially. */
            assertEquals(membership, (( RaftCoreState )snapshot.Get(CoreStateType.RAFT_CORE_STATE)).committed().members());

            /* The session state is initially empty. */
            assertEquals(new GlobalSessionTrackerState(), snapshot.Get(CoreStateType.SESSION_TRACKER));

            ReadOnlyTransactionStore transactionStore         = new ReadOnlyTransactionStore(pageCache, fileSystem, databaseLayout, config, new Monitors());
            LastCommittedIndexFinder lastCommittedIndexFinder = new LastCommittedIndexFinder(new ReadOnlyTransactionIdStore(pageCache, databaseLayout), transactionStore, NullLogProvider.Instance);

            long lastCommittedIndex = lastCommittedIndexFinder.LastCommittedIndex;

            assertEquals(-1, lastCommittedIndex);
        }