@Test public void generateExceedSubMilliSecond() throws Exception { DummyFlakeGenerator production = new DummyFlakeGenerator(); Set<FlakeId> flakeIds = IntStream.range(0, 1024000).parallel() .mapToObj(i -> production.next()).collect(Collectors.toSet()); assertEquals(1024000, flakeIds.size()); assertEquals(445, flakeIds.stream().findFirst().get().nodeId()); }
public final FlakeId next() { return new FlakeId(getCurrentSequenceTime(), nodeId); }
FlakeIdGenerator { public final FlakeId next() { return new FlakeId(getCurrentSequenceTime(), nodeId); } }
FlakeIdGenerator { public final FlakeId next() { return new FlakeId(getCurrentSequenceTime(), nodeId); } protected  FlakeIdGenerator(int nodeId); @VisibleForTesting  FlakeIdGenerator(int nodeId, Clock clock, String scope); }
FlakeIdGenerator { public final FlakeId next() { return new FlakeId(getCurrentSequenceTime(), nodeId); } protected  FlakeIdGenerator(int nodeId); @VisibleForTesting  FlakeIdGenerator(int nodeId, Clock clock, String scope); final FlakeId next(); final int getNodeId(); }
FlakeIdGenerator { public final FlakeId next() { return new FlakeId(getCurrentSequenceTime(), nodeId); } protected  FlakeIdGenerator(int nodeId); @VisibleForTesting  FlakeIdGenerator(int nodeId, Clock clock, String scope); final FlakeId next(); final int getNodeId();  }