Package org.linkedin.util.clock

Examples of org.linkedin.util.clock.Timespan


    assertFalse(futureWithException.isDone());

    // now we verify that shutdown is still not complete (until both tasks are complete)
    try
    {
      shutdown.waitForShutdown(new Timespan(200));
      fail("should timeout");
    }
    catch(TimeoutException e)
    {
      // expected
    }

    assertFalse(futureWithRes.isDone());
    assertFalse(futureWithException.isDone());

    // we finally unblock the tasks
    o.wakeUp();

    // we get both normal results
    assertEquals(10, (int) futureWithRes.get());
    try
    {
      futureWithException.get();
      fail("MyException should be thrown");
    }
    catch(ExecutionException ex)
    {
      assertTrue(ex.getCause() instanceof MyException);
    }

    // now we should be able to shutdown
    shutdown.waitForShutdown(new Timespan(200));

    executorService.shutdown();
    executorService.awaitTermination(200, TimeUnit.MILLISECONDS);
  }
View Full Code Here


    throws InterruptedException, IllegalStateException, TimeoutException
  {
    if(!_executorService.isShutdown())
      throw new IllegalStateException("call shutdown first");

    Timespan timespan = ClockUtils.toTimespan(timeout);
    if(timespan == null)
      _executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
    else
    if(!_executorService.awaitTermination(timespan.getDurationInMilliseconds(), TimeUnit.MILLISECONDS))
      throw new TimeoutException();
  }
View Full Code Here

  public Timespan getDuration()
  {
    if(isCompleted())
      return getCompletionStatus().getDuration();
    else
      return new Timespan(_context.currentTimeMillis() - getStartTime());
  }
View Full Code Here

  }

  @Override
  public Timespan getDuration()
  {
    return new Timespan(_endTime - _startTime);
  }
View Full Code Here

  }

  @Override
  public Timespan getDuration()
  {
    return new Timespan(_endTime - _startTime);
  }
View Full Code Here

TOP

Related Classes of org.linkedin.util.clock.Timespan

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.