List of usage examples for java.util.concurrent TimeUnit HOURS
TimeUnit HOURS
To view the source code for java.util.concurrent TimeUnit HOURS.
Click Source Link
From source file:org.libreoffice.impressremote.fragment.TimerEditingDialog.java
private int getHours(int aMinutes) { return (int) (aMinutes / TimeUnit.HOURS.toMinutes(1)); }
From source file:it.smartcommunitylab.aac.openid.service.JWKSetCacheService.java
public JWKSetCacheService() { this.validators = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.HOURS) // expires 1 hour after fetch .maximumSize(100)//from www . ja v a2 s .c om .build(new JWKSetVerifierFetcher(HttpClientBuilder.create().useSystemProperties().build())); this.encrypters = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.HOURS) // expires 1 hour after fetch .maximumSize(100) .build(new JWKSetEncryptorFetcher(HttpClientBuilder.create().useSystemProperties().build())); }
From source file:org.trustedanalytics.platformoperations.service.PlatformOperationsScheduler.java
@PostConstruct public void defaultSchedule() { schedulePlatformSummary(schedule, TimeUnit.HOURS); }
From source file:org.apache.metron.profiler.client.stellar.WindowLookbackTest.java
@Test public void testSpecifyingConfig() throws Exception { //we should be able to specify the config and have it take hold. If we change the //profile duration to 1 minute instead of 15 minutes (the default), then we should see //the correct number of profiles. long durationMs = 60000; State state = test("1 hour", new Date(), Optional.of(ImmutableMap.of(ProfilerConfig.PROFILER_PERIOD.getKey(), 1)), Assertions.NOT_EMPTY, Assertions.CONTIGUOUS);/* w w w . j a va2s .c om*/ Assert.assertEquals(TimeUnit.HOURS.toMillis(1) / durationMs, state.periods.size()); }
From source file:org.mitre.jwt.signer.service.impl.ClientKeyCacheService.java
public ClientKeyCacheService() { this.jwksValidators = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.HOURS) // expires 1 hour after fetch .maximumSize(100).build(new JWKSetVerifierBuilder()); this.jwksEncrypters = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.HOURS) // expires 1 hour after fetch .maximumSize(100).build(new JWKSetEncryptorBuilder()); }
From source file:rus.cpuinfo.AndroidDepedentModel.SysInfo.java
@NonNull private String getUpTime() { long m = SystemClock.elapsedRealtime(); final long hr = TimeUnit.MILLISECONDS.toHours(m); final long min = TimeUnit.MILLISECONDS.toMinutes(m - TimeUnit.HOURS.toMillis(hr)); final long sec = TimeUnit.MILLISECONDS .toSeconds(m - TimeUnit.HOURS.toMillis(hr) - TimeUnit.MINUTES.toMillis(min)); return String.format(Locale.getDefault(), "%02d:%02d:%02d", hr, min, sec); }
From source file:com.wegas.core.rest.ComboController.java
/** * Retrieve//from w w w .j a va 2s . c om * * @param req * @return HTTP 200 with requested data or HTTP forbidden response * @throws IOException */ @GET @Produces({ MediaTypeJs, MediaTypeCss }) @CacheMaxAge(time = 3, unit = TimeUnit.HOURS) public Response index(@Context Request req) throws IOException { try { Ehcache cache = cacheManagerHolder.getInstance().getEhcache(CACHE_NAME); final int hash = this.uriInfo.getRequestUri().getQuery().hashCode(); final Element combo = cache.get(hash); CacheObject comboCache; if (combo != null) { // Get from cache comboCache = (CacheObject) combo.getObjectValue(); } else { // build Cache. //final Set<String> files = this.uriInfo.getQueryParameters().keySet(); // Old version, removed cause query parameters where in the wrong order ArrayList<String> files = new ArrayList<>(); // New version, with parameters in the right order for (String parameter : this.uriInfo.getRequestUri().getQuery().split("&")) { String split = parameter.split("=")[0]; if (split != null) { files.add(split); } } files.remove("v"); files.remove("version"); final String mediaType = (files.iterator().next().endsWith("css")) ? MediaTypeCss : MediaTypeJs; // Select the content-type based on the first file extension comboCache = new CacheObject(this.getCombinedFile(files, mediaType), mediaType); cache.put(new Element(hash, comboCache)); } ResponseBuilder rb = req.evaluatePreconditions(new EntityTag(comboCache.getETag())); if (rb != null) { return rb.tag(comboCache.getETag()).build(); } // MediaType types[] = {"application/json", "application/xml"}; // List<Variant> vars = Variant.mediaTypes(types).add().build(); // Variant var = req.selectVariant(vars); //EntityTag etag = new EntityTag(); //Response.ResponseBuilder responseBuilder = request.evaluatePreconditions(updateTimestamp, etag); return Response.ok(comboCache.getFiles()).type(comboCache.getMediaType()) // .expires(new Date(System.currentTimeMillis() + (1000 * 60 * 60 * 24 * 3))) .tag(new EntityTag(comboCache.getETag())).build(); } catch (WegasForbiddenException ex) { return Response.status(Response.Status.FORBIDDEN).entity(ex.getMessage()).build(); } }
From source file:org.apache.hadoop.yarn.server.resourcemanager.amlauncher.ApplicationMasterLauncher.java
@Override protected void serviceInit(Configuration conf) throws Exception { int threadCount = conf.getInt(YarnConfiguration.RM_AMLAUNCHER_THREAD_COUNT, YarnConfiguration.DEFAULT_RM_AMLAUNCHER_THREAD_COUNT); ThreadFactory tf = new ThreadFactoryBuilder().setNameFormat("ApplicationMasterLauncher #%d").build(); launcherPool = new ThreadPoolExecutor(threadCount, threadCount, 1, TimeUnit.HOURS, new LinkedBlockingQueue<Runnable>()); launcherPool.setThreadFactory(tf);// w w w . j a v a 2s .c o m Configuration newConf = new YarnConfiguration(conf); newConf.setInt(CommonConfigurationKeysPublic.IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SOCKET_TIMEOUTS_KEY, conf.getInt(YarnConfiguration.RM_NODEMANAGER_CONNECT_RETRIES, YarnConfiguration.DEFAULT_RM_NODEMANAGER_CONNECT_RETRIES)); setConfig(newConf); super.serviceInit(newConf); }
From source file:org.trustedanalytics.platformoperations.service.PlatformOperationsScheduler.java
public void schedulePlatformSummary(long delay, TimeUnit timeUnit) { LOGGER.info("Schedule Platform Summary: {}h", TimeUnit.HOURS.convert(delay, timeUnit)); executor.scheduleWithFixedDelay(platformSummary(), 0, delay, timeUnit); }
From source file:org.libreoffice.impressremote.fragment.TimerEditingDialog.java
private int getMinutes(int aHours, int aMinutes) { return (int) (TimeUnit.HOURS.toMinutes(aHours) + aMinutes); }