List of usage examples for java.util.concurrent TimeUnit MILLISECONDS
TimeUnit MILLISECONDS
To view the source code for java.util.concurrent TimeUnit MILLISECONDS.
Click Source Link
From source file:monasca.common.middleware.HttpPoolCleaner.java
/** * Start the cleaner.// w ww .j av a 2 s.com */ @Override public void run() { try { while (!shutdown) { synchronized (this) { wait(timeBetweenEvictionRunsMillis); // Close expired connections connMgr.closeExpiredConnections(); // Close connections that have been idle longer than x sec connMgr.closeIdleConnections(minEvictableIdleTimeMillis, TimeUnit.MILLISECONDS); } } } catch (InterruptedException ex) { // terminate } }
From source file:com.moilioncircle.redis.replicator.EventHandlerWorker.java
@Override public void run() { while (!isClosed.get() || replicator.eventQueue.size() > 0) { Object event = null;//from w w w .ja v a2 s . c o m try { event = replicator.eventQueue.poll(replicator.configuration.getPollTimeout(), TimeUnit.MILLISECONDS); if (event == null) { continue; } else if (event instanceof KeyValuePair<?>) { KeyValuePair<?> kv = (KeyValuePair<?>) event; if (!replicator.doRdbFilter(kv)) continue; replicator.doRdbHandler(kv); } else if (event instanceof Command) { Command command = (Command) event; if (!replicator.doCommandFilter(command)) continue; replicator.doCommandHandler(command); } else if (event instanceof PreFullSyncEvent) { replicator.doPreFullSync(); } else if (event instanceof PostFullSyncEvent) { replicator.doPostFullSync(((PostFullSyncEvent) event).getChecksum()); } else { throw new AssertionError(event); } } catch (Throwable throwable) { try { replicator.doExceptionListener(throwable, event); } catch (Throwable e) { logger.error("error", e); } } } replicator.doCloseListener(); }
From source file:de.hpi.fgis.hdrs.node.SegmentServiceThread.java
@Override public void run() { while (!quit) { // get next segment to flush DelayQueueEntry entry = null;/*from w w w .ja v a2 s .c om*/ long segmentId = 0; try { entry = queue.poll(POLL_TIMEOUT, TimeUnit.MILLISECONDS); if (null != entry) { segmentId = entry.getId(); handle(segmentId); } else { handle(); } } catch (InterruptedException ex) { // interrupted... } catch (Throwable unchecked) { fail(unchecked); } } LOG.info("Quitting."); }
From source file:com.rptools.name.NameGen.java
@Autowired public NameGen(NameFileParser nameFileParser) { Stopwatch timer = Stopwatch.createStarted(); first = nameFileParser.parseFile("names.txt"); last = nameFileParser.parseFile("lastNames.txt"); timer.stop();/* w ww. ja v a 2 s . com*/ log.info(String.format(PARSED_TIME, timer.elapsed(TimeUnit.MILLISECONDS))); }
From source file:de.thischwa.pmcms.view.renderer.ExportThreadPoolController.java
ExportThreadPoolController(int threadMaxCountPerCore) { int threadPoolSize = 1; if (threadMaxCountPerCore != 0) threadPoolSize = threadMaxCountPerCore * Constants.CPU_COUNT; threadPool = new ThreadPool(threadPoolSize, threadPoolSize, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); logger.info("ExportThreadPoolController thread pool size initialized with: " + threadPoolSize); }
From source file:org.sonatype.nexus.internal.httpclient.ConnectionEvictionThreadTest.java
/** * Verify that ClientConnectionManager are called. *///from w w w . ja v a 2 s .c om @Test public void connectionEvictedIn5Seconds() throws Exception { final HttpClientConnectionManager clientConnectionManager = mock(HttpClientConnectionManager.class); final ConnectionEvictionThread underTest = new ConnectionEvictionThread(clientConnectionManager, 1000, 100); underTest.start(); Thread.sleep(300); verify(clientConnectionManager, atLeastOnce()).closeExpiredConnections(); verify(clientConnectionManager, atLeastOnce()).closeIdleConnections(1000, TimeUnit.MILLISECONDS); underTest.interrupt(); }
From source file:org.simbasecurity.core.config.store.QuartzConfigurationStore.java
public String getValue(ConfigurationParameter parameter) { try {/*from w w w .j a va 2 s.c om*/ Trigger trigger = findTrigger(parameter); if (trigger instanceof SimpleTrigger) { long repeatInterval = ((SimpleTrigger) trigger).getRepeatInterval(); return String.valueOf(parameter.getTimeUnit().convert(repeatInterval, TimeUnit.MILLISECONDS)); } else if (trigger instanceof CronTrigger) { return ((CronTrigger) trigger).getCronExpression(); } else { throw new IllegalStateException("Type " + trigger.getClass().getName() + " not handled"); } } catch (SchedulerException e) { throw new RuntimeException(e); } }
From source file:org.sonatype.nexus.apachehttpclient.EvictingThreadTest.java
/** * Verify that ClientConnectionManager are called. * * @throws Exception unexpected/*from w w w.j a v a2 s . c om*/ */ @Test public void connectionEvictedIn5Seconds() throws Exception { final HttpClientConnectionManager clientConnectionManager = mock(HttpClientConnectionManager.class); final EvictingThread underTest = new EvictingThread(clientConnectionManager, 1000, 100); underTest.start(); Thread.sleep(300); verify(clientConnectionManager, atLeastOnce()).closeExpiredConnections(); verify(clientConnectionManager, atLeastOnce()).closeIdleConnections(1000, TimeUnit.MILLISECONDS); underTest.interrupt(); }
From source file:acromusashi.stream.example.topology.config.ConfigReloadSpout.java
/** * {@inheritDoc}/*from w ww.ja v a2 s.c o m*/ */ @Override public void onNextTuple() { try { TimeUnit.MILLISECONDS.sleep(this.interval); } catch (InterruptedException ex) { return; } String key = RandomStringUtils.randomAlphanumeric(10); String message = RandomStringUtils.randomAlphanumeric(10); StreamMessage streamMessage = new StreamMessage(); streamMessage.addField("Message", message); emit(streamMessage, key, key); }
From source file:com.talis.storage.AbstractStoreTest.java
@Test public void storedItemHasModifiedDateSetOnWrite() throws Exception { long before = System.currentTimeMillis(); TimeUnit.MILLISECONDS.sleep(1); SubmittedItem submitted = new SubmittedItem(MediaType.TEXT_PLAIN_TYPE, new ByteArrayInputStream(data)); StoredItem stored = store.write(itemURI, submitted); assertTrue(stored.getLastModified().getTime() > before); TimeUnit.MILLISECONDS.sleep(1); assertTrue(stored.getLastModified().getTime() < System.currentTimeMillis()); }