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:com.cognifide.aet.job.common.modifiers.WebElementsLocatorParams.java
private void initializeTimeOutParam(String timeoutString) throws ParametersException { if (StringUtils.isNotBlank(timeoutString)) { if (!StringUtils.isNumeric(timeoutString)) { throw new ParametersException("Parameter 'timeout' on Click Modifier isn't a numeric value."); }/* www. java 2 s .c om*/ timeoutInSeconds = TimeUnit.SECONDS.convert(Long.valueOf(timeoutString), TimeUnit.MILLISECONDS); if (timeoutInSeconds < 0) { throw new ParametersException("'timeout' parameter value should be greater or equal zero."); } else if (TIMEOUT_SECONDS_MAX_VALUE < timeoutInSeconds) { throw new ParametersException("'timeout' parameter value can't be greater than " + Long.toString(TIMEOUT_SECONDS_MAX_VALUE) + " seconds."); } } }
From source file:com.navercorp.pinpoint.collector.dao.AutoFlusher.java
public void initialize() { if (CollectionUtils.isEmpty(cachedStatisticsDaoList)) { return;/*ww w .j a v a 2 s. com*/ } ThreadFactory threadFactory = PinpointThreadFactory.createThreadFactory(this.getClass().getSimpleName()); executor = Executors.newScheduledThreadPool(cachedStatisticsDaoList.size(), threadFactory); for (CachedStatisticsDao dao : cachedStatisticsDaoList) { executor.scheduleAtFixedRate(new Worker(dao), 0L, flushPeriod, TimeUnit.MILLISECONDS); } logger.info("Auto flusher initialized."); }
From source file:com.iflytek.edu.cloud.frame.support.redis.RedisRegistry.java
public RedisRegistry() { String baseDir = SystemPropertyUtil.get("BASE_HOME"); redisValue = baseDir + "$$" + JettyConfigUtil.getServerPort(); this.expireFuture = expireExecutor.scheduleWithFixedDelay(new Runnable() { public void run() { try { deferExpired(); // } catch (Throwable t) { // LOGGER.error("Unexpected exception occur at defer expire time, cause: " + t.getMessage(), t); }//from ww w .j ava 2 s . c o m } }, expirePeriod, expirePeriod, TimeUnit.MILLISECONDS); LOGGER.info("?" + EnvUtil.getProjectName()); }
From source file:net.ion.framework.db.manager.script.FileAlterationMonitor.java
public synchronized void start() throws Exception { Callable<Void> sjob = new Callable<Void>() { @Override/*from w w w . j a v a 2s . c o m*/ public Void call() throws Exception { for (FileAlterationObserver o : observers) { o.checkAndNotify(); } ses.schedule(this, interval, TimeUnit.MILLISECONDS); return null; } }; ses.schedule(sjob, interval, TimeUnit.MILLISECONDS); }
From source file:org.duracloud.mill.manifest.builder.ManifestBuilder.java
/** * //from www.j a v a 2 s. com * @param account * @param contentStores * @param spaceList * @param manifestItemRepo * @param clean * @param dryRun * @param threads */ public void init(String account, Collection<ContentStore> contentStores, List<String> spaceList, boolean clean, boolean dryRun, int threads) { this.account = account; this.contentStores = contentStores; this.spaceList = spaceList; this.clean = clean; this.dryRun = dryRun; if (this.executor != null) { this.executor.shutdownNow(); } this.successes = 0; this.errors = 0; this.totalProcessed = 0; this.executor = new ThreadPoolExecutor(threads, threads, 0l, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(500)); }
From source file:org.sonatype.nexus.internal.httpclient.ConnectionEvictionThreadTest.java
/** * Verify that eviction thread will continue to run even if calls on ClientConnectionManager fails. * * @throws Exception unexpected/*w w w . jav a 2s . co m*/ */ @Test public void evictionContinuesWhenConnectionManagerFails() throws Exception { final HttpClientConnectionManager clientConnectionManager = mock(HttpClientConnectionManager.class); doThrow(new RuntimeException("closeExpiredConnections")).when(clientConnectionManager) .closeExpiredConnections(); doThrow(new RuntimeException("closeIdleConnections")).when(clientConnectionManager) .closeIdleConnections(1000, TimeUnit.MILLISECONDS); final ConnectionEvictionThread underTest = new ConnectionEvictionThread(clientConnectionManager, 1000, 100); underTest.start(); Thread.sleep(300); verify(clientConnectionManager, atLeast(2)).closeExpiredConnections(); verify(clientConnectionManager, atLeast(2)).closeIdleConnections(1000, TimeUnit.MILLISECONDS); underTest.interrupt(); }
From source file:com.adaptris.core.fs.MovingDeletingFsConsumerTest.java
public void testConsume() throws Exception { final File parentDir = FsHelper .createFileReference(FsHelper.createUrlFromString(PROPERTIES.getProperty(BASE_KEY), true)); final String subDir = new GuidGenerator().safeUUID(); final File baseDir = new File(parentDir, subDir); final File procDir = new File(parentDir, "proc"); final MockMessageListener stub = new MockMessageListener(10); final MovingNonDeletingFsConsumer fs = createConsumer(subDir, "testConsume"); fs.setPoller(new FixedIntervalPoller(new TimeInterval(300L, TimeUnit.MILLISECONDS))); fs.setProcessedPath(procDir.getAbsolutePath()); final StandaloneConsumer sc = new StandaloneConsumer(fs); sc.registerAdaptrisMessageListener(stub); final int count = 10; List<File> files = null; try {/*from w w w . j a va 2 s . com*/ LifecycleHelper.init(sc); files = createFiles(baseDir, ".xml", count); LifecycleHelper.start(sc); waitForMessages(stub, count); assertMessages(stub.getMessages(), count, baseDir.listFiles((FilenameFilter) new Perl5FilenameFilter(".*\\.xml"))); } catch (final Exception e) { log.warn(e.getMessage(), e); fail(); } finally { stop(sc); if (files != null) { for (final File f : files) { boolean found = false; for (final String n : procDir.list()) { if (f.getName().equals(n)) { found = true; } } if (!found) { fail("Couldn't find file " + f.getName() + " in processed directory"); } } } FileUtils.deleteQuietly(baseDir); FileUtils.deleteQuietly(procDir); } }
From source file:com.boozallen.cognition.ingest.accumulo.storm.AccumuloBaseBolt.java
@Override public final void prepare(Map stormConf, TopologyContext context) { Instance inst = new ZooKeeperInstance(accumuloConnConfig.getInstance(), accumuloConnConfig.getZooServers()); try {/*w w w . j a va 2 s. co m*/ conn = inst.getConnector(accumuloConnConfig.getUser(), new PasswordToken(accumuloConnConfig.getKey())); config = new BatchWriterConfig(); config.setMaxMemory(accumuloConnConfig.getMaxMem()); config.setMaxLatency(accumuloConnConfig.getMaxLatency(), TimeUnit.MILLISECONDS); config.setMaxWriteThreads(accumuloConnConfig.getMaxWriteThreads()); } catch (AccumuloException e) { logger.error("Failed to get Connection", e); throw new PrepareFailedException("Failed to get Connection", e); } catch (AccumuloSecurityException e) { logger.error("Failed to authenticate", e); throw new PrepareFailedException("Failed to authenticate", e); } prepareAccumuloBolt(stormConf, context); }
From source file:com.addthis.codec.utils.ExecutorServiceBuilder.java
public ExecutorService build() { ThreadPoolExecutor service = new ThreadPoolExecutor(coreThreads, maxThreads, keepAlive, TimeUnit.MILLISECONDS, queue, threadFactory); if (shutdownHook) { return MoreExecutors.getExitingExecutorService(service); } else {//ww w . j a va2s . c om return service; } }
From source file:lab.examples.zookeeper.demo.RouteMutationProcessor.java
@SuppressWarnings({ "unchecked", "deprecation" }) @Override/*from w w w . j a va 2 s. c om*/ public void process(Exchange exchange) throws Exception { ZooKeeperMessage message = (ZooKeeperMessage) exchange.getIn(); List<String> childNodes = (List<String>) message.getBody(); ZooKeeper zookeeper = zookeeperConnector.getZooKeeper(); Stat stat = new Stat(); if (!routeIdList.isEmpty()) { if (childNodes.size() < routeIdList.size()) { for (String routeId : (List<String>) CollectionUtils.subtract(routeIdList, childNodes)) { //camelContext.stopRoute(routeId,5,TimeUnit.MILLISECONDS,true); //camelContext.removeRoute(routeId); camelContext.shutdownRoute(routeId, 5, TimeUnit.MILLISECONDS); routeIdList.remove(routeId); } } } for (String routeId : childNodes) { // Add notification received if (camelContext.getRoute(routeId) == null) { // Route does not already exist String[] destinations = new String(zookeeper.getData("/DEMO/" + routeId, null, stat)) .split(DELIMITER); camelContext.addRoutes(new MyDynamicRouteBuilder(camelContext, routeId, destinations[0].trim(), destinations[1].trim())); routeIdList.add(routeId); } } }