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.wenyu.clustertools.Flush.java
@Override public void execute() { ExecutorService executor = Executors.newFixedThreadPool(parallel); Map<ClusterToolCmd.Node, Future<Void>> futures = new HashMap<>(); for (ClusterToolCmd.Node node : nodes) { futures.put(node, executor.submit(new Executor(node))); }/*from w w w . ja v a 2 s . com*/ for (Map.Entry<ClusterToolCmd.Node, Future<Void>> future : futures.entrySet()) { try { future.getValue().get(Constants.MAX_PARALLEL_WAIT_IN_SEC, TimeUnit.SECONDS); } catch (Exception ex) { System.out .println(String.format("%s failed with error: %s", future.getKey().server, ex.toString())); ex.printStackTrace(); } } }
From source file:de.ecclesia.kipeto.repository.HttpRepositoryStrategy.java
public HttpRepositoryStrategy(String repository) { this.repository = repository; HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, (int) TimeUnit.SECONDS.toMillis(5)); HttpConnectionParams.setSoTimeout(httpParams, (int) TimeUnit.SECONDS.toMillis(10)); client = new DefaultHttpClient(httpParams); }
From source file:org.zenoss.zep.dao.impl.FlapTrackerDaoImpl.java
@Override public void persistTracker(String clearFingerprintHash, FlapTracker tracker, long timeToKeep) throws ZepException { logger.debug("Setting string key {} value {}", createKey(clearFingerprintHash), tracker.convertToString()); try {/* ww w . j a v a 2 s . c o m*/ template.opsForValue().set(createKey(clearFingerprintHash), tracker.convertToString(), timeToKeep, TimeUnit.SECONDS); } catch (RedisConnectionFailureException e) { throw new ZepException(e); } }
From source file:com.github.jarlakxen.embedphantomjs.PhantomJSExecutorTest.java
@Test public void test_FileExecutor_FromString() throws InterruptedException, ExecutionException { PhantomJSFileExecutor ex = new PhantomJSFileExecutor(PhantomJSReference.create().build(), new ExecutionTimeout(5, TimeUnit.SECONDS)); assertEquals("TEST1" + String.format("%n"), ex.execute(DEFAULT_FILE_JS).get()); }
From source file:com.olacabs.fabric.compute.PipelineTestBench.java
/** * A constructor for getting an instance of {@code PipelineTestBench}. *//*ww w .j a va 2 s . c om*/ public PipelineTestBench() { metricRegistry = SharedMetricRegistries.getOrCreate("metrics-registry"); metricRegistry.timer("consume-timer"); reporter = ConsoleReporter.forRegistry(metricRegistry).convertDurationsTo(TimeUnit.MILLISECONDS) .convertRatesTo(TimeUnit.SECONDS).filter(MetricFilter.ALL).build(); }
From source file:com.ppcxy.cyfm.showcase.demos.schedule.JdkTimerJob.java
@PreDestroy public void stop() { Threads.gracefulShutdown(scheduledExecutorService, shutdownTimeout, TimeUnit.SECONDS); }
From source file:com.boundary.sdk.event.snmp.SnmpTrapFilterTest.java
@Test public void testWarmStart() throws InterruptedException, IOException { out.expectedMessageCount(1);/*from w w w . java 2s . c om*/ out.await(5, TimeUnit.SECONDS); trap.send(); SendTrap trap1 = new SendTrap(); trap1.setPort(1162); trap1.addVariableBinding( new VariableBinding(SnmpConstants.warmStart, new OctetString("Host has been restarted"))); trap1.send(); out.assertIsSatisfied(); List<Exchange> exchanges = out.getExchanges(); assertEquals("check size", 1, exchanges.size()); for (Exchange exchange : exchanges) { SnmpTrap trap = exchange.getIn().getBody(SnmpTrap.class); } }
From source file:io.gravitee.repository.hazelcast.keyvalue.KVHazelcastRepository.java
@Override public Object put(String key, Object value, long ttl) { return put(key, value, ttl, TimeUnit.SECONDS); }
From source file:org.zalando.zmon.actuator.ZmonMetricsFilterTest.java
@Before public void setUp() { ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS).build(); reporter.start(2, TimeUnit.SECONDS); restTemplate = new RestTemplate(); restTemplate.setErrorHandler(new ResponseErrorHandler() { @Override/*from w w w . jav a2 s . c om*/ public boolean hasError(final ClientHttpResponse response) throws IOException { // we want them all to pass return false; } @Override public void handleError(final ClientHttpResponse response) throws IOException { } }); }
From source file:name.abhijitsarkar.javaee.coffeehouse.spring.event.CoffeeHouseClosingEventPublisher.java
void closeShop() { final Runnable closer = new Runnable() { public void run() { final OperationalEvent event = new OperationalEvent(this); event.setOpen(false);/* w w w. j a va2s . co m*/ LOGGER.debug("Firing notification to close shop."); CoffeeHouseClosingEventPublisher.this.publisher.publishEvent(event); } }; final long initialDelay = 1L; final long delay = 2L; final long duration = 10L; final ScheduledFuture<?> closerHandle = scheduler.scheduleWithFixedDelay(closer, initialDelay, delay, TimeUnit.SECONDS); scheduler.schedule(new Runnable() { public void run() { closerHandle.cancel(true); } }, duration, TimeUnit.SECONDS); }