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:uk.ac.cam.cl.dtg.segue.api.monitors.InMemoryMisuseMonitor.java
/** * Creates a misuse monitor that just uses non-persistent storage. *//*from www. j av a2 s.c om*/ @Inject public InMemoryMisuseMonitor() { nonPersistentDatabase = CacheBuilder.newBuilder() .expireAfterAccess(2, TimeUnit.DAYS).<String, Map<String, Map.Entry<Date, Integer>>>build(); handlerMap = Maps.newConcurrentMap(); }
From source file:com.linkedin.pinot.segments.v1.creator.IntArraysTest.java
@BeforeClass public static void before() throws Exception { final String filePath = TestUtils .getFileFromResourceUrl(DictionariesTest.class.getClassLoader().getResource(AVRO_DATA)); if (INDEX_DIR.exists()) { FileUtils.deleteQuietly(INDEX_DIR); }//w w w . jav a2s . c o m System.out.println(INDEX_DIR.getAbsolutePath()); final SegmentIndexCreationDriver driver = SegmentCreationDriverFactory.get(null); final SegmentGeneratorConfig config = SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns( new File(filePath), INDEX_DIR, "weeksSinceEpochSunday", TimeUnit.DAYS, "test"); config.setTimeColumnName("weeksSinceEpochSunday"); driver.init(config); driver.build(); final DataFileStream<GenericRecord> avroReader = AvroUtils.getAvroReader(new File(filePath)); final org.apache.avro.Schema avroSchema = avroReader.getSchema(); final String[] columns = new String[avroSchema.getFields().size()]; int i = 0; for (final Field f : avroSchema.getFields()) { columns[i] = f.name(); i++; } }
From source file:org.eclipse.orion.server.git.jobs.InitJob.java
public InitJob(Clone clone, String userRunningTask, String user, String cloneLocation, String gitUserName, String gitUserMail) {/* w w w .j av a 2 s . c o m*/ super(userRunningTask, true); this.clone = clone; this.user = user; this.gitUserName = gitUserName; this.gitUserMail = gitUserMail; this.cloneLocation = cloneLocation; setFinalMessage("Init complete."); setTaskExpirationTime(TimeUnit.DAYS.toMillis(7)); }
From source file:org.muehleisen.hannes.taxiapp.TaxiRoute.java
@Override public void run() { log.info(this.getClass().getSimpleName() + " starting..."); BlockingQueue<Runnable> taskQueue = new LinkedBlockingDeque<Runnable>(100); ExecutorService ex = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), Runtime.getRuntime().availableProcessors(), Integer.MAX_VALUE, TimeUnit.DAYS, taskQueue, new ThreadPoolExecutor.DiscardPolicy()); // create rainbow table for driver lookup log.info("Creating driver license rainbow table."); RouteLogEntry.initLrt();/* www . j av a 2s . c o m*/ // bring up routing service log.info("Bringing up OTP Graph Service from '" + graph + "'."); GraphServiceImpl graphService = new GraphServiceImpl(); graphService.setPath(graph); graphService.startup(); ps = new RetryingPathServiceImpl(graphService, new EarliestArrivalSPTService()); // read taxi files log.info("Reading taxi files from '" + taxilog + "'."); Collection<File> files = FileUtils.listFiles(new File(taxilog), new SuffixFileFilter(".csv.zip"), TrueFileFilter.INSTANCE); for (File f : files) { log.info("Reading '" + f + "'."); try { ZipInputStream z = new ZipInputStream(new FileInputStream(f)); z.getNextEntry(); // ZIP files have many entries. In this case, // only one BufferedReader r = new BufferedReader(new InputStreamReader(z)); r.readLine(); // header String line = null; while ((line = r.readLine()) != null) { RouteLogEntry rle = new RouteLogEntry(line); if (!rle.hasGeo()) { continue; } while (taskQueue.remainingCapacity() < 1) { Thread.sleep(100); } ex.submit(new RouteTask(rle)); } r.close(); z.close(); } catch (Exception e) { log.error("Failed to read taxi file from '" + taxilog + "'.", e); } } ex.shutdown(); try { ex.awaitTermination(Integer.MAX_VALUE, TimeUnit.DAYS); } catch (InterruptedException e) { // ... } log.info(deliveries); }
From source file:org.ownchan.server.app.config.WebMvcConfig.java
@Override public void addResourceHandlers(ResourceHandlerRegistry registry) { String implementationVersion = ScanBaseMarker.class.getPackage().getImplementationVersion(); String pathVersion;//from w w w . j a v a 2 s . c o m CacheControl cacheControl; if (StringUtils.isNotBlank(implementationVersion)) { /* * As we use versioning for the GUI URL paths, we can cache "forever". * Browsers will re-validate when the resource's URL changes with every new version of the application. */ cacheControl = CacheControl.maxAge(365, TimeUnit.DAYS); pathVersion = implementationVersion; } else { /* * If the application is started directly in the DEV IDE, * we don't cache and allow all versions in the path. */ cacheControl = CacheControl.noStore(); pathVersion = "{version:[a-zA-Z0-9\\.\\-]+}"; } addStaticResourceHandlers(registry, cacheControl, "/static/" + pathVersion + "/**"); }
From source file:org.ownchan.server.ui.core.config.WebMvcConfig.java
@Override public void addResourceHandlers(ResourceHandlerRegistry registry) { String implementationVersion = ScanBaseMarker.class.getPackage().getImplementationVersion(); String pathVersion;/*ww w.j a v a2 s. c o m*/ CacheControl cacheControl; if (StringUtils.isNotBlank(implementationVersion)) { /* * As we use versioning for the GUI URL paths, we can cache "forever". * Browsers will re-validate when the resource's URL changes with every new version of the application. */ cacheControl = CacheControl.maxAge(365, TimeUnit.DAYS); pathVersion = implementationVersion; } else { /* * If the application is started directly in the DEV IDE, * we don't cache and allow all versions in the path. */ cacheControl = CacheControl.noStore(); pathVersion = "{version:[a-zA-Z0-9\\.\\-]+}"; } String webBasePath = "/ocn-ui-core/" + pathVersion; String localBasePath = "classpath:/ownchan-server-ui-core"; registry.addResourceHandler(webBasePath + "/widgets/**") .addResourceLocations(localBasePath + "/jqx/jqwidgets/").setCacheControl(cacheControl); registry.addResourceHandler(webBasePath + "/common/**").addResourceLocations(localBasePath + "/common/") .setCacheControl(cacheControl); }
From source file:com.ignorelist.kassandra.steam.scraper.JsonApiTagLoader.java
public JsonApiTagLoader(Path cachePath) { this.cache = new FileCache(cachePath, new CacheLoader<String, InputStream>() { @Override/*from w w w .j a v a2 s.c om*/ public InputStream load(String k) throws Exception { rateLimiter.acquire(); URL url = new URL(buildApiUrl(k)); InputStream inputStream = URLUtil.openInputStream(url); try { byte[] data = ByteStreams.toByteArray(inputStream); loadAppData(data); // fugly return new ByteArrayInputStream(data); } finally { IOUtils.closeQuietly(inputStream); } } }, TimeUnit.DAYS, 7); }
From source file:com.folion.config.PersistenceConfiguration.java
private ProxyBucket getProxyBucket(Environment environment, String bucketName) { String couchbaseServersFromConfig = environment.getProperty("srv.couchbase.servers"); List<String> servers = new ArrayList<>(Arrays.asList(couchbaseServersFromConfig.split(","))); Cluster cluster = CouchbaseCluster.create(servers); Bucket bucket = cluster.openBucket(environment.getProperty("srv.couchbase." + bucketName), 1, TimeUnit.DAYS); return new ProxyBucket(cluster, bucket); }
From source file:com.bodybuilding.argos.controller.TurbineStreamController.java
@RequestMapping("/turbine-stream/{cluster}") public ResponseEntity<SseEmitter> streamHystrix(@PathVariable("cluster") String cluster) { Optional<HystrixClusterMonitor> clusterMonitor = clusterRegistry.getCluster(cluster); if (!clusterMonitor.isPresent()) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); }/*from w w w .jav a 2 s . c o m*/ final SseEmitter emitter = new SseEmitter(TimeUnit.DAYS.toMillis(45)); SseEmitterUtil.bindObservable(emitter, clusterMonitor.get().observeJson().takeUntil(shutdown).subscribeOn(Schedulers.io())); return ResponseEntity.ok(emitter); }
From source file:org.kuali.rice.kim.impl.role.RoleInternalServiceImpl.java
@Override public void roleInactivated(String roleId) { if (StringUtils.isBlank(roleId)) { throw new IllegalArgumentException("roleId is null or blank"); }// w w w. ja v a 2s .c o m long oneDayInMillis = TimeUnit.DAYS.toMillis(1); Timestamp yesterday = new Timestamp(System.currentTimeMillis() - oneDayInMillis); List<String> roleIds = new ArrayList<String>(); roleIds.add(roleId); inactivateRoleMemberships(roleIds, yesterday); inactivateRoleDelegations(roleIds, yesterday); inactivateMembershipsForRoleAsMember(roleIds, yesterday); }