コード例 #1
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);
        }
コード例 #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));
            }
        }