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:costumetrade.common.verify.TempTokenServce.java

@Override
public String get() {

    String account = TEMP_TOKEN_PREFIX + RandomStringUtils.random(6);
    String token = jwtService.tokenFor(account);
    LoginInfo loginInfo = new LoginInfo();
    loginInfo.setAccount(account);/*w  w w  .j a v  a  2 s .c  o m*/
    redisTemplate.opsForValue().set(token, loginInfo, 10, TimeUnit.SECONDS);
    return token;
}

From source file:de.slub.fedora.jms.MessageMapper.java

public static List<IndexJob> map(Message message) throws Exception {
    ArrayList<IndexJob> indexJobs = new ArrayList<>();
    String pid = message.getStringProperty("pid");
    String dsid = extractDsId(((TextMessage) message).getText());
    String methodName = message.getStringProperty("methodName");
    switch (methodName) {
    case "ingest":
        indexJobs.add(new ObjectIndexJob(CREATE, pid, 1, TimeUnit.SECONDS));
        break;//from  w ww . j  ava 2 s  .  co  m
    case "addDatastream":
        indexJobs.add(new DatastreamIndexJob(CREATE, pid, dsid, 1, TimeUnit.SECONDS));
        break;
    case "purgeObject":
        indexJobs.add(new ObjectIndexJob(DELETE, pid));
        break;
    case "purgeDatastream":
        indexJobs.add(new DatastreamIndexJob(DELETE, pid, dsid));
        break;
    case "modifyObject":
        indexJobs.add(new ObjectIndexJob(UPDATE, pid, 5, TimeUnit.SECONDS));
        break;
    case "modifyDatastreamByReference":
    case "modifyDatastreamByValue":
    case "setDatastreamState":
        indexJobs.add(new ObjectIndexJob(UPDATE, pid, dsid, 1, TimeUnit.SECONDS));
        indexJobs.add(new DatastreamIndexJob(UPDATE, pid, dsid, 5, TimeUnit.SECONDS));
        break;
    }
    return indexJobs;
}

From source file:be.bittich.quote.config.CacheConfigForTest.java

@Bean
public CacheManager cacheManager() {
    GuavaCacheManager cacheManager = new GuavaCacheManager();
    cacheManager/*from  w  w  w . j ava2  s .  c om*/
            .setCacheBuilder(CacheBuilder.newBuilder().maximumSize(1000).expireAfterWrite(5, TimeUnit.SECONDS));
    return cacheManager;
}

From source file:com.hazelcast.simulator.worker.metronome.SimpleMetronome.java

/**
 * Creates a {@link Metronome} instance with a fixed frequency in Hz.
 *
 * If the frequency is 0 Hz the method {@link #waitForNext()} will have no delay.
 *
 * @param frequency frequency//from  w  w  w  .j a va  2 s . co  m
 * @return a {@link Metronome} instance
 */
public static Metronome withFixedFrequency(float frequency) {
    if (frequency == 0) {
        return EMPTY_METRONOME;
    }

    long intervalNanos = round((double) TimeUnit.SECONDS.toNanos(1) / frequency);
    return new SimpleMetronome(intervalNanos);
}

From source file:com.epam.ta.reportportal.database.search.ModifiableQueryBuilder.java

/**
 * Query for entities modified later than provided time period
 * /*w  ww  .j a  va 2 s. com*/
 * @param period
 * @return
 */
public static Query findModifiedLaterThanPeriod(final Time period) {
    return findModifiedLaterThan(
            DateUtils.addSeconds(Calendar.getInstance().getTime(), (int) (-1 * period.in(TimeUnit.SECONDS))));
}

From source file:com.fatwire.dta.sscrawler.RenderingThreadPool.java

public RenderingThreadPool(final int threadSize) {
    super(threadSize, threadSize, 60, TimeUnit.SECONDS, new PriorityBlockingQueue<Runnable>(5000));

}

From source file:com.manning.siia.pipeline.Counter.java

public int getCount() throws InterruptedException {
    latch.await(30, TimeUnit.SECONDS);
    return count;
}

From source file:costumetrade.common.akka.ActorSystemContext.java

@Override
public void destroy() throws Exception {
    system.awaitTermination(Duration.create(10, TimeUnit.SECONDS));
}

From source file:com.liferay.petra.json.web.service.client.internal.IdleConnectionMonitorThread.java

@Override
public void run() {
    try {/*from   w ww  .  j a v a 2 s . c o  m*/
        while (!_shutdown) {
            synchronized (this) {
                wait(5000);

                _nHttpClientConnectionManager.closeExpiredConnections();

                _nHttpClientConnectionManager.closeIdleConnections(30, TimeUnit.SECONDS);
            }
        }
    } catch (InterruptedException ie) {
    }
}

From source file:com.google.cloud.runtime.jetty.util.HttpUrlUtil.java

/**
 * Wait for a server to be "up" by requesting a specific GET resource
 * that should be returned in status code 200.
 * <p>// w w  w.j a  va  2  s. co m
 * This will attempt a check for server up.
 * If any result other then response code 200 occurs, then
 * a 2s delay is performed until the next test.
 * Up to the duration/timeunit specified.
 * </p>
 *
 * @param uri      the URI to request
 * @param duration the time duration to wait for server up
 * @param unit     the time unit to wait for server up
 */
public static void waitForServerUp(URI uri, int duration, TimeUnit unit) {
    System.err.println("Waiting for server up: " + uri);
    boolean waiting = true;
    long expiration = System.currentTimeMillis() + unit.toMillis(duration);
    while (waiting && System.currentTimeMillis() < expiration) {
        try {
            System.out.print(".");
            HttpURLConnection http = openTo(uri);
            int statusCode = http.getResponseCode();
            if (statusCode != HttpURLConnection.HTTP_OK) {
                log.log(Level.FINER, "Waiting 2s for next attempt");
                TimeUnit.SECONDS.sleep(2);
            } else {
                waiting = false;
            }
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException("Invalid URI: " + uri.toString());
        } catch (IOException e) {
            log.log(Level.FINEST, "Ignoring IOException", e);
        } catch (InterruptedException ignore) {
            // ignore
        }
    }
    System.err.println();
    System.err.println("Server seems to be up.");
}