//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBootstrapWhenBootstrappable() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBootstrapWhenBootstrappable() { // given //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: IDictionary <MemberId, CoreServerInfo> members = IntStream.range(0, _minCoreHosts).mapToObj(i => Pair.of(new MemberId(System.Guid.randomUUID()), TestTopology.addressesForCore(i, false))).collect(Collectors.toMap(Pair::first, Pair::other)); CoreTopology bootstrappableTopology = new CoreTopology(null, true, members); CoreTopologyService topologyService = mock(typeof(CoreTopologyService)); when(topologyService.LocalCoreServers()).thenReturn(bootstrappableTopology); when(topologyService.SetClusterId(any(), eq("default"))).thenReturn(true); CoreSnapshot snapshot = mock(typeof(CoreSnapshot)); when(_coreBootstrapper.bootstrap(any())).thenReturn(snapshot); ClusterBinder binder = ClusterBinder(new StubSimpleStorage <ClusterId>(this), topologyService); // when BoundState boundState = binder.BindToCluster(); // then verify(_coreBootstrapper).bootstrap(any()); Optional <ClusterId> clusterId = binder.Get(); assertTrue(clusterId.Present); verify(topologyService).setClusterId(clusterId.get(), "default"); assertTrue(boundState.Snapshot().Present); assertEquals(boundState.Snapshot().get(), snapshot); }
//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); }
public virtual void InstallSnapshots(CoreSnapshot coreSnapshot) { Debug.Assert(!_runningBatch); _idAllocationStateMachine.installSnapshot(coreSnapshot.Get(CoreStateType.ID_ALLOCATION)); _replicatedLockTokenStateMachine.installSnapshot(coreSnapshot.Get(CoreStateType.LOCK_TOKEN)); // transactions and tokens live in the store }
public virtual void AddSnapshots(CoreSnapshot coreSnapshot) { Debug.Assert(!_runningBatch); coreSnapshot.Add(CoreStateType.ID_ALLOCATION, _idAllocationStateMachine.snapshot()); coreSnapshot.Add(CoreStateType.LOCK_TOKEN, _replicatedLockTokenStateMachine.snapshot()); // transactions and tokens live in the store }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public synchronized void installSnapshot(org.neo4j.causalclustering.core.state.snapshot.CoreSnapshot coreSnapshot) throws java.io.IOException public virtual void InstallSnapshot(CoreSnapshot coreSnapshot) { lock (this) { long snapshotPrevIndex = coreSnapshot.PrevIndex(); _raftLog.skip(snapshotPrevIndex, coreSnapshot.PrevTerm()); _coreState.installSnapshot(coreSnapshot); _raftMachine.installCoreState(coreSnapshot.Get(CoreStateType.RAFT_CORE_STATE)); _coreState.flush(snapshotPrevIndex); _applicationProcess.installSnapshot(coreSnapshot); Monitor.PulseAll(this); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public synchronized org.neo4j.causalclustering.core.state.snapshot.CoreSnapshot snapshot() throws Exception public virtual CoreSnapshot Snapshot() { lock (this) { _applicationProcess.pauseApplier(OPERATION_NAME); try { long lastApplied = _applicationProcess.lastApplied(); long prevTerm = _raftLog.readEntryTerm(lastApplied); CoreSnapshot coreSnapshot = new CoreSnapshot(lastApplied, prevTerm); _coreState.augmentSnapshot(coreSnapshot); coreSnapshot.Add(CoreStateType.RAFT_CORE_STATE, _raftMachine.coreState()); return(coreSnapshot); } finally { _applicationProcess.resumeApplier(OPERATION_NAME); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.causalclustering.core.state.snapshot.CoreSnapshot bootstrap(java.util.Set<org.neo4j.causalclustering.identity.MemberId> members) throws Exception public virtual CoreSnapshot Bootstrap(ISet <MemberId> members) { if (_recoveryRequiredChecker.isRecoveryRequiredAt(_databaseLayout)) { string message = "Cannot bootstrap. Recovery is required. Please ensure that the store being seeded comes from a cleanly shutdown " + "instance of Neo4j or a Neo4j backup"; _log.error(message); throw new System.InvalidOperationException(message); } StoreFactory factory = new StoreFactory(_databaseLayout, _config, new DefaultIdGeneratorFactory(_fs), _pageCache, _fs, _logProvider, EmptyVersionContextSupplier.EMPTY); NeoStores neoStores = factory.OpenAllNeoStores(true); neoStores.Close(); CoreSnapshot coreSnapshot = new CoreSnapshot(FIRST_INDEX, FIRST_TERM); coreSnapshot.Add(CoreStateType.ID_ALLOCATION, DeriveIdAllocationState(_databaseLayout)); coreSnapshot.Add(CoreStateType.LOCK_TOKEN, new ReplicatedLockTokenState()); coreSnapshot.Add(CoreStateType.RAFT_CORE_STATE, new RaftCoreState(new MembershipEntry(FIRST_INDEX, members))); coreSnapshot.Add(CoreStateType.SESSION_TRACKER, new GlobalSessionTrackerState()); AppendNullTransactionLogEntryToSetRaftIndexToMinusOne(); return(coreSnapshot); }
public override void Bootstrapped(CoreSnapshot snapshot, ClusterId clusterId) { _user.info("This instance bootstrapped the cluster."); _debug.info(format("Bootstrapped with snapshot: %s and clusterId: %s", snapshot, clusterId)); }
/// <summary> /// The applier must be paused when installing a snapshot. /// </summary> /// <param name="coreSnapshot"> The snapshot to install. </param> internal virtual void InstallSnapshot(CoreSnapshot coreSnapshot) { Debug.Assert(_pauseCount > 0); _applierState.lastApplied = _lastFlushed = coreSnapshot.PrevIndex(); }