List of usage examples for java.util.concurrent TimeUnit MILLISECONDS
TimeUnit MILLISECONDS
To view the source code for java.util.concurrent TimeUnit MILLISECONDS.
Click Source Link
From source file:rmblworx.tools.timey.SimpleCountdownTest.java
/** * @throws InterruptedException//from www. java2s . c o m * wenn dieser Thread nicht schlafen gelegt werden konnte. */ @Test public void testComputeTime() throws InterruptedException { final long time = System.currentTimeMillis() + COUNTDOWN_START; this.countdown.startCountdown(1, TimeUnit.MILLISECONDS); Thread.sleep(TIME_TO_WAIT); this.countdown.stopCountdown(); final long actualCountdownTime = this.descriptor.getMilliSeconds(); assertTrue(this.descriptor.getMilliSeconds() + "", actualCountdownTime < time); }
From source file:com.util.StringUtilities.java
/** * converts millis to [__hr __min __sec] format * * @param millis long/*from w ww. j a va 2 s.c om*/ * @return String of duration */ public static String convertLongToTime(long millis) { String duration = String.format("%02dhr %02dmin %02dsec", TimeUnit.MILLISECONDS.toHours(millis), TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)), TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis))); if (TimeUnit.MILLISECONDS.toHours(millis) == 0) { String[] split = duration.split("hr"); duration = split[1].trim(); } return duration.trim(); }
From source file:com.bodybuilding.argos.discovery.ClusterListDiscovery.java
public ClusterListDiscovery() { super(UPDATE_INTERVAL, TimeUnit.MILLISECONDS); Netty4ClientHttpRequestFactory requestFactory = new Netty4ClientHttpRequestFactory(); requestFactory.setConnectTimeout(10_000); requestFactory.setReadTimeout(10_000); this.restTemplate = new RestTemplate(requestFactory); }
From source file:org.wso2.mobile.idp.proxy.handlers.RefreshTokenHandler.java
public void obtainNewAccessToken() throws InterruptedException, ExecutionException, TimeoutException { new NetworkCallTask().execute().get(1000, TimeUnit.MILLISECONDS); }
From source file:com.liferay.mobile.android.CookieAuthenticationTest.java
@Test public void signIn() throws Exception { Session session = new SessionImpl(this.session); final JSONArray[] sites = { null }; final CountDownLatch lock = new CountDownLatch(1); CookieSignIn.signIn(session, new CookieSignIn.CookieCallback() { @Override//from w ww . ja v a 2s. c om public void onSuccess(Session session) { try { GroupService service = new GroupService(session); sites[0] = service.getUserSitesGroups(); lock.countDown(); } catch (Exception e) { onFailure(e); } } @Override public void onFailure(Exception exception) { fail(exception.getMessage()); lock.countDown(); } }); lock.await(2000, TimeUnit.MILLISECONDS); GroupServiceTest.assertUserSites(sites[0]); }
From source file:com.hellblazer.jackal.configuration.GossipSnoopConfig.java
@Bean @Primary// www . j a v a 2 s . c o m @Autowired public GossipSnoop snoop(Gossip gossip, Controller controller, Identity partitionIdentity, HeartbeatConfiguration heartbeatConfig) throws IOException { Heartbeat heartbeat = new HeartbeatState(gossip.getLocalAddress(), 0, partitionIdentity); heartbeat.setTime(0); gossip.create(controller); return new GossipSnoop(heartbeat, gossip, heartbeatConfig.heartbeatInterval, TimeUnit.MILLISECONDS); }
From source file:tachyon.metrics.sink.MetricsServlet.java
/** * Creates a MetricsServlet with a Properties and MetricRegistry. * * @param properties the properties which may contain path property. * @param registry the metric registry to register. *///from ww w . j av a2 s. co m public MetricsServlet(Properties properties, MetricRegistry registry) { mProperties = properties; mMetricsRegistry = registry; mObjectMapper = new ObjectMapper() .registerModule(new MetricsModule(TimeUnit.SECONDS, TimeUnit.MILLISECONDS, false)); }
From source file:com.almende.eve.scheduling.clock.RunnableClock.java
@Override public void run() { final List<Runnable> toRun = new ArrayList<Runnable>(); synchronized (TIMELINE) { while (!TIMELINE.isEmpty()) { final ClockEntry ce = TIMELINE.firstEntry().getValue(); final DateTime now = DateTime.now(); if (ce.getDue().isEqual(now) || ce.getDue().isBefore(now)) { TIMELINE.remove(ce);//from w ww . j av a 2 s . c o m toRun.add(ce.getCallback()); continue; } final long interval = new Interval(now, ce.getDue()).toDurationMillis(); if (interval <= 0) { continue; } if (future == null || future.getDelay(TimeUnit.MILLISECONDS) != interval) { if (future != null) { future.cancel(false); } future = SCHEDULER.schedule(this, interval, TimeUnit.MILLISECONDS); } break; } if (future == null && !TIMELINE.isEmpty()) { LOG.warning("Lost trigger, should never happen!"); } } for (Runnable run : toRun) { RUNNER.execute(run); } }
From source file:com.yahoo.gondola.container.Utils.java
private static void wait(Lock lock, Condition condition, long timeout) throws InterruptedException { if (lock != null) { condition.await(timeout, TimeUnit.MILLISECONDS); } else {/*from www .j a v a 2 s . c o m*/ Thread.sleep(timeout); } }
From source file:com.opera.core.systems.SelftestTest.java
@Before public void resetTimeout() { driver.manage().timeouts().selftestTimeout(DEFAULT_SELFTEST_TIMEOUT.in(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS); }