Package java.util.concurrent

Examples of java.util.concurrent.TimeUnit.toMillis()


                final TimeUnit unit = TimeUnit.valueOf(unitName);
                millis = TimeUnit.MILLISECONDS.convert(time, unit);
            } catch (IllegalArgumentException e) {
                try {
                    final IEEETimeUnit unit = IEEETimeUnit.valueOf(unitName);
                    millis = unit.toMillis(time);
                } catch (IllegalArgumentException e2) {
                    throw new IllegalArgumentException
                        ("Duration argument has unknown unit name: " +
                         property);
                }
View Full Code Here


        try {
            final String[] s = period.split(" ", 2);
            long duration = Math.abs(Long.parseLong(s[0]));
            TimeUnit timeUnit = TimeUnit.valueOf(s[1]);
            return timeUnit.toMillis(duration);
        } catch (RuntimeException ex) {
            throw new IllegalArgumentException(Keys.realm.ldap.syncPeriod + " must have format '<long> <TimeUnit>' where <TimeUnit> is one of 'MILLISECONDS', 'SECONDS', 'MINUTES', 'HOURS', 'DAYS'");
        }
    }
View Full Code Here

        try {
            final String[] s = period.split(" ", 2);
            long duration = Math.abs(Long.parseLong(s[0]));
            TimeUnit timeUnit = TimeUnit.valueOf(s[1]);
            return timeUnit.toMillis(duration);
        } catch (RuntimeException ex) {
            throw new IllegalArgumentException(Keys.realm.ldap.syncPeriod + " must have format '<long> <TimeUnit>' where <TimeUnit> is one of 'MILLISECONDS', 'SECONDS', 'MINUTES', 'HOURS', 'DAYS'");
        }
    }
View Full Code Here

         barrier.await(); // wait for all threads to be ready

         long timeout = warmup ? WARMUP_TIME_SECS : RUNNING_TIME_SECS;
         TimeUnit unit = TimeUnit.SECONDS;

         Thread.sleep(unit.toMillis(timeout)); // Wait for the duration of the test
         run.set(false); // Instruct tests to stop doing work
         barrier.await(2, TimeUnit.MINUTES); // wait for all threads to finish

         log.infof("[%s] All threads finished, check for exceptions", title(warmup));
         for (Future<String> future : futures) {
View Full Code Here

                    entry.setState(state);
                    entry.updateExpiry(keepalive, effectiveUnit);
                    if (this.log.isDebugEnabled()) {
                        final String s;
                        if (keepalive > 0) {
                            s = "for " + (double) effectiveUnit.toMillis(keepalive) / 1000 + " seconds";
                        } else {
                            s = "indefinitely";
                        }
                        this.log.debug("Connection " + format(entry) + " can be kept alive " + s);
                    }
View Full Code Here

  public void sleepFor(String sleepTime) throws InterruptedException {
    String[] array = sleepTime.split(" ");
    long duration = Long.parseLong(array[0]);
    TimeUnit unit = TimeUnit.valueOf(array[1].toUpperCase());
    Thread.sleep(unit.toMillis(duration));
  }

}
View Full Code Here

                summand = Long.valueOf(matcher.group(DURATION_GROUP));
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException("Number overflow for duration '" + rawStr + "'", e);
            }
           
            result = result.add(BigInteger.valueOf(timeUnit.toMillis(summand)));
        }
       
        if (result.compareTo(LONG_MAX) == 1)
            throw new IllegalArgumentException("Number overflow for duration '" + rawStr + "'");
       
View Full Code Here

          value.setReduceShuffleBytes(attempt.getCounters().get(REDUCE_SHUFFLE_BYTES));
        }
               
        key.setTime(currentUnitStart.getTimeInMillis());
       
        if ((key.getTime() + unit.toMillis(1)) >= start && start >= key.getTime())
        {
          value.setStarted(1);
        }
       
        if ((key.getTime() + unit.toMillis(1)) >= end && end >= key.getTime())
View Full Code Here

        if ((key.getTime() + unit.toMillis(1)) >= start && start >= key.getTime())
        {
          value.setStarted(1);
        }
       
        if ((key.getTime() + unit.toMillis(1)) >= end && end >= key.getTime())
        {
          value.setFinished(1);
        }
       
        currentTime = nextMillis;
View Full Code Here

    }

    @Test
    public void testLastAccessTime() throws InterruptedException {
        final TimeUnit timeUnit = TimeUnit.NANOSECONDS;
        final long startTime = timeUnit.toMillis(System.nanoTime());

        HazelcastInstance h1 = createHazelcastInstance();
        IMap<String, String> map1 = h1.getMap(name);

        String key = "key";
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.