Package me.prettyprint.hector.api

Examples of me.prettyprint.hector.api.ClockResolution


   * This test must be placed FIRST. Please don't change the order.
   * @throws Exception
   */
  @Test
  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(
View Full Code Here


  /**
   * 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);
      }
View Full Code Here

    public TimeUnit getClockResolution() {
        // The ClockResolution class in Hector is quite lame.
        // No equals() or any way to actually query it to find out
        // its resolution other than its class
        ClockResolution clockResolution = hostConfigurator.getClockResolution();
        if ((clockResolution instanceof MicrosecondsClockResolution)
            || (clockResolution instanceof MicrosecondsSyncClockResolution)) {
            return TimeUnit.MICROSECONDS;
        }
        if (clockResolution instanceof MillisecondsClockResolution) {
            return TimeUnit.MILLISECONDS;
        }
        if (clockResolution instanceof SecondsClockResolution) {
            return TimeUnit.SECONDS;
        }
        throw new AssertionError("Unexpected implementation class for clockResolution: "
                                         + clockResolution.getClass().getName());
    }
View Full Code Here

    public TimeUnit getClockResolution() {
        // The ClockResolution class in Hector is quite lame.
        // No equals() or any way to actually query it to find out
        // its resolution other than its class
        ClockResolution clockResolution = hostConfigurator.getClockResolution();
        if ((clockResolution instanceof MicrosecondsClockResolution)
            || (clockResolution instanceof MicrosecondsSyncClockResolution)) {
            return TimeUnit.MICROSECONDS;
        }
        if (clockResolution instanceof MillisecondsClockResolution) {
            return TimeUnit.MILLISECONDS;
        }
        if (clockResolution instanceof SecondsClockResolution) {
            return TimeUnit.SECONDS;
        }
        throw new AssertionError("Unexpected implementation class for clockResolution: "
                                         + clockResolution.getClass().getName());
    }
View Full Code Here

TOP

Related Classes of me.prettyprint.hector.api.ClockResolution

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.