@Test public void generateWithSubMilliSecond() throws Exception { DummyFlakeGenerator generator = new DummyFlakeGenerator(1, fixed(10, 3), "genSub"); List<FlakeId> flakeIds = IntStream.range(0, 4096) .mapToObj(i -> generator.next()) .collect(Collectors.toList()); assertEquals("flake id generated on the same time should different in sub millisecond", 4096, Sets.newHashSet(flakeIds).size()); assertEquals(99656663040000001L, flakeIds.get(0).value()); assertEquals(99656663044193281L, flakeIds.get(4095).value()); }
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();  }