List of usage examples for java.util.concurrent TimeUnit DAYS
TimeUnit DAYS
To view the source code for java.util.concurrent TimeUnit DAYS.
Click Source Link
From source file:org.eclipse.skalli.core.rest.admin.StatisticsQueryTest.java
@Test public void testFromQuery() throws Exception { Calendar cal = Calendar.getInstance(); long now = cal.getTimeInMillis(); long fromMillis = now - TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS); cal.setTimeInMillis(fromMillis);/*from ww w .j a v a2 s .c o m*/ String fromStr = DatatypeConverter.printDateTime(cal); StatisticsQuery query = new StatisticsQuery(getParams(fromStr, null, null), now); Assert.assertEquals(fromMillis, query.getFrom()); Assert.assertEquals(now, query.getTo()); }
From source file:com.hpcloud.util.Duration.java
private Duration(long length, TimeUnit timeUnit) { this.length = length; this.timeUnit = Preconditions.checkNotNull(timeUnit); finite = length == Long.MAX_VALUE && TimeUnit.DAYS.equals(timeUnit) ? false : true; }
From source file:ru.mystamps.web.config.MvcConfig.java
@Override public void addResourceHandlers(ResourceHandlerRegistry registry) { VersionResourceResolver resourceResolver = new VersionResourceResolver() .addFixedVersionStrategy(Url.RESOURCES_VERSION, "/**"); @SuppressWarnings("checkstyle:magicnumber") CacheControl cacheControl = CacheControl.maxAge(7, TimeUnit.DAYS); registry.addResourceHandler("/static/**").addResourceLocations("/WEB-INF/static/") .setCacheControl(cacheControl).resourceChain(true).addResolver(resourceResolver); registry.addResourceHandler("/public/js/**").addResourceLocations("classpath:/js/").resourceChain(true) .addResolver(resourceResolver); // For WebJars: registry.addResourceHandler("/public/bootstrap/**") .addResourceLocations("classpath:/META-INF/resources/webjars/bootstrap/"); registry.addResourceHandler("/public/jquery/**") .addResourceLocations("classpath:/META-INF/resources/webjars/jquery/"); registry.addResourceHandler("/public/selectize/**") .addResourceLocations("classpath:/META-INF/resources/webjars/selectize.js/"); }
From source file:org.apache.activemq.usecases.DurableSubscriptionHangTestCase.java
private void produceExpiredAndOneNonExpiredMessages() throws JMSException { ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://" + brokerName); TopicConnection connection = connectionFactory.createTopicConnection(); TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = session.createTopic(topicName); MessageProducer producer = session.createProducer(topic); producer.setTimeToLive(TimeUnit.SECONDS.toMillis(1)); for (int i = 0; i < 40000; i++) { sendRandomMessage(session, producer); }//from w w w .j a v a2 s . com producer.setTimeToLive(TimeUnit.DAYS.toMillis(1)); sendRandomMessage(session, producer); connection.close(); LOG.info("produceExpiredAndOneNonExpiredMessages done"); }
From source file:com.cloudbees.demo.beesshop.service.MongoDbFileStorageService.java
public void serveFile(String photoId, String id, HttpServletResponse response) throws IOException { GridFSDBFile file = gridFS.findOne(new ObjectId(id)); response.setContentType(file.getContentType()); response.setHeader("cache-control", "public, max-age=" + TimeUnit.SECONDS.convert(365, TimeUnit.DAYS)); try (InputStream in = file.getInputStream()) { ByteStreams.copy(in, response.getOutputStream()); }/* www .j a v a 2s . c o m*/ }
From source file:com.isthari.spring.cloud.config.cassandra.CassandraEnvironmentRepository.java
public CassandraEnvironmentRepository(ConfigurableEnvironment environment, String hostnames, String username, String password, Boolean createSchema) { // Create cluster object Cluster.Builder builder = Cluster.builder(); // Add contact points for (String hostname : hostnames.split(",")) { builder.addContactPoints(hostname); }/*from ww w .ja v a 2 s .c o m*/ if (username != null && password != null) { builder.withCredentials(username, password); } Cluster cluster = builder.build(); if (createSchema) { this.createSchema(cluster); } // Connect session = cluster.connect("cloud_config"); this.stmtGetVersion = session.prepare( "select version from application_label_version where application=? and label=? and profile=? limit 1"); this.stmtGetSnapshot = session .prepare("select parameters from configuration_snapshot where application=? and version=?"); // Executor for async tasks BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<Runnable>(10); executor = new ThreadPoolExecutor(4, 10, 1, TimeUnit.DAYS, workQueue); }
From source file:org.sonatype.nexus.testsuite.task.nexus2692.AbstractEvictTaskIt.java
@Before public void setupStorageAndAttributes() throws Exception { final File workDir = new File(AbstractNexusIntegrationTest.nexusWorkDir); storageWorkDir = new File(workDir, "storage"); FileUtils.copyDirectory(getTestResourceAsFile("storage/"), storageWorkDir); // now setup all the attributes File attributesInfo = getTestResourceAsFile("attributes.info"); final Marshaller marshaller = new JacksonJSONMarshaller(); final long now = System.currentTimeMillis(); try (BufferedReader reader = new BufferedReader(new FileReader(attributesInfo))) { String line = reader.readLine(); while (line != null) { final String[] parts = line.split(" "); final String repoFilePart = parts[0]; final String repoId = repoFilePart.substring(0, repoFilePart.indexOf('/')); final String filePart = repoFilePart.substring(repoFilePart.indexOf('/'), repoFilePart.length()); long offset = TimeUnit.DAYS.toMillis(Long.parseLong(parts[1])); // get the file File itemFile = new File(storageWorkDir, repoFilePart); if (itemFile.isFile()) { this.pathMap.put(repoFilePart, Integer.parseInt(parts[1])); /*// www .j ava2 s . c om * groups are not checked, so the hashes are left behind, see: NEXUS-3026 */ if (repoFilePart.startsWith("releases/") || repoFilePart.startsWith("releases-m1/") || repoFilePart.startsWith("public/") || repoFilePart.startsWith("snapshots/") || repoFilePart.startsWith("thirdparty/") || repoFilePart.contains(".meta") || repoFilePart.contains(".index")) { neverDeleteFiles.add(repoFilePart); } // modify the file corresponding attribute final File attributeFile = new File( new File(new File(storageWorkDir, repoId), ".nexus/attributes"), filePart); Attributes attributes; try (FileInputStream in = new FileInputStream(attributeFile)) { attributes = marshaller.unmarshal(in); } // set new value attributes.setLastRequested(now + offset); // write it out try (FileOutputStream out = new FileOutputStream(attributeFile)) { marshaller.marshal(attributes, out); } } line = reader.readLine(); } } }
From source file:org.apache.metron.dataloads.bulk.ElasticsearchDataPrunerIntegrationTest.java
@Test public void testDeletesCorrectIndexes() throws Exception { Integer numDays = 5;/*ww w.j a v a 2 s . c o m*/ Date createStartDate = new Date(); createStartDate.setTime(yesterday.getTime() - TimeUnit.DAYS.toMillis(numDays - 1)); ElasticsearchDataPruner pruner = new ElasticsearchDataPruner(yesterday, 30, configuration, client(), "*"); String indexesToDelete = "sensor_index_" + new SimpleDateFormat("yyyy.MM.dd").format(createStartDate) + ".*"; Boolean deleted = pruner.deleteIndex(admin(), indexesToDelete); assertTrue("Index deletion should be acknowledged", deleted); }
From source file:com.github.restdriver.clientdriver.integration.ClientDriverRuleTest.java
@Test public void responseExpectationTimeoutIsPropagatedToClientDriverResponse() { // Given/*ww w . j a v a 2 s. co m*/ final ClientDriverRule driver = new ClientDriverRule().expectResponsesWithin(5, TimeUnit.DAYS); final ClientDriverResponse response = giveResponse("", null); // When driver.addExpectation(onRequestTo("/path"), response); // Then assertThat(response.hasNotExpired(), is(true)); }
From source file:com.epam.catgenome.util.Utils.java
/** * Makes time for S3 URL access/*from w ww .j a v a 2 s . c o m*/ * @return a {@link Date} object, representing time for S3 URL access */ public static Date getTimeForS3URL() { return new Date(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1)); }