Example usage for java.util.concurrent TimeUnit MILLISECONDS

List of usage examples for java.util.concurrent TimeUnit MILLISECONDS

Introduction

In this page you can find the example usage for java.util.concurrent TimeUnit MILLISECONDS.

Prototype

TimeUnit MILLISECONDS

To view the source code for java.util.concurrent TimeUnit MILLISECONDS.

Click Source Link

Document

Time unit representing one thousandth of a second.

Usage

From source file:com.cloudera.oryx.common.math.SolverLoadIT.java

@Test
public void testLoad() {
    RealMatrix symmetric = randomSymmetricMatrix(500);
    Stopwatch stopwatch = new Stopwatch().start();
    int iterations = 100;
    for (int i = 0; i < iterations; i++) {
        MatrixUtils.getSolver(symmetric);
    }/*from ww w .j a  v  a 2s .c  o m*/
    stopwatch.stop();
    // long elapsedMS = stopwatch.elapsed(TimeUnit.MILLISECONDS);
    long elapsedMS = stopwatch.elapsedTime(TimeUnit.MILLISECONDS);
    log.info("{}ms elapsed for {} iterations", elapsedMS, iterations);
    assertTrue(elapsedMS < 600 * iterations);
}

From source file:com.arpnetworking.metrics.generator.metric.GaussianMetricGenerator.java

/**
 * {@inheritDoc}//from   www.j  av  a 2  s .  co  m
 */
@Override
public void generate(final Metrics metrics) {
    metrics.setTimer(_nameGenerator.getName(), Math.round(_generator.nextGaussian(_mu, _sigma)),
            TimeUnit.MILLISECONDS);
}

From source file:com.willwinder.universalgcodesender.utils.ThreadHelperTest.java

@Test
public void waitUntilWhenTrueShouldReturnOk() throws TimeoutException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();// w w  w. j  ava  2s  . c  o m
    ThreadHelper.waitUntil(() -> true, 200, TimeUnit.MILLISECONDS);
    stopWatch.stop();
    assertTrue(stopWatch.getTime() < 200);
}

From source file:com.example.common.LibratoMetricWriter.java

public LibratoMetricWriter(HttpPoster poster, LibratoProperties librato) {
    this.poster = poster;
    this.librato = librato;
    this.batch = new LibratoBatch(librato.getBatchSize(), Sanitizer.NO_OP, librato.getTimeoutMillis(),
            TimeUnit.MILLISECONDS, librato.getAgent(), poster);
}

From source file:com.worldline.easycukes.selenium.utils.SeleniumHelper.java

/**
 * @param driver//from   w  ww.j  a  v  a2  s . c  om
 * @param by
 * @return
 */
public static WebElement waitForElementToBePresent(@NonNull final WebDriver driver, @NonNull final By by) {
    final FluentWait<WebDriver> wait = new FluentWait<>(driver)
            .withTimeout(WAITING_TIME_OUT_IN_SECONDS, TimeUnit.SECONDS)
            .pollingEvery(POLLING_INTERVAL_IN_MILLIS, TimeUnit.MILLISECONDS)
            .ignoring(NoSuchElementException.class);
    return wait.until(new ExpectedCondition<WebElement>() {
        @Override
        public WebElement apply(WebDriver webDriver) {
            try {
                if (webDriver.findElement(by).isDisplayed())
                    return webDriver.findElement(by);
                return null;
            } catch (final ElementNotVisibleException e) {
                return null;
            }
        }
    });
}

From source file:org.commonjava.aprox.subsys.http.AproxHttpConnectionManager.java

@Override
public void releaseConnection(final HttpClientConnection conn, final Object state, final long keepalive,
        final TimeUnit tunit) {
    logger.info("RELEASE: {}, keepalive: {}, tunit: {}", conn, keepalive, tunit);

    super.releaseConnection(conn, state, 0, TimeUnit.MILLISECONDS);
    if (closeConnectionsOnRelease) {
        try {/*from   w  w  w . j a v a  2 s.com*/
            logger.info("CLOSING: {}", conn);
            conn.close();
        } catch (final IOException e) {
            logger.debug("I/O error closing connection", e);
        }
    }
}

From source file:fr.aliasource.index.core.AbstractCrawler.java

@Override
public void startFetch() {
    if (logger.isDebugEnabled()) {
        logger.debug("incremental fetch");
    }//from  w  ww  .java2s .  c  o m

    int i = 0;
    String id = null;
    do {
        try {
            id = toCrawl.poll(500, TimeUnit.MILLISECONDS);
        } catch (InterruptedException e) {
        }
        if (id != null) {
            Map<String, String> data = fetchData(id);
            listener.dataFetched(getType(), data);
            i++;
        }
    } while (id != null);
    listener.crawlComplete(getType(), i > 0);
}

From source file:fr.keemto.spikes.ScheduledTaskRegistrarIT.java

@Test
@Ignore// www  . ja va2 s  . c om
public void registerAScheduledTaskWithRegistrar() throws Exception {
    CountDownTask task = new CountDownTask();
    Map<Runnable, Long> fixedDelayTasks = new HashMap<Runnable, Long>();
    fixedDelayTasks.put(task, new Long(100));
    registrar.setFixedDelayTasks(fixedDelayTasks);

    registrar.afterPropertiesSet();

    latch.await(2000, TimeUnit.MILLISECONDS);

    assertThat(latch.getCount(), equalTo((long) 0));
}

From source file:io.restassured.module.mockmvc.AsyncTest.java

@Test
public void can_supply_string_as_body_for_async_post_with_config_in_given() {
    RestAssuredMockMvc.given().config(newConfig().asyncConfig(withTimeout(10, TimeUnit.MILLISECONDS)))
            .body("a string").when().async().post("/stringBody").then().body(equalTo("a string"));
}

From source file:biospectra.utils.BlockingExecutor.java

/**
 * Creates a BlockingExecutor which will block and prevent further
 * submission to the pool when the specified queue size has been reached.
 *
 * @param poolSize the number of the threads in the pool
 * @param queueSize the size of the queue
 *//*ww w  .  j  av  a2 s  . c o m*/
public BlockingExecutor(final int poolSize, final int queueSize) {
    super(poolSize, poolSize, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());

    // the semaphore is bounding both the number of tasks currently executing
    // and those queued up
    semaphore = new Semaphore(poolSize + queueSize);
}