Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
            _file = TestDirectory.file("idgen");
            _fs   = FileSystemRule.get();
            when(_raftMachine.state()).thenReturn(_state);
            _idReusabilityCondition = IdReusabilityCondition;
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void freeIdOnlyWhenReusabilityConditionAllows()
        public virtual void FreeIdOnlyWhenReusabilityConditionAllows()
        {
            ReplicatedIdRangeAcquirer rangeAcquirer = SimpleRangeAcquirer(IdType.NODE, 0, 1024);

            IdReusabilityCondition idReusabilityCondition = IdReusabilityCondition;

            long burnedIds = 23L;

            using (FreeIdFilteredIdGenerator idGenerator = new FreeIdFilteredIdGenerator(GetReplicatedIdGenerator(10, burnedIds, rangeAcquirer), idReusabilityCondition))
            {
                idGenerator.FreeId(10);
                assertEquals(0, idGenerator.DefragCount);
                assertEquals(23, idGenerator.NextId());

                when(_commandIndexTracker.AppliedCommandIndex).thenReturn(4L, 6L);                             // gap-free
                when(_state.lastLogIndexBeforeWeBecameLeader()).thenReturn(5L);
                idReusabilityCondition.OnLeaderSwitch(new LeaderInfo(_myself, 1));

                assertEquals(24, idGenerator.NextId());
                idGenerator.FreeId(11);
                assertEquals(25, idGenerator.NextId());
                idGenerator.FreeId(6);
                assertEquals(6, idGenerator.NextId());
            }
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
            when(_raftMachine.state()).thenReturn(_state);
            _myself = new MemberId(System.Guid.randomUUID());
            _idReusabilityCondition = new IdReusabilityCondition(_commandIndexTracker, _raftMachine, _myself);
        }