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.blocks4j.reconf.client.validation.ConfigurationRepositoryElementValidator.java
private static void checkUpdateFrequency(ConfigurationRepositoryElement arg, Map<String, String> errors) { if (arg.getRate() == null || arg.getRate() < 1) { errors.put("@ConfigurationRepository", msg.get("rate.error")); }//from w w w. j a v a 2s . c om if (arg.getTimeUnit() == null || !EnumSet.of(TimeUnit.MINUTES, TimeUnit.HOURS, TimeUnit.DAYS).contains(arg.getTimeUnit())) { errors.put("@ConfigurationRepository", msg.get("timeUnit.null")); } }
From source file:org.apache.tez.analyzer.utils.SVGUtils.java
public static String getTimeStr(final long millis) { long minutes = TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)); long hours = TimeUnit.MILLISECONDS.toHours(millis); StringBuilder b = new StringBuilder(); b.append(hours == 0 ? "" : String.valueOf(hours) + "h"); b.append(minutes == 0 ? "" : String.valueOf(minutes) + "m"); long seconds = millis - TimeUnit.MINUTES.toMillis(TimeUnit.MILLISECONDS.toMinutes(millis)); b.append(secondFormat.format(seconds / 1000.0) + "s"); return b.toString(); }
From source file:springfox.documentation.schema.property.CachingModelPropertiesProvider.java
@Autowired public CachingModelPropertiesProvider(final TypeResolver resolver, @Qualifier("optimized") final ModelPropertiesProvider delegate) { cache = CacheBuilder.newBuilder().maximumSize(1000).expireAfterWrite(24, TimeUnit.HOURS) .build(new CacheLoader<ModelContext, List<ModelProperty>>() { public List<ModelProperty> load(ModelContext key) { return delegate.propertiesFor(key.resolvedType(resolver), key); }/*from w w w .j av a2 s. c om*/ }); }
From source file:org.eclipse.gyrex.jobs.internal.commands.LsCmd.java
private static String toRelativeTime(final long duration) { if (duration < TimeUnit.MINUTES.toMillis(2)) return "a minute ago"; else if (duration < TimeUnit.HOURS.toMillis(2)) return String.format("%d minutes ago", TimeUnit.MILLISECONDS.toMinutes(duration)); else//from w w w .j av a2 s .co m return String.format("%d hours ago", TimeUnit.MILLISECONDS.toMinutes(duration)); }
From source file:com.esofthead.mycollab.module.ecm.esb.impl.DeleteResourcesCommandImpl.java
@Override public void removeResource(String[] paths, String userDelete, Integer sAccountId) { Lock lock = DistributionLockUtil.getLock("ecm-" + sAccountId); if (sAccountId == null) { return;//w w w . j a v a2s . co m } try { if (lock.tryLock(1, TimeUnit.HOURS)) { long totalSize = 0; DriveInfo driveInfo = driveInfoService.getDriveInfo(sAccountId); for (String path : paths) { if (StringUtils.isBlank(path)) { continue; } totalSize += rawContentService.getSize(path); rawContentService.removePath(path); } if (driveInfo.getUsedvolume() == null || (driveInfo.getUsedvolume() < totalSize)) { LOG.error( "Inconsistent storage volumne site of account {}, used storage is less than removed storage ", sAccountId); driveInfo.setUsedvolume(0L); } else { driveInfo.setUsedvolume(driveInfo.getUsedvolume() - totalSize); } driveInfoService.saveOrUpdateDriveInfo(driveInfo); } } catch (Exception e) { LOG.error("Error while delete content " + paths, e); } finally { lock.unlock(); } }
From source file:org.apache.tez.dag.app.taskclean.TaskCleanerImpl.java
public void serviceStart() { ThreadFactory tf = new ThreadFactoryBuilder().setNameFormat("TaskCleaner #%d").build(); launcherPool = new ThreadPoolExecutor(5, 5, 1, TimeUnit.HOURS, new LinkedBlockingQueue<Runnable>(), tf); eventHandlingThread = new Thread(new Runnable() { @Override//from w ww .j av a2 s. c o m public void run() { TaskCleanupEvent event = null; while (!Thread.currentThread().isInterrupted()) { try { event = eventQueue.take(); } catch (InterruptedException e) { LOG.error("Returning, interrupted : " + e); return; } // the events from the queue are handled in parallel // using a thread pool launcherPool.execute(new EventProcessor(event)); } } }); eventHandlingThread.setName("TaskCleaner Event Handler"); eventHandlingThread.start(); }
From source file:at.ac.univie.isc.asio.flock.FlockAssemblerTest.java
@Test public void should_use_provided_configuration_properties() throws Exception { final FlockConfig input = new FlockConfig().setName(Id.valueOf("test")) .setIdentifier(URI.create("asio:///test/")).setTimeout(Timeout.from(21, TimeUnit.HOURS)); final FlockConfig result = make(Id.valueOf("test"), JACKSON.writeValueAsBytes(input)); assertThat(result.getIdentifier(), equalTo(URI.create("asio:///test/"))); assertThat(result.getTimeout(), equalTo(Timeout.from(21, TimeUnit.HOURS))); }
From source file:org.glite.security.voms.admin.util.validation.x509.CanlDNValidator.java
public CanlDNValidator(String trustAnchorsDir, boolean openssl1Mode) { trustAnchorStore = new OpensslTrustAnchorStoreImpl(trustAnchorsDir, trustStoreTimer, TimeUnit.HOURS.toMillis(4), nsMode.globusEnabled(), nsMode.euGridPmaEnabled(), new ObserversHandler(Collections.singletonList(this)), openssl1Mode); }
From source file:com.spotify.helios.master.DeadAgentReaper.java
DeadAgentReaper(final MasterModel masterModel, final long timeoutHours, final Clock clock) { this.masterModel = masterModel; checkArgument(timeoutHours > 0);/*from ww w .j a v a2 s .c o m*/ this.timeoutMillis = TimeUnit.HOURS.toMillis(timeoutHours); this.clock = clock; }
From source file:org.mitre.jwt.signer.service.impl.SymmetricCacheService.java
public SymmetricCacheService() { validators = CacheBuilder.newBuilder().expireAfterAccess(24, TimeUnit.HOURS).maximumSize(100) .build(new SymmetricValidatorBuilder()); }