/** * Create a timestamp based on the TimeResolution set to the cluster. * * @return a timestamp */ public long createTimestamp() { return chc.getClockResolution().createClock(); }
public long createClock() { return this.clock.createClock(); }
/** * Creates a clock of now with the default clock resolution (micorosec) as * defined in {@link CassandraHostConfigurator}. Notice that this is a * convenience method. To specify explicit time, * {@link Keyspace#createClock()} should be used instead. */ public static long createClock() { return CassandraHostConfigurator.getClockResolution().createClock(); }
/** * Gets a new time uuid using {@link ClockResolution#createClock()} as a time generator. * It is useful to use in a TimeUUIDType sorted column family. * * @param clock a ClockResolution * @return the time uuid */ public static java.util.UUID getTimeUUID(ClockResolution clock) { return getTimeUUID(clock.createClock()); }
/** * Test that multiple calls do not generate the same clock (timestamp) */ @Test public void testMicrosecondsSync() throws Exception { ClockResolution clockResolution = HFactory.createClockResolution(ClockResolution.MICROSECONDS_SYNC); long previous = clockResolution.createClock(); for (int i = 0; i < 50; i++) { long current = clockResolution.createClock(); log.debug("previous=" + previous + " - current=" + current); if (current == previous) { fail("Two calls to clock generated the same timestamp. (previous=" + previous + " - current=" + current + "). Cycle:" + i); } current = previous; } }
/** * Creates a clock of now with the default clock resolution (micorosec) as * defined in {@link CassandraHostConfigurator}. Notice that this is a * convenience method. To specify explicit time, * {@link Keyspace#createClock()} should be used instead. */ public static long createClock() { return CassandraHostConfigurator.DEF_CLOCK_RESOLUTION.createClock(); }
@Override public long createClock() { return CassandraHostConfigurator.DEF_CLOCK_RESOLUTION.createClock(); }
public long createClock() { return this.clock.createClock(); }
public long createClock() { return this.clock.createClock(); }
/** * Creates a clock of now with the default clock resolution (micorosec) as * defined in {@link CassandraHostConfigurator}. Notice that this is a * convenience method. To specify explicit time, * {@link Keyspace#createClock()} should be used instead. */ public static long createClock() { return CassandraHostConfigurator.getClockResolution().createClock(); }
/** * Gets a new time uuid using {@link ClockResolution#createClock()} as a time generator. * It is useful to use in a TimeUUIDType sorted column family. * * @param clock a ClockResolution * @return the time uuid */ public static java.util.UUID getTimeUUID(ClockResolution clock) { return getTimeUUID(clock.createClock()); }
/** * Gets a new time uuid using {@link ClockResolution#createClock()} as a time generator. * It is useful to use in a TimeUUIDType sorted column family. * * @param clock a ClockResolution * @return the time uuid */ public static java.util.UUID getTimeUUID(ClockResolution clock) { return getTimeUUID(clock.createClock()); }
/** * This test must be placed FIRST. Please don't change the order. * @throws Exception */ @Test @Ignore public void testTimeUUIDWithClockResolution() throws Exception { ClockResolution clock = new MicrosecondsClockResolution(); long time = clock.createClock(); // Invoke twice with same time. Both generated UUID should be the same. // Test improved algorithm. assertEquals(TimeUUIDUtils.getTimeUUID(time), java.util.UUID.fromString( new com.eaio.uuid.UUID(UUIDGen.createTime(time), UUIDGen.getClockSeqAndNode()).toString())); clock = new MicrosecondsSyncClockResolution(); // Invoke twice with a clockResolution that guarantees unique timestamp. The second must be greater // than the first one. java.util.UUID first = TimeUUIDUtils.getTimeUUID(clock); java.util.UUID second = TimeUUIDUtils.getTimeUUID(clock); assertTrue(second.compareTo(first) > 0); }