Package com.google.common.base

Examples of com.google.common.base.Ticker


  }

  public void testSerializationProxyManual() {
    RemovalListener<Object, Object> listener = new SerializableRemovalListener<Object, Object>();
    SerializableWeigher<Object, Object> weigher = new SerializableWeigher<Object, Object>();
    Ticker ticker = new SerializableTicker();
    @SuppressWarnings("unchecked") // createMock
    LocalManualCache<Object, Object> one = (LocalManualCache) CacheBuilder.newBuilder()
        .weakKeys()
        .softValues()
        .expireAfterAccess(123, NANOSECONDS)
View Full Code Here


      return new Module() {
         @Override
         public void configure(Binder binder) {
            // predictable time
            binder.bind(Ticker.class).toInstance(new Ticker() {
               @Override
               public long read() {
                  return 0;
               }
            });
View Full Code Here

    @Test
    public void shouldCalculateIterationsTime() throws Exception {

        // given
        Ticker ticker = mock(Ticker.class);
        when(ticker.read()).thenReturn(0L, 2000000000L);
        Stopwatch stopwatch = new Stopwatch(ticker);

        // when
        stopwatch.start();
        // some method is called here
View Full Code Here

    @Test
    public void shouldPrintIterationsTime() throws Exception {

        // given
        Ticker ticker = mock(Ticker.class);
        when(ticker.read()).thenReturn(0L, 2*60*60*1000000000L); // 2 hours
        Stopwatch stopwatch = new Stopwatch(ticker);

        // when
        stopwatch.start();
        // some method is called here
View Full Code Here

   
    // Collection<Integer> allShards, ShardStateManager shardStateManager, TimeValue period
    @Test
    public void testStartStop() throws Exception {
        Collection<Integer> allShards = Collections.unmodifiableCollection(Util.parseShards("ALL"));
        ShardStateManager manager = new ShardStateManager(allShards, new Ticker() {
            @Override
            public long read() {
                return System.currentTimeMillis();
            }
        });
View Full Code Here

    }

    // Normal ticker behavior is to return nanoseconds elapsed since VM started.
    // This returns milliseconds since the epoch based upon ScheduleContext's internal representation of time (scheduleTime).
    public Ticker asMillisecondsSinceEpochTicker() {
        return new Ticker() {
            @Override
            public long read() {
                return ScheduleContext.this.getCurrentTimeMillis();
            }
        };
View Full Code Here

    public TaskExecutorSimulator()
    {
        executor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool(threadsNamed(getClass().getSimpleName() + "-%d")));

        taskExecutor = new TaskExecutor(24, new Ticker()
        {
            private final long start = System.nanoTime();

            @Override
            public long read()
View Full Code Here

    public TaskExecutorSimulator()
    {
        executor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool(threadsNamed(getClass().getSimpleName() + "-%d")));

        taskExecutor = new TaskExecutor(24, new Ticker()
        {
            private final long start = System.nanoTime();

            @Override
            public long read()
View Full Code Here

    public TaskExecutorSimulator()
    {
        executor = listeningDecorator(newCachedThreadPool(threadsNamed(getClass().getSimpleName() + "-%d")));

        taskExecutor = new TaskExecutor(24, new Ticker()
        {
            private final long start = System.nanoTime();

            @Override
            public long read()
View Full Code Here

    public TaskExecutorSimulator()
    {
        executor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool(threadsNamed(getClass().getSimpleName() + "-%d")));

        taskExecutor = new TaskExecutor(24, new Ticker()
        {
            private final long start = System.nanoTime();

            @Override
            public long read()
View Full Code Here

TOP

Related Classes of com.google.common.base.Ticker

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.