/* * Tests that we unfreeze active transactions after commit and after apply of batch if batch length (in time) * is larger than safeZone time. */ //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUnfreezeKernelTransactionsAfterApplyIfBatchIsLarge() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldUnfreezeKernelTransactionsAfterApplyIfBatchIsLarge() { // GIVEN int maxBatchSize = 10; long idReuseSafeZoneTime = 100; Dependencies dependencies = mock(typeof(Dependencies)); TransactionObligationFulfiller fulfiller = mock(typeof(TransactionObligationFulfiller)); when(dependencies.ObligationFulfiller()).thenReturn(fulfiller); when(dependencies.LogService()).thenReturn(NullLogService.Instance); when(dependencies.VersionContextSupplier()).thenReturn(EmptyVersionContextSupplier.EMPTY); KernelTransactions kernelTransactions = mock(typeof(KernelTransactions)); when(dependencies.KernelTransactions()).thenReturn(kernelTransactions); TransactionCommitProcess commitProcess = mock(typeof(TransactionCommitProcess)); when(dependencies.CommitProcess()).thenReturn(commitProcess); TransactionCommittingResponseUnpacker unpacker = Life.add(new TransactionCommittingResponseUnpacker(dependencies, maxBatchSize, idReuseSafeZoneTime)); // WHEN int txCount = maxBatchSize; int doesNotMatter = 1; unpacker.UnpackResponse(new DummyTransactionResponse(doesNotMatter, txCount, idReuseSafeZoneTime + 1), NO_OP_TX_HANDLER); // THEN InOrder inOrder = inOrder(commitProcess, kernelTransactions); inOrder.verify(commitProcess, times(1)).commit(any(), any(), any()); inOrder.verify(kernelTransactions, times(1)).unblockNewTransactions(); }
internal BatchingResponseHandler(int maxBatchSize, TransactionQueue.Applier applier, TransactionObligationFulfiller obligationFulfiller, ResponseUnpacker_TxHandler txHandler, VersionContextSupplier versionContextSupplier, Log log) { this._obligationFulfiller = obligationFulfiller; this._txHandler = txHandler; this._versionContextSupplier = versionContextSupplier; this._queue = new TransactionQueue(maxBatchSize, applier); this._log = log; }
public override void Start() { this._obligationFulfiller = _dependencies.obligationFulfiller(); this._log = _dependencies.logService().getInternalLog(typeof(BatchingResponseHandler)); this._versionContextSupplier = _dependencies.versionContextSupplier(); this._batchCommitter = new TransactionBatchCommitter(_dependencies.kernelTransactions(), _idReuseSafeZoneTime, _dependencies.commitProcess(), _log); this._stopped = false; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAwaitTransactionObligationsToBeFulfilled() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAwaitTransactionObligationsToBeFulfilled() { // GIVEN Dependencies dependencies = mock(typeof(Dependencies)); TransactionObligationFulfiller fulfiller = mock(typeof(TransactionObligationFulfiller)); when(dependencies.ObligationFulfiller()).thenReturn(fulfiller); when(dependencies.LogService()).thenReturn(NullLogService.Instance); TransactionCommittingResponseUnpacker unpacker = Life.add(new TransactionCommittingResponseUnpacker(dependencies, 10, 0)); // WHEN unpacker.UnpackResponse(new DummyObligationResponse(4), NO_OP_TX_HANDLER); // THEN verify(fulfiller, times(1)).fulfill(4L); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private java.net.URI startHaCommunication(org.neo4j.kernel.lifecycle.LifeSupport haCommunicationLife, org.neo4j.kernel.NeoStoreDataSource neoDataSource, java.net.URI me, java.net.URI masterUri, org.neo4j.storageengine.api.StoreId storeId, org.neo4j.helpers.CancellationRequest cancellationRequest) throws IllegalArgumentException, InterruptedException private URI StartHaCommunication(LifeSupport haCommunicationLife, NeoStoreDataSource neoDataSource, URI me, URI masterUri, StoreId storeId, CancellationRequest cancellationRequest) { MasterClient master = NewMasterClient(masterUri, me, neoDataSource.StoreId, haCommunicationLife); TransactionObligationFulfiller obligationFulfiller = ResolveDatabaseDependency(typeof(TransactionObligationFulfiller)); UpdatePullerScheduler updatePullerScheduler = _updatePullerFactory.createUpdatePullerScheduler(UpdatePuller); Slave slaveImpl = new SlaveImpl(obligationFulfiller); SlaveServer server = _slaveServerFactory.apply(slaveImpl); if (cancellationRequest.CancellationRequested()) { MsgLog.info("Switch to slave cancelled, unable to start HA-communication"); return(null); } _masterDelegateHandler.Delegate = master; haCommunicationLife.Add(updatePullerScheduler); haCommunicationLife.Add(server); haCommunicationLife.Start(); /* * Take the opportunity to catch up with master, now that we're alone here, right before we * drop the availability guard, so that other transactions might start. */ if (!CatchUpWithMaster(UpdatePuller)) { return(null); } URI slaveHaURI = CreateHaURI(me, server); _clusterMemberAvailability.memberIsAvailable(HighAvailabilityModeSwitcher.SLAVE, slaveHaURI, storeId); return(slaveHaURI); }
public SlaveImpl(TransactionObligationFulfiller fulfiller) { this._fulfiller = fulfiller; }