List of usage examples for java.util.concurrent TimeUnit SECONDS
TimeUnit SECONDS
To view the source code for java.util.concurrent TimeUnit SECONDS.
Click Source Link
From source file:com.pinterest.pinlater.backends.redis.RedisPools.java
public RedisPools(PropertiesConfiguration configuration, String host, int port, boolean dequeueOnly) { int numGeneralConnections = configuration.getInt("BACKEND_CONNECTIONS_PER_SHARD"); int generalSocketTimeoutMillis = (int) TimeUnit.SECONDS .toMillis(configuration.getInt("BACKEND_SOCKET_TIMEOUT_SECONDS")); int numMonitorConnections = configuration.getInt("MONITOR_CONNECTIONS_PER_SHARD", 3); int monitorSocketTimeoutMillis = (int) TimeUnit.SECONDS .toMillis(configuration.getInt("MONITOR_SOCKET_TIMEOUT_SECONDS", 10)); int maxWaitMillis = configuration.getInt("BACKEND_CONNECTION_MAX_WAIT_MILLIS"); this.host = host; this.port = port; this.dequeueOnly = dequeueOnly; this.generalRedisPool = createRedisPool(host, port, numGeneralConnections, maxWaitMillis, generalSocketTimeoutMillis); this.monitorRedisPool = createRedisPool(host, port, numMonitorConnections, maxWaitMillis, monitorSocketTimeoutMillis); }
From source file:gobblin.writer.ThrottleWriterTest.java
public void testThrottleQps() throws IOException { DataWriter<Void> writer = mock(DataWriter.class); int parallelism = 2; int qps = 4;//from w w w .ja v a 2 s.co m DataWriter<Void> throttleWriter = setup(writer, parallelism, qps, ThrottleType.QPS); int count = 0; long duration = 10L; Stopwatch stopwatch = Stopwatch.createStarted(); while (stopwatch.elapsed(TimeUnit.SECONDS) <= duration) { throttleWriter.write(null); count++; } int expected = (int) (qps * duration); Assert.assertTrue(count <= expected + qps * 2, "Request too high " + count + " , QPS " + qps + " for duration " + duration + " second "); Assert.assertTrue(count >= expected - qps * 2, "Request too low " + count + " , QPS " + qps + " for duration " + duration + " second "); }
From source file:com.bna.ezrxlookup.ui.web.EZRxInitialPage.java
@Before public void setUp() throws Exception { driver = (WebDriver) new FirefoxDriver(); baseUrl = "http://52.7.4.133:8080"; //baseUrl = "http://localhost:8080"; driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); }
From source file:org.apache.camel.example.spring.boot.MySpringBootRouterTest.java
@Test public void shouldProduceMessages() throws InterruptedException { // we expect that one or more messages is automatic done by the Camel // route as it uses a timer to trigger NotifyBuilder notify = new NotifyBuilder(camelContext).whenDone(1).create(); assertTrue(notify.matches(10, TimeUnit.SECONDS)); }
From source file:org.apigw.authserver.svc.impl.ExpiringAuthorizationCodeServices.java
/** * //ww w. j a va2 s . co m * @param timeToLive How long the authorization code will exist, specified in seconds */ public ExpiringAuthorizationCodeServices(int timeToLive) { authorizationCodeStore = new MapMaker().expiration(timeToLive, TimeUnit.SECONDS).makeMap(); }
From source file:com.doubleview.fastcrawler.fetcher.IdleConnectionMonitorThread.java
@Override public void run() { try {//from w ww .j a v a 2s. 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); } } } catch (InterruptedException ignored) { logger.error(ignored.getMessage(), ignored); } }
From source file:org.nebula.service.core.Heartbeat.java
private void shutdownScheduler() { scheduler.shutdown();/*from w ww .java2 s. c o m*/ try { scheduler.awaitTermination(10, TimeUnit.SECONDS); } catch (InterruptedException e) { //ignore the exception } }
From source file:io.gatling.jsonbenchmark.bytes.MainJacksonObjectBenchmark.java
@GenerateMicroBenchmark @OutputTimeUnit(TimeUnit.SECONDS) public void actionLabel(BlackHole bh) throws Exception { bh.consume(parse(ACTION_LABEL_BYTES)); }
From source file:org.dataconservancy.access.connector.ConnectionMonitorThread.java
@Override public void run() { try {/*from ww w. ja va 2s . c o m*/ while (!shutdown) { synchronized (this) { wait(5000); // Close expired connections log.trace("Closing expired connections."); connMgr.closeExpiredConnections(); // Optionally, close connections // that have been idle longer than 30 sec log.trace("Closing connections idle 30s or longer."); connMgr.closeIdleConnections(30, TimeUnit.SECONDS); } } } catch (InterruptedException ex) { log.trace("Terminating."); // terminate } }
From source file:com.github.terma.m.node.Node.java
public static void run(final NodeConfig nodeConfig) { final long millisToRefresh = TimeUnit.SECONDS.toMillis(nodeConfig.secToRefresh); final List<Checker> checkers = buildCheckers(nodeConfig); while (true) { final long cycleStart = System.currentTimeMillis(); final List<Event> events = new ArrayList<>(); for (final Checker checker : checkers) { final long checkStart = System.currentTimeMillis(); try { events.addAll(checker.get()); LOGGER.info(/*from w w w . j a va 2s. c o m*/ "Check: " + checker + ", done: " + (System.currentTimeMillis() - checkStart) + " msec"); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Check: " + checker + ", fail: " + (System.currentTimeMillis() - checkStart) + " msec", e); e.printStackTrace(); } } LOGGER.info("Cycle done, checks: " + checkers.size() + ", events: " + events.size() + " in: " + (System.currentTimeMillis() - cycleStart) + " msec"); final long sendStart = System.currentTimeMillis(); try { send(nodeConfig.serverHost, nodeConfig.serverPort, nodeConfig.serverContext, events); } catch (final IOException exception) { exception.printStackTrace(); } LOGGER.info("Send, events: " + events.size() + " done: " + (System.currentTimeMillis() - sendStart) + " msec"); try { Thread.sleep(millisToRefresh); } catch (InterruptedException e) { return; } } }