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:pl.bristleback.server.bristle.message.akka.SingleThreadMessageDispatcher.java
@Override public void dispatchMessages() throws Exception { WebsocketMessage message = messages.poll(DELAY, TimeUnit.MILLISECONDS); if (message != null) { log.debug("Sending a server message: " + message.getContent()); if (CollectionUtils.isEmpty(message.getRecipients())) { log.debug("Empty or null recipients collection: " + message.getRecipients()); return; }// ww w . j a va 2 s . c o m sendMessage(message); } }
From source file:reconf.infra.http.layer.SimpleHttpClient.java
private static RequestConfig createBasicHttpParams(long timeout, TimeUnit timeUnit) { int timemillis = (int) TimeUnit.MILLISECONDS.convert(timeout, timeUnit); return RequestConfig.custom().setCookieSpec(CookieSpecs.IGNORE_COOKIES) .setStaleConnectionCheckEnabled(false).setConnectTimeout(timemillis).setSocketTimeout(timemillis) .setConnectionRequestTimeout(timemillis).build(); }
From source file:org.esigate.extension.monitoring.Metric.java
@Override public void init(Driver d, Properties properties) { this.driver = d; LOG.debug("Initialize Metric"); driver.getEventManager().register(EventManager.EVENT_PROXY_POST, this); driver.getEventManager().register(EventManager.EVENT_FETCH_POST, this); reporter = Slf4jReporter.forRegistry(this.metric).outputTo(LOG).convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS).build(); reporter.start(PARAM_METRIC_PERIOD.getValue(properties), TimeUnit.SECONDS); }
From source file:org.apache.jmeter.protocol.http.sampler.MeasuringConnectionManager.java
public MeasuringConnectionManager(SchemeRegistry schemeRegistry, DnsResolver resolver, int timeToLiveMs, int validateAfterInactivityMs) { super(schemeRegistry, timeToLiveMs, TimeUnit.MILLISECONDS, resolver, validateAfterInactivityMs); }
From source file:com.xiaomi.linden.common.util.FileChangeWatcher.java
@Override public void run() { try {//from w w w .j a v a2 s. c o m watcher = FileSystems.getDefault().newWatchService(); Path path = new File(absolutePath).toPath().getParent(); String fileWatched = FilenameUtils.getName(absolutePath); path.register(watcher, new WatchEvent.Kind[] { StandardWatchEventKinds.ENTRY_MODIFY }, SensitivityWatchEventModifier.HIGH); LOGGER.info("File watcher start to watch {}", absolutePath); while (isAlive()) { try { Thread.sleep(interval); WatchKey key = watcher.poll(1000l, TimeUnit.MILLISECONDS); if (key == null) { continue; } List<WatchEvent<?>> events = key.pollEvents(); for (WatchEvent<?> event : events) { if (event.kind() == StandardWatchEventKinds.ENTRY_MODIFY) { String file = event.context().toString(); if (fileWatched.equals(file)) { doOnChange(); } } } if (!key.reset()) { LOGGER.info("File watcher key not valid."); } } catch (InterruptedException e) { LOGGER.error("File watcher thread exit!"); break; } } } catch (Throwable e) { LOGGER.error("File watcher error {}", Throwables.getStackTraceAsString(e)); } }
From source file:org.cloudfoundry.identity.uaa.login.DefaultAutologinCodeStore.java
@Override public Authentication getUser(String code) { flush();//from w ww.ja v a 2s. c o m TokenExpiry value = codes.remove(code); if (value == null) { logger.info("Could not redeem code: " + code); return null; } if (value.getDelay(TimeUnit.MILLISECONDS) <= 0) { logger.info("Code expired: " + code); expiryQueue.remove(value); return null; } if (expireCodeWhenUsed) { expiryQueue.remove(value); } else { codes.put(code, value); } logger.info("Redeemed code: " + code); return value.getUser(); }
From source file:com.fns.xlator.monitoring.MonitoringSupport.java
@Bean public StatsDReporter statsDReporter() { // @formatter:off return StatsDReporter.forRegistry(metricRegistry) .prefixedWith(String.format("%s.%s", statsdSettings.getApplicationName(), statsdSettings.getApplicationHostname())) .convertDurationsTo(TimeUnit.MILLISECONDS).convertRatesTo(TimeUnit.SECONDS).filter(MetricFilter.ALL) .build(statsdSettings.getHostname(), statsdSettings.getPort()); // @formatter:on }
From source file:com.synapticpath.naica.selenium.SeleniumUtils.java
/** * Call this method to find a WebElement. Several parameters are supported. * //from w ww. j ava 2s . c o m * @param elementSelector * Will be used as primary criteria to find an element. * @param visible * When not null, will be evaluated for visibility on page. That is, the desired element must * also be visible when true, or invisible when false. * @param withText * if specified, the element.getText must match also. * @param timeout * positive number of seconds to wait * @return the {@link WebElement} when found, null if not found in timeout reached first. */ public static WebElement findElementWithTimeout(final SeleniumSelector elementSelector, final Boolean visible, final String withText, int timeout) { final WebDriver driver = SeleniumTestContext.getInstance().getDriver(); FluentWait<WebDriver> wait = new FluentWait<WebDriver>(driver) .withTimeout(timeout > -1 ? timeout : MAX_WAIT, TimeUnit.SECONDS) .pollingEvery(POLL_INTERVAL_MILLIS, TimeUnit.MILLISECONDS).ignoring(NoSuchElementException.class) .ignoring(TimeoutException.class); try { return wait.until((WebDriver d) -> { WebElement e = d.findElement(elementSelector.toBySelector()); if (e != null && (withText == null || e.getText().contains(withText)) && (visible == null || visible && e.isDisplayed() || !visible && !e.isDisplayed())) { return e; } return null; }); } catch (TimeoutException te) { logger.severe(format("Element selected by %s, visible:%s, withText:%s was not found in time.", elementSelector, visible, withText)); } return null; }
From source file:com.facebook.infrastructure.service.QuorumResponseHandler.java
public T get() throws TimeoutException, DigestMismatchException, InterruptedException { long startTime = System.currentTimeMillis(); lock_.lock();/*from ww w .j av a2 s . com*/ try { boolean bVal = true; if (!done_.get()) { bVal = condition_.await(DatabaseDescriptor.getRpcTimeout(), TimeUnit.MILLISECONDS); } if (!bVal && !done_.get()) { throw new TimeoutException("Operation timed out - received only " + responses_.size() + " responses from [" + StringUtils.join(responders(), ", ") + "]"); } } finally { lock_.unlock(); for (Message response : responses_) { MessagingService.removeRegisteredCallback(response.getMessageId()); } } logger_.debug("QuorumResponseHandler: " + (System.currentTimeMillis() - startTime) + " ms; " + " responses from [" + StringUtils.join(responders(), ", ") + "]"); return responseResolver_.resolve(responses_); }
From source file:io.s4.core.WindowingPE.java
/** * Constructor for time-based slots. The abstract method * {@link #addPeriodicSlot()} is called periodically. * //from ww w .j av a 2s.c om * @param app * the application * @param slotDuration * the slot duration in timeUnit * @param timeUnit * the unit of time * @param numSlots * the number of slots to be stored */ public WindowingPE(App app, long slotDuration, TimeUnit timeUnit, int numSlots) { super(app); this.numSlots = numSlots; if (slotDuration > 0l) { slotDurationInMilliseconds = TimeUnit.MILLISECONDS.convert(slotDuration, timeUnit); timer = new Timer(); timer.schedule(new SlotTask(), slotDurationInMilliseconds, slotDurationInMilliseconds); logger.trace("TIMER: " + slotDurationInMilliseconds); } else { slotDurationInMilliseconds = 0; timer = null; } }