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:cn.guoyukun.spring.utils.fetch.RemoteFileFetcher.java
private RemoteFileFetcher(String url, int reloadInterval, FileChangeListener listener) { this.connectTimeout = 1000; this.readTimeout = 1000; this.url = url; this.listener = listener; if (reloadInterval > 0) { scheduledExecutorService.scheduleWithFixedDelay(new Runnable() { public void run() { RemoteFileFetcher.this.doFetch(); }/*from ww w . j a v a 2s . c om*/ }, reloadInterval, reloadInterval, TimeUnit.MILLISECONDS); } doFetch(); }
From source file:com.heelenyc.im.client.handler.ClientHeartBeatReqHandler.java
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { Message message = (Message) msg;// ww w . ja v a 2 s. c o m // ????? if (message.getHeader() != null && message.getHeader().getType() == MessageType.LOGIN_RESP.value()) { heartBeat = ctx.executor().scheduleAtFixedRate(new ClientHeartBeatReqHandler.HeartBeatTask(ctx), 0, Constans.HEARTBEAT_PERIOD_INMS, TimeUnit.MILLISECONDS); } else if (message.getHeader() != null && message.getHeader().getType() == MessageType.HEARTBEAT_RESP.value()) { logger.info("Client receive server heart beat message : ---> " + message); } else ctx.fireChannelRead(msg); }
From source file:module.d.SearchController.java
@RequestMapping("/search") public ModelAndView searchItemPage(String searchFormName) { System.out.println("Invoking controller: " + searchFormName); ModelAndView mv = new ModelAndView(); mv.setViewName("search"); // String searchForm = this.searchFormGateway.renderSearchUiForm(searchFormName); String searchForm = null;// w ww.ja v a 2 s . c om try { Future<String> future = null; try { future = this.searchFormGateway.renderSearchUiForm(searchFormName); searchForm = future.get(1000, TimeUnit.MILLISECONDS); } catch (Exception e) { future = this.searchFormGateway.renderSearchUiForm(searchFormName); searchForm = future.get(1000, TimeUnit.MILLISECONDS); } } catch (Exception e) { searchForm = "<b>'Search Item' form page is currently unavailable, please try again later</b>"; } mv.addObject("searchForm", searchForm); return mv; }
From source file:com.consol.citrus.samples.docker.AbstractDockerIT.java
@BeforeSuite(alwaysRun = true) public void checkDockerEnvironment() { try {/*w ww . jav a 2s .c o m*/ Future<Boolean> future = Executors.newSingleThreadExecutor().submit(() -> { dockerClient.getEndpointConfiguration().getDockerClient().pingCmd().exec(); return true; }); future.get(5000, TimeUnit.MILLISECONDS); connected = true; } catch (Exception e) { log.warn("Skipping Docker test execution as no proper Docker environment is available on host system!", e); } }
From source file:client.PerfRequestSyncInterceptor.java
@Override public ClientHttpResponse intercept(HttpRequest hr, byte[] bytes, ClientHttpRequestExecution chre) throws IOException { stopwatch.start();/*from w w w . ja v a 2 s .c om*/ long time = System.currentTimeMillis(); ClientHttpResponse response = chre.execute(hr, bytes); stopwatch.stop(); LOG.info(hr.getMethod() + "@ uri=" + hr.getURI() + " payload(kB)= " + (bytes.length / 1024) + ", response_time=" + stopwatch.elapsedTime(TimeUnit.MILLISECONDS) + ", response_code=" + response.getStatusCode().value()); return response; }
From source file:com.springer.omelet.driver.DriverUtility.java
/*** * Generic waitFor Function which waits for condition to be successful else * return null//w ww . j a v a 2 s . c o m * * @param expectedCondition * :ExpectedCondition<T> * @param driver * :WebDriver * @param timeout * in seconds * @return <T> or null */ public static <T> T waitFor(ExpectedCondition<T> expectedCondition, WebDriver driver, int timeOutInSeconds) { Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); try { T returnValue = new WebDriverWait(driver, timeOutInSeconds).pollingEvery(500, TimeUnit.MILLISECONDS) .until(expectedCondition); return returnValue; } catch (TimeoutException e) { LOGGER.error(e); return null; } finally { driver.manage().timeouts().implicitlyWait(Driver.getBrowserConf().getDriverTimeOut(), TimeUnit.SECONDS); stopwatch.stop(); LOGGER.debug("Time Taken for waitFor method for Expected Condition is:" + stopwatch.elapsedTime(TimeUnit.SECONDS)); } }
From source file:com.phei.netty.protocol.netty.client.HeartBeatReqHandler.java
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { NettyMessage message = (NettyMessage) msg; // ?????/*w ww .j a v a 2 s. c om*/ if (message.getHeader() != null && message.getHeader().getType() == MessageType.LOGIN_RESP.value()) { heartBeat = ctx.executor().scheduleAtFixedRate(new HeartBeatReqHandler.HeartBeatTask(ctx), 0, 5000, TimeUnit.MILLISECONDS); } else if (message.getHeader() != null && message.getHeader().getType() == MessageType.HEARTBEAT_RESP.value()) { LOG.info("Client receive server heart beat message : ---> " + message); } else ctx.fireChannelRead(msg); }
From source file:fr.keemto.scheduling.ScheduledTaskIT.java
@Test public void shouldExecuteFetcherAsychronouslyWithDelay() throws Exception { CountDownLatch latch = new CountDownLatch(10); Task countDownTask = new CountDownTask(latch); scheduler.scheduleTask(countDownTask); latch.await(2000, TimeUnit.MILLISECONDS); assertThat(latch.getCount(), equalTo((long) 0)); }
From source file:com.fns.xlator.monitoring.StatsdRunner.java
@Override public void run(String... strings) throws Exception { // JVM metrics ala Dropwizard metrics-jvm metricRegistry.registerAll(new MemoryUsageGaugeSet()); metricRegistry.registerAll(new ThreadStatesGaugeSet()); metricRegistry.registerAll(new GarbageCollectorMetricSet()); metricRegistry.registerAll(new ClassLoadingGaugeSet()); // start collecting w/ statsd via ReadyTalk client reporter.start(statsdSettings.getPublishingIntervalInMillis(), TimeUnit.MILLISECONDS); }