示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldApplyCommittedCommand() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldApplyCommittedCommand()
        {
            // given
            RaftLogCommitIndexMonitor listener = mock(typeof(RaftLogCommitIndexMonitor));

            _monitors.addMonitorListener(listener);

            InOrder inOrder = inOrder(_coreState, _commandDispatcher);

            _raftLog.append(new RaftLogEntry(0, Operation(_nullTx)));
            _raftLog.append(new RaftLogEntry(0, Operation(_nullTx)));
            _raftLog.append(new RaftLogEntry(0, Operation(_nullTx)));

            // when
            _applicationProcess.notifyCommitted(2);
            _applicationProcess.start();

            // then
            inOrder.verify(_coreState).commandDispatcher();
            inOrder.verify(_commandDispatcher).dispatch(eq(_nullTx), eq(0L), AnyCallback());
            inOrder.verify(_commandDispatcher).dispatch(eq(_nullTx), eq(1L), AnyCallback());
            inOrder.verify(_commandDispatcher).dispatch(eq(_nullTx), eq(2L), AnyCallback());
            inOrder.verify(_commandDispatcher).close();

            verify(listener).commitIndex(2);
        }
示例#2
0
        public CommandApplicationProcess(RaftLog raftLog, int maxBatchSize, int flushEvery, System.Func <DatabaseHealth> dbHealth, LogProvider logProvider, ProgressTracker progressTracker, SessionTracker sessionTracker, CoreState coreState, InFlightCache inFlightCache, Monitors monitors)
        {
            if (!InstanceFieldsInitialized)
            {
                InitializeInstanceFields();
                InstanceFieldsInitialized = true;
            }
            this._raftLog         = raftLog;
            this._flushEvery      = flushEvery;
            this._progressTracker = progressTracker;
            this._sessionTracker  = sessionTracker;
            this._log             = logProvider.getLog(this.GetType());
            this._dbHealth        = dbHealth;
            this._coreState       = coreState;
            this._inFlightCache   = inFlightCache;
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            this._commitIndexMonitor = monitors.NewMonitor(typeof(RaftLogCommitIndexMonitor), this.GetType().FullName);
            this._batcher            = new CommandBatcher(maxBatchSize, this.applyBatch);
            this._batchStat          = StatUtil.create("BatchSize", _log, 4096, true);
        }