class 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++;
    }

    public  PartitionedRegionIDGenerator(Region<String, Long> idRegion, FunctionServiceHelper functionServiceHelper);

}