@Test public void idsThatHaveBeenGeneratedASecondApartAlsoAreASecondApartInIdSpace() throws InterruptedException { Long id1 = flake.nextId(); Wait.delay(1, TimeUnit.SECONDS); Long id2 = flake.nextId(); long timestampFromId1 = id1 >> 22; long timestampFromId2 = id2 >> 22; long timeBetween = timestampFromId2 - timestampFromId1; assertTrue(timeBetween > 900L && timeBetween < 1_800L); }
@Override public Long nextId() { final SequenceNumber sequenceNumber = getSequence().nextSequenceNumber(); final ByteBuffer bb = (ByteBuffer) toByteBuffer(sequenceNumber); return encoder.encode(bb); }
Flake64L extends Flake64<Long> { @Override public Long nextId() { final SequenceNumber sequenceNumber = getSequence().nextSequenceNumber(); final ByteBuffer bb = (ByteBuffer) toByteBuffer(sequenceNumber); return encoder.encode(bb); } }
Flake64L extends Flake64<Long> { @Override public Long nextId() { final SequenceNumber sequenceNumber = getSequence().nextSequenceNumber(); final ByteBuffer bb = (ByteBuffer) toByteBuffer(sequenceNumber); return encoder.encode(bb); } Flake64L(final TimeProvider timeProvider,
                    final WorkerIdProvider workerIdProvider);  Flake64L(final TimeProvider timeProvider,
                    final WorkerIdProvider workerIdProvider,
                    final Encoder<ByteBuffer, Long> encoder); }
Flake64L extends Flake64<Long> { @Override public Long nextId() { final SequenceNumber sequenceNumber = getSequence().nextSequenceNumber(); final ByteBuffer bb = (ByteBuffer) toByteBuffer(sequenceNumber); return encoder.encode(bb); } Flake64L(final TimeProvider timeProvider,
                    final WorkerIdProvider workerIdProvider);  Flake64L(final TimeProvider timeProvider,
                    final WorkerIdProvider workerIdProvider,
                    final Encoder<ByteBuffer, Long> encoder); @Override Long nextId(); }
Flake64L extends Flake64<Long> { @Override public Long nextId() { final SequenceNumber sequenceNumber = getSequence().nextSequenceNumber(); final ByteBuffer bb = (ByteBuffer) toByteBuffer(sequenceNumber); return encoder.encode(bb); } Flake64L(final TimeProvider timeProvider,
                    final WorkerIdProvider workerIdProvider);  Flake64L(final TimeProvider timeProvider,
                    final WorkerIdProvider workerIdProvider,
                    final Encoder<ByteBuffer, Long> encoder); @Override Long nextId();  }