public override bool Equals(object o) { if (this == o) { return(true); } if (o == null || this.GetType() != o.GetType()) { return(false); } ReplicatedIdAllocationRequest that = ( ReplicatedIdAllocationRequest )o; if (_idRangeStart != that._idRangeStart) { return(false); } if (_idRangeLength != that._idRangeLength) { return(false); } if (!_owner.Equals(that._owner)) { return(false); } return(_idType == that._idType); }
private bool ReplicateIdAllocationRequest(IdType idType, ReplicatedIdAllocationRequest idAllocationRequest) { try { return(( bool? )_replicator.replicate(idAllocationRequest, true).get().Value); } catch (Exception e) { _log.warn(format("Failed to acquire id range for idType %s", idType), e); throw new IdGenerationException(e); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUpdateStateOnlyForTypeRequested() public virtual void ShouldUpdateStateOnlyForTypeRequested() { // given ReplicatedIdAllocationStateMachine stateMachine = new ReplicatedIdAllocationStateMachine(new InMemoryStateStorage <IdAllocationState>(new IdAllocationState())); ReplicatedIdAllocationRequest idAllocationRequest = new ReplicatedIdAllocationRequest(_me, _someType, 0, 1024); // when stateMachine.ApplyCommand(idAllocationRequest, 0, r => { }); // then assertEquals(1024, stateMachine.FirstUnallocated(_someType)); assertEquals(0, stateMachine.FirstUnallocated(_someOtherType)); }
internal virtual IdAllocation AcquireIds(IdType idType) { while (true) { long firstUnallocated = _idAllocationStateMachine.firstUnallocated(idType); ReplicatedIdAllocationRequest idAllocationRequest = new ReplicatedIdAllocationRequest(_me, idType, firstUnallocated, _allocationSizes[idType]); if (ReplicateIdAllocationRequest(idType, idAllocationRequest)) { IdRange idRange = new IdRange(EMPTY_LONG_ARRAY, firstUnallocated, _allocationSizes[idType]); return(new IdAllocation(idRange, -1, 0)); } else { _log.info("Retrying ID generation due to conflict. Request was: " + idAllocationRequest); } } }