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:io.github.jhipster.config.metrics.GraphiteRegistry.java
public GraphiteRegistry(MetricRegistry metricRegistry, JHipsterProperties jHipsterProperties) { this.jHipsterProperties = jHipsterProperties; if (this.jHipsterProperties.getMetrics().getGraphite().isEnabled()) { log.info("Initializing Metrics Graphite reporting"); String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost(); Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort(); String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix(); Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort)); GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS) .prefixedWith(graphitePrefix).build(graphite); graphiteReporter.start(1, TimeUnit.MINUTES); }//from w w w. jav a 2s . c o m }
From source file:com.github.neio.filesystem.paths.TestFilePath.java
@Test public void testTouch() throws InterruptedException, IOException { File testFile = new File(testDir, "testFile"); FileUtils.writeStringToFile(testFile, "Hello World"); long initialTime = testFile.lastModified(); TimeUnit.SECONDS.sleep(1); new FilePath("./testTempDir/testFile").touch(); Assert.assertTrue(initialTime < testFile.lastModified()); }
From source file:com.watchrabbit.crawler.manager.service.ManagerServiceIT.java
@Ignore @Test/*from w w w . j a va 2s .c om*/ public void shouldProcessTest() { authService.addNewAuthData( new AuthData.Builder().withDomain("api.watchrabbit.com").withLogin("").withPassword("") .withAuthEndpointUrl("https://api.watchrabbit.com/signin").withSessionDuration(60).build()); Address address = new Address.Builder().withUrl("https://scalingapp.com").withNextExecutionDate(new Date()) .withDomainName(InternetAddress.getDomainName("https://scalingapp.com")).build(); addressRepository.save(address); managerService.findIdsForExecution(1000).forEach(managerService::orderExecution); sleep(10, TimeUnit.SECONDS); System.err.println("FIRST BATCH"); addressRepository.findOrderByNextExecutionDate(1000).stream() .map(queued -> queued.getDomainName() + " " + queued.getUrl() + " " + queued.getNextExecutionDate()) .sorted().forEach(System.out::println); managerService.findIdsForExecution(1000).forEach(managerService::orderExecution); sleep(10, TimeUnit.SECONDS); System.err.println("SECOND BATCH"); addressRepository.findOrderByNextExecutionDate(1000).stream() .map(queued -> queued.getDomainName() + " " + queued.getUrl() + " " + queued.getNextExecutionDate()) .sorted().forEach(System.out::println); managerService.findIdsForExecution(1000).forEach(managerService::orderExecution); sleep(10, TimeUnit.SECONDS); System.err.println("THIRD BATCH"); }
From source file:org.apache.solr.client.solrj.ConnectionReuseTest.java
@BeforeClass public static void setupCluster() throws Exception { TestInjection.failUpdateRequests = "true:100"; configureCluster(1)// w ww .j a va2 s .c o m .addConfig("config", TEST_PATH().resolve("configsets").resolve("cloud-minimal").resolve("conf")) .configure(); CollectionAdminRequest.createCollection(COLLECTION, "config", 1, 1).processAndWait(cluster.getSolrClient(), DEFAULT_TIMEOUT); cluster.getSolrClient().waitForState(COLLECTION, DEFAULT_TIMEOUT, TimeUnit.SECONDS, (n, c) -> DocCollection.isFullyActive(n, c, 1, 1)); }
From source file:io.github.retz.web.StatusCache.java
@Override public void run() { StatusCache.updateUsedResources();/*from ww w . ja v a 2 s. c o m*/ if (on) { scheduler.schedule(new StatusCache(INTERVAL), INTERVAL, TimeUnit.SECONDS); } }
From source file:com.appleframework.monitor.service.TaskService.java
public void scheduledTask(final Project project, final Task task) { final String projectName = project.getName(); //first,cancel old task removeScheduled(projectName, task);/*from w ww .j av a 2 s . c om*/ String taskKey = getTaskKey(projectName, task); ScheduledFuture<?> future = executor.schedule(new Runnable() { @Override public void run() { long startTime = System.currentTimeMillis(); try { FutureTask<CommandResult> _fuFutureTask = TaskService.this.runScript(task.getScript(), project); _fuFutureTask.get(task.getTimeout(), TimeUnit.SECONDS); } catch (TimeoutException e) { logger.error("execute task timeout,use {} (second), project={} , script={}", new Object[] { (System.currentTimeMillis() - startTime) / 1000, projectName, task }); } catch (Exception e) { logger.error("execute task ERROR,use {} (second), project={} , script={}", new Object[] { (System.currentTimeMillis() - startTime) / 1000, projectName, task }); logger.error("execute task fail", e); } logger.info("execute task success,use {} (second) , project={} , taskName={}", new Object[] { (System.currentTimeMillis() - startTime) / 1000, projectName, task.getName() }); } }, new CronTrigger(task.getCron())); logger.info("add a new task {}", taskKey); futures.put(taskKey, future); }
From source file:com.epam.ta.reportportal.database.search.ModifiableQueryBuilder.java
/** * Finds files with provided project and uploaded later than provided time period * //from www . j a va 2s . c o m * @param period * @param project * @return */ public static Query findModifiedLaterThanPeriod(final Time period, final String project) { Query query = Query.query(Criteria.where(Modifiable.UPLOADED).lt( DateUtils.addSeconds(Calendar.getInstance().getTime(), (int) (-1 * period.in(TimeUnit.SECONDS))))); return query.addCriteria(Criteria.where(METADATA).is(project)); }
From source file:org.swarmcom.jsynapse.service.accesstoken.AccessTokenServiceImpl.java
@PostConstruct public void init() { this.mongoTemplate.indexOps(AccessToken.class) .ensureIndex(new Index().on("lastUsed", Sort.Direction.ASC).expire(expire, TimeUnit.SECONDS)); }/* w w w .j av a2 s. c o m*/
From source file:com.taobao.pushit.server.listener.ConnectionMetaDataTimerListener.java
public void onConnectionCreated(final Connection conn) { try {/*w w w .j ava 2 s. com*/ Timeout timeout = timer.newTimeout(new TimerTask() { public void run(Timeout timeout) throws Exception { // if (!timeout.isCancelled() && conn.isConnected()) { if (conn.getAttribute(CONN_META_DATA_ATTR) == null) { log.error("" + conn.getRemoteSocketAddress() + "clientInterests"); conn.close(false); } } } }, delay, TimeUnit.SECONDS); // if (conn.setAttributeIfAbsent(CONN_METADATA_TIMEOUT_ATTR, timeout) != null) { timeout.cancel(); } } catch (Throwable t) { try { conn.close(false); } catch (NotifyRemotingException e) { // ignore } log.error("", t); } }
From source file:io.fluo.core.ITBaseMini.java
@Before public void setUpFluo() throws Exception { config = new FluoConfiguration(); config.setApplicationName("mini-test" + testCounter.getAndIncrement()); config.setAccumuloInstance(miniAccumulo.getInstanceName()); config.setAccumuloUser(USER);// ww w .j a va 2 s. c o m config.setAccumuloPassword(PASSWORD); config.setAccumuloZookeepers(miniAccumulo.getZooKeepers()); config.setInstanceZookeepers(miniAccumulo.getZooKeepers() + "/fluo"); config.setAccumuloTable(getNextTableName()); config.setWorkerThreads(5); config.setObservers(getObservers()); config.setOraclePort(PortUtils.getRandomFreePort()); config.setMiniStartAccumulo(false); setConfig(config); setAppConfig(config.getAppConfiguration()); config.setTransactionRollbackTime(1, TimeUnit.SECONDS); try (FluoAdmin admin = FluoFactory.newAdmin(config)) { InitOpts opts = new InitOpts().setClearZookeeper(true).setClearTable(true); admin.initialize(opts); } config.getAppConfiguration().clear(); client = FluoFactory.newClient(config); miniFluo = FluoFactory.newMiniFluo(config); }