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.wudaosoft.net.httpclient.IdleConnectionMonitorThread.java

@Override
public void run() {
    try {// w  w  w .j a  v a  2 s  .  c  o m
        while (!shutdown) {
            synchronized (this) {
                wait(18000);
                // Close expired connections
                connMgr.closeExpiredConnections();
                // Optionally, close connections
                // that have been idle longer than 30 sec
                connMgr.closeIdleConnections(30, TimeUnit.SECONDS);
            }
        }
    } catch (InterruptedException ex) {
        // terminate
    }
}

From source file:org.sbs.goodcrawler.fetcher.IdleConnectionMonitorThread.java

@Override
public void run() {
    try {//from  w w  w . ja va2  s.c  o m
        while (!shutdown) {
            synchronized (this) {
                wait(5000);
                // Close expired connections
                connMgr.closeExpiredConnections();
                // Optionally, close connections
                // that have been idle longer than 30 sec
                connMgr.closeIdleConnections(30, TimeUnit.SECONDS);
                System.out.println("#getAvailable=" + connMgr.getTotalStats().getAvailable());
            }
        }
    } catch (InterruptedException ex) {
        // terminate
    }
}

From source file:com.autonomousturk.crawler.fetcher.IdleConnectionMonitorThread.java

@Override
public void run() {
    try {/*  w  w w  . j  av  a2  s.co  m*/
        while (!shutdown) {
            synchronized (this) {
                wait(5000);
                // Close expired connections
                connMgr.closeExpiredConnections();
                // Optionally, close connections
                // that have been idle longer than 30 sec
                connMgr.closeIdleConnections(30, TimeUnit.SECONDS);
            }
        }
    } catch (InterruptedException ex) {
        // terminate
    }
}

From source file:com.mpush.test.client.ConnClientTestMain.java

private static void testConnClient(int count, String userPrefix, int printDelay, boolean sync)
        throws Exception {
    Logs.init();/*w  w w  . j a  v a  2  s. co m*/
    ConnClientBoot boot = new ConnClientBoot();
    boot.start().get();

    List<ServiceNode> serverList = boot.getServers();
    if (serverList.isEmpty()) {
        boot.stop();
        System.out.println("no mpush server.");
        return;
    }

    if (printDelay > 0) {
        Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(
                () -> System.err.println(ConnClientChannelHandler.STATISTICS), 3, printDelay, TimeUnit.SECONDS);
    }

    for (int i = 0; i < count; i++) {
        String clientVersion = "1.0." + i;
        String osName = "android";
        String osVersion = "1.0.1";
        String userId = userPrefix + "user-" + i;
        String deviceId = userPrefix + "test-device-id-" + i;
        byte[] clientKey = CipherBox.I.randomAESKey();
        byte[] iv = CipherBox.I.randomAESIV();

        ClientConfig config = new ClientConfig();
        config.setClientKey(clientKey);
        config.setIv(iv);
        config.setClientVersion(clientVersion);
        config.setDeviceId(deviceId);
        config.setOsName(osName);
        config.setOsVersion(osVersion);
        config.setUserId(userId);

        int L = serverList.size();
        int index = (int) ((Math.random() % L) * L);
        ServiceNode node = serverList.get(index);

        ChannelFuture future = boot.connect(node.getAttr(ATTR_PUBLIC_IP), node.getPort(), config);
        if (sync)
            future.awaitUninterruptibly();
    }
}

From source file:org.ovirt.engine.sdk.web.IdleConnectionMonitorThread.java

@Override
public void run() {
    try {/*from ww w. j av a  2s  .com*/
        while (!shutdown) {
            synchronized (this) {
                wait(this.waitTtl);
                connMgr.closeExpiredConnections();
                connMgr.closeIdleConnections(this.closeTtl, TimeUnit.SECONDS);
            }
        }
    } catch (InterruptedException ex) {
        // terminate
    }
}

From source file:com.heliosapm.opentsdb.server.MemoryReporter.java

/**
 * Creates a new MemoryReporter/*from   w ww  .  j  a va  2  s .  co m*/
 * @param frequency The frequency in seconds of the memory reporting
 */
public MemoryReporter(int frequency) {
    super("MemoryReporter-" + frequency);
    setDaemon(true);
    sleepTime = TimeUnit.MILLISECONDS.convert(frequency, TimeUnit.SECONDS);
}

From source file:org.zhangmz.pickles.helper.AdminMainHelper.java

@PostConstruct
public void init() {
    logger.debug("?? " + loginTimeoutSecs);
    // CacheBuilder.newBuilder().maximumSize(1000).expireAfterWrite(loginTimeoutSecs, TimeUnit.SECONDS).build();
    mainInfos = CacheBuilder.newBuilder().maximumSize(1000)
            .expireAfterAccess(loginTimeoutSecs, TimeUnit.SECONDS).build();
}

From source file:br.com.jbugbrasil.bot.telegram.api.httpclient.BotCloseableHttpClient.java

@Override
public CloseableHttpClient get() {
    return HttpClientBuilder.create().setSSLHostnameVerifier(new NoopHostnameVerifier())
            .setConnectionTimeToLive(70, TimeUnit.SECONDS).setMaxConnTotal(100).build();
}

From source file:com.nanocrawler.fetcher.IdleConnectionMonitorThread.java

@Override
// Perioidical checker of closing idle connections
public void run() {
    try {//from   w  ww  . j  a va  2s.  c o  m
        while (!shutdown) {
            synchronized (this) {
                wait(5000);
                connMgr.closeExpiredConnections();
                connMgr.closeIdleConnections(30, TimeUnit.SECONDS);
            }
        }
    } catch (InterruptedException ex) {
        // terminate
    }
}

From source file:com.lakeside.download.http.HttpConnectionMonitor.java

@Override
public void run() {
    try {/* w  w w  .  j a  v  a  2 s . c o m*/
        while (!shutdown) {
            synchronized (this) {
                wait(10000);
                // Close expired connections
                connMgr.closeExpiredConnections();
                // Optionally, close connections
                // that have been idle longer than 30 sec
                connMgr.closeIdleConnections(30, TimeUnit.SECONDS);
            }
        }
    } catch (InterruptedException ex) {
        // terminate
    }
}