PartitionedRegionIDGenerator implements IDGenerator<Long> { @Override public synchronized Long generate(String domain) { if (nextId < 0L || nextId > lastId) { Collection<long[]> coll = (Collection<long[]>) functionServiceHelper .onRegion(idRegion) .withArgs(domain) .execute("PartitionedRegionIDGeneratorFunction") .getResult(); assert coll.size() == 1; long[] ids = coll.iterator().next(); assert ids.length == 2; nextId = ids[0]; lastId = ids[1]; } LOG.debug("generate: domain={}, nextId={}, lastId={}", domain, nextId, lastId); return nextId++; } PartitionedRegionIDGenerator(Region<String, Long> idRegion, FunctionServiceHelper functionServiceHelper); @Override synchronized Long generate(String domain);  }
@Test void getId() { assertEquals((long)idGenerator.generate("test"), 0L); assertEquals((long)idGenerator.generate("test"), 1L); assertEquals((long)idGenerator.generate("test"), 2L); assertEquals((long)idGenerator.generate("test"), 3L); }