Example usage for java.util.concurrent TimeUnit SECONDS

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

Introduction

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

Prototype

TimeUnit SECONDS

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

Click Source Link

Document

Time unit representing one second.

Usage

From source file:com.apress.prospringintegration.customadapters.outbound.ShellMessageWritingMessageEndpointTests.java

@Test
public void testSendingMessages() throws Throwable {
    Thread.sleep(TimeUnit.SECONDS.toMillis(30));
}

From source file:de.codecentric.batch.metrics.ConsoleMetricsExporter.java

public ConsoleMetricsExporter(MetricRegistry metricRegistry) {
    reporter = ConsoleReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS).build();
}

From source file:com.thomas.domain.util.ScreenshotIt.java

/**
 *
 * This method will take the screen shot and compare it with the existing screen shot to check for accuracy
 * @param lnk_TopNav//from   w w w.j a va2s  .  c  o m
 * @throws java.io.IOException
 * @throws java.lang.InterruptedException
 */
public void Screenshot(String lnk_TopNav) throws IOException, InterruptedException {

    scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    String projectLocation = System.getProperty("user.dir");
    File file_actual = new File(
            projectLocation + "\\src\\main\\resources\\screenshots\\screenshot_" + lnk_TopNav + ".png");
    driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
    FileUtils.copyFile(scrFile, file_actual);

}

From source file:com.opengamma.language.context.DefaultGlobalContextEventHandler.java

public DefaultGlobalContextEventHandler() {
    final int cores = Runtime.getRuntime().availableProcessors();
    final ThreadPoolExecutor executor = new ThreadPoolExecutor(cores, cores, 60, TimeUnit.SECONDS,
            new LinkedBlockingQueue<Runnable>());
    executor.allowCoreThreadTimeOut(true);
    executor.setThreadFactory(new NamedThreadPoolFactory("S-Worker"));
    setSaturatingExecutor(executor);//from  w  w  w.j a va 2 s  . c om
}

From source file:com.baidu.api.client.core.ReportUtil.java

/**
 * Get the report file Url by report Id. We will check the file status internally.
 *
 * @param service  The instance of ReportService
 * @param reportId The report Id./*from   ww w . j a  v a 2s.  c  om*/
 * @param retryNum Retry times, we will check the file status every 30 seconds.
 * @return
 */
public static GetReportFileUrlResponse getReportFileUrl(ReportService service, String reportId, int retryNum) {
    LOGGER.info("We will check the file status every 30 seconds, please wait...");
    // This is the request
    GetReportStateRequest parameters = new GetReportStateRequest();
    parameters.setReportId(reportId);
    int lastStatus = -1;
    while (retryNum-- > 0) {
        try {
            TimeUnit.SECONDS.sleep(30);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        // Invoke the method.
        GetReportStateResponse ret = service.getReportState(parameters);
        // Deal with the response header, the second parameter controls whether to print the response header to
        // console
        // or not.
        ResHeader rheader = ResHeaderUtil.getResHeader(service, true);
        // If status equals zero, there is no error. Otherwise, you need to check the errors in the response header.
        if (rheader.getStatus() == 0) {
            LOGGER.info("getReportState.result\n" + ObjToStringUtil.objToString(ret));
            if (ret.getIsGenerated() == 3) {
                lastStatus = 3;
                break;
            }
        } else {
            throw new ClientBusinessException(rheader, ret);
        }
    }
    if (lastStatus == 3) {
        // This is the request
        GetReportFileUrlRequest parameters2 = new GetReportFileUrlRequest();
        parameters2.setReportId(reportId);
        // Invoke the method.
        GetReportFileUrlResponse ret = service.getReportFileUrl(parameters2);
        // Deal with the response header, the second parameter controls whether to print the response header to
        // console
        // or not.
        ResHeader rheader = ResHeaderUtil.getResHeader(service, true);
        // If status equals zero, there is no error. Otherwise, you need to check the errors in the response header.
        if (rheader.getStatus() == 0) {
            LOGGER.info("getReportFileUrl.result\n" + ObjToStringUtil.objToString(ret));
            return ret;
        } else {
            throw new ClientBusinessException(rheader, ret);
        }
    }
    throw new ClientInternalException(
            "We tried to get file for " + retryNum / 2 + " minites, but file still not ready!");
}

From source file:com.qwazr.server.BaseServer.java

default void stop() {
    getServer().close();/*from ww w  . j a v a2s. c  om*/
    if (SystemUtils.IS_OS_WINDOWS) // Gracefull shutdown on Windows
        ThreadUtils.sleep(10, TimeUnit.SECONDS);
}

From source file:com.alibaba.wasp.metrics.JmxCacheBuster.java

/**
 * For JMX to forget about all previously exported metrics.
 *//*from  w  ww. jav a 2 s.c o m*/
public static void clearJmxCache() {

    // If there are more then 100 ms before the executor will run then
    // everything should be merged.
    if (fut == null || (!fut.isDone() && fut.getDelay(TimeUnit.MILLISECONDS) > 100))
        return;

    synchronized (lock) {
        fut = MetricsExecutor.getExecutor().schedule(new JmxCacheBusterRunnable(), 5, TimeUnit.SECONDS);
    }
}

From source file:org.springside.samples.quickservice.functional.TaskRestServiceTest.java

@BeforeClass
public static void start() throws Exception {
    Future<ConfigurableApplicationContext> future = Executors.newSingleThreadExecutor()
            .submit(new Callable<ConfigurableApplicationContext>() {
                @Override/* ww  w. j av a  2s .  co  m*/
                public ConfigurableApplicationContext call() throws Exception {
                    return SpringApplication.run(QuickServiceApplication.class);
                }
            });
    context = future.get(60, TimeUnit.SECONDS);
}

From source file:org.terasoluna.gfw.common.exception.test.TestFacade.java

public String getMessage() {
    long sleepSec = currentThreadSleepSec.get().longValue();
    try {//from   w w  w.j  a v a  2s .  com
        TimeUnit.SECONDS.sleep(sleepSec);
    } catch (InterruptedException e) {
        throw new IllegalStateException(e);
    }
    return service.getMessage();
}

From source file:Main.java

public void start(String[] args) {

    barrier = new CyclicBarrier(args.length);

    for (final String site : args)
        new Thread() {
            public void run() {
                while (true) {
                    long time = timeConnect(site);
                    results.add(new Result(time, site));
                    try {
                        barrier.await(99, TimeUnit.SECONDS);
                    } catch (BrokenBarrierException e) {
                        return;
                    } catch (Exception e) {
                        return;
                    }/*w ww. j a v  a 2s  .c  om*/
                }
            }
        }.start();
}