示例#1
0
 internal virtual long FirstUnallocated(IdType idType)
 {
     lock (this)
     {
         return(State().firstUnallocated(idType));
     }
 }
示例#2
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public org.neo4j.com.Response<org.neo4j.kernel.ha.id.IdAllocation> allocateIds(org.neo4j.com.RequestContext context, final org.neo4j.kernel.impl.store.id.IdType idType)
        public override Response <IdAllocation> AllocateIds(RequestContext context, IdType idType)
        {
            Serializer serializer = buffer => buffer.writeByte(( int )idType);
            Deserializer <IdAllocation> deserializer = (buffer, temporaryBuffer) => ReadIdAllocation(buffer);

            return(SendRequest(_requestTypes.type(HaRequestTypes_Type.AllocateIds), context, serializer, deserializer));
        }
示例#3
0
 public ReplicatedIdAllocationRequest(MemberId owner, IdType idType, long idRangeStart, int idRangeLength)
 {
     this._owner         = owner;
     this._idType        = idType;
     this._idRangeStart  = idRangeStart;
     this._idRangeLength = idRangeLength;
 }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void openFilteredGenerator()
        public virtual void OpenFilteredGenerator()
        {
            FreeIdFilteredIdGeneratorFactory filteredGenerator = CreateFilteredFactory();
            IdType idType = IdType.NODE;
            long   highId = 1L;
            long   maxId  = 10L;

            System.Func <long> highIdSupplier = () => highId;
            IdGenerator        idGenerator    = filteredGenerator.Open(_file, idType, highIdSupplier, maxId);

            verify(_idGeneratorFactory).open(eq(_file), eq(idType), any(typeof(System.Func <long>)), eq(maxId));
            assertThat(idGenerator, instanceOf(typeof(FreeIdFilteredIdGenerator)));
        }
示例#5
0
        public override void ApplyCommand(ReplicatedIdAllocationRequest request, long commandIndex, System.Action <Result> callback)
        {
            lock (this)
            {
                if (commandIndex <= State().logIndex())
                {
                    return;
                }

                State().logIndex(commandIndex);

                IdType idType = request.IdType();

                bool requestAccepted = request.IdRangeStart() == FirstUnallocated(idType);
                if (requestAccepted)
                {
                    State().firstUnallocated(idType, request.IdRangeStart() + request.IdRangeLength());
                }

                callback(Result.of(requestAccepted));
            }
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createContextWithCustomIdGeneratorFactoryWhenProvided()
        internal virtual void CreateContextWithCustomIdGeneratorFactoryWhenProvided()
        {
            IdGeneratorFactory idGeneratorFactory = mock(typeof(IdGeneratorFactory));
            IdContextFactory   contextFactory     = IdContextFactoryBuilder.Of(_fs, _jobScheduler).withIdGenerationFactoryProvider(any => idGeneratorFactory).build();
            DatabaseIdContext  idContext          = contextFactory.CreateIdContext("database");

            IdGeneratorFactory bufferedGeneratorFactory = idContext.IdGeneratorFactory;

            assertThat(idContext.IdController, instanceOf(typeof(BufferedIdController)));
            assertThat(bufferedGeneratorFactory, instanceOf(typeof(BufferingIdGeneratorFactory)));

            (( BufferingIdGeneratorFactory )bufferedGeneratorFactory).initialize(() => mock(typeof(KernelTransactionsSnapshot)));
            File   file   = _testDirectory.file("a");
            IdType idType = IdType.NODE;

            System.Func <long> highIdSupplier = () => 0;
            int maxId = 100;

            idGeneratorFactory.Open(file, idType, highIdSupplier, maxId);

            verify(idGeneratorFactory).open(file, idType, highIdSupplier, maxId);
        }
示例#7
0
        public override IdAllocation AllocateIds(IdType idType)
        {
            IdGenerator generator = _idGeneratorFactory.get(idType);

            return(new IdAllocation(generator.NextIdBatch(ID_GRAB_SIZE), generator.HighId, generator.DefragCount));
        }
示例#8
0
 /// <param name="idType">     the type of graph object whose ID is under allocation </param>
 /// <param name="idRangeEnd"> the first unallocated entry for idType </param>
 internal virtual void FirstUnallocated(IdType idType, long idRangeEnd)
 {
     _firstUnallocated[( int )idType] = idRangeEnd;
 }
示例#9
0
 /// <param name="idType"> the type of graph object whose ID is under allocation </param>
 /// <returns> the first unallocated entry for idType </returns>
 public override long FirstUnallocated(IdType idType)
 {
     return(_firstUnallocated[( int )idType]);
 }