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:edu.xiyou.fruits.WebCrawler.scheduler.BloomScheduler.java

@Override
public String takeTasks() throws InterruptedException {
    takeTaskCount.incrementAndGet();//from   w w w .j a  v  a 2  s .  c  o  m
    String url = queue.poll(60, TimeUnit.SECONDS);
    return url;
}

From source file:io.pivotal.cf.servicebroker.KafkaClientTest.java

@Test
public void testCreateAndDeleteTopic() throws Exception {
    String topicName = "topic" + System.currentTimeMillis();
    assertFalse(client.listTopics().contains(topicName));

    client.createTopic(topicName);/* ww w. ja va 2  s.  c  o m*/
    TimeUnit.SECONDS.sleep(3);
    assertTrue(client.listTopics().contains(topicName));

    client.deleteTopic(topicName);
    TimeUnit.SECONDS.sleep(3);
    assertFalse(client.listTopics().contains(topicName));
}

From source file:org.apache.camel.component.netty.MultipleCodecsSpringTest.java

@Test
public void canSupplyMultipleCodecsToEndpointPipeline() throws Exception {
    String poem = new Poetry().getPoem();
    MockEndpoint mock = getMockEndpoint("mock:multiple-codec");
    mock.expectedBodiesReceived(poem);/*  w  ww . ja va2  s. co  m*/
    sendBody("direct:multiple-codec", poem);
    mock.await(1, TimeUnit.SECONDS);
    mock.assertIsSatisfied();
}

From source file:io.orchestrate.client.integration.FetchTest.java

private <T> KvObject<T> result(final KvFetchOperation<T> kvFetchOp)
        throws InterruptedException, ExecutionException, TimeoutException {
    OrchestrateFuture<KvObject<T>> future = client().execute(kvFetchOp);
    return future.get(3, TimeUnit.SECONDS);
}

From source file:com.pinterest.rocksplicator.controller.WorkerPoolTest.java

@Test
public void testAssignSingleTask() throws Exception {
    Semaphore idleWorkersSemaphore = new Semaphore(0);
    ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS,
            new ArrayBlockingQueue<Runnable>(1));
    WorkerPool workerPool = new WorkerPool(threadPoolExecutor, idleWorkersSemaphore, new TaskQueue() {
    });/* ww w.j  a v a  2  s. c o m*/
    workerPool.assignTask(getSleepIncrementTask());
    Thread.sleep(2000);
    Assert.assertEquals(1, SleepIncrementTask.executionCounter.intValue());
    workerPool.assignTask(getSleepIncrementTask());
    Thread.sleep(2000);
    Assert.assertEquals(2, SleepIncrementTask.executionCounter.intValue());
    Assert.assertEquals(2, idleWorkersSemaphore.availablePermits());
}

From source file:org.fcrepo.client.integration.AbstractResourceIT.java

protected AbstractResourceIT() {
    connectionManager.setMaxTotal(Integer.MAX_VALUE);
    connectionManager.setDefaultMaxPerRoute(20);
    connectionManager.closeIdleConnections(3, TimeUnit.SECONDS);
}

From source file:io.vertx.stack.StackResolutionTest.java

@Before
public void setUp() {
    FileUtils.delete(root);
    Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> !root.exists());
}

From source file:com.qpark.eip.core.spring.statistics.impl.AppUserStatisticsChannelAdapter.java

/**
 * @param millis//from w ww .  java 2  s  . c o m
 * @return the duration in 000:00:00.000 format.
 */
static String getDuration(final long millis) {
    String hmss = String.format("%03d:%02d:%02d.%03d", 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)),
            TimeUnit.MILLISECONDS.toMillis(millis)
                    - TimeUnit.SECONDS.toMillis(TimeUnit.MILLISECONDS.toSeconds(millis)));
    return hmss;
}

From source file:com.alibaba.otter.manager.biz.common.alarm.AbstractAlarmService.java

public void sendAlarm(AlarmMessage data) {
    try {/*from   w  w  w .jav a2 s .  c o  m*/
        if (!queue.offer(data, 2, TimeUnit.SECONDS)) {
            logger.error(String.format("alarm sent to queue error : [%s]", data.toString()));
        }
    } catch (Exception e) {
        logger.error(String.format("send alarm [%s] to drgoon agent error!", data.toString()), e);
    }
}

From source file:com.omade.monitor.ClientApplication.java

public static void executeFixedRate() {
    ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
    executor.scheduleAtFixedRate(/* w  w  w. j a v a2  s .  c om*/
            new DoTask(config.getProperty("server.url"), config.getProperty("server.port")), 0, 1,
            TimeUnit.SECONDS);
}