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:dk.dma.navnet.client.AbstractClientConnectionTest.java
@Before public void before() { clientPort = ThreadLocalRandom.current().nextInt(40000, 50000); ws = new TestWebSocketServer(clientPort); ws.start();//from ww w . j a v a2 s . co m t = ws.addEndpoint(new TestClientEndpoint()); conf = MaritimeCloudClientConfiguration.create(ID1); conf.setHost("localhost:" + clientPort); conf.setKeepAlive(1, TimeUnit.HOURS); }
From source file:com.spotify.helios.master.reaper.DeadAgentReaper.java
@VisibleForTesting DeadAgentReaper(final MasterModel masterModel, final long timeoutHours, final Clock clock, final double permitsPerSecond, final int initialDelay) { super(permitsPerSecond, initialDelay, DELAY, TIME_UNIT); this.masterModel = masterModel; checkArgument(timeoutHours > 0);//from w ww . j a v a 2 s . c o m this.timeoutMillis = TimeUnit.HOURS.toMillis(timeoutHours); this.clock = clock; }
From source file:org.libreoffice.impressremote.fragment.TimerEditingDialog.java
private int getMinutes(int aMinutes) { return (int) (aMinutes - getHours(aMinutes) * TimeUnit.HOURS.toMinutes(1)); }
From source file:com.lostrealm.lembretes.DownloadJob.java
private static void schedulePeriodic() { new JobRequest.Builder(PERIODIC).setPeriodic(TimeUnit.HOURS.toMillis(7), TimeUnit.MINUTES.toMillis(15)) .setRequiredNetworkType(JobRequest.NetworkType.CONNECTED).setPersisted(true).setUpdateCurrent(true) .build().schedule();/*from w w w . j a v a 2s .c o m*/ }
From source file:com.esofthead.mycollab.module.ecm.esb.impl.SaveContentCommandImpl.java
@Override public void saveContent(Content content, String createdUser, Integer sAccountId) { LOG.debug("Save content {} by {}", BeanUtility.printBeanObj(content), createdUser); if (sAccountId == null) { return;//from w w w.j a v a 2 s .c o m } Lock lock = DistributionLockUtil.getLock("ecm-" + sAccountId); long totalSize = content.getSize(); if (StringUtils.isNotBlank(content.getThumbnail())) { totalSize += rawContentService.getSize(content.getThumbnail()); } try { if (lock.tryLock(1, TimeUnit.HOURS)) { DriveInfo driveInfo = driveInfoService.getDriveInfo(sAccountId); if (driveInfo.getUsedvolume() == null) { driveInfo.setUsedvolume(totalSize); } else { driveInfo.setUsedvolume(totalSize + driveInfo.getUsedvolume()); } driveInfoService.saveOrUpdateDriveInfo(driveInfo); } } catch (Exception e) { LOG.error("Error while save content " + BeanUtility.printBeanObj(content), e); } finally { lock.unlock(); } }
From source file:org.wso2.carbon.dataservices.google.tokengen.servlet.util.CodeHolder.java
/** * Private constructor to make the class singleton and start the cleanup process. *//*from w w w. j ava2s .c o m*/ private CodeHolder() { if (GoogleTokenGenDSComponent.getHazelcastInstance() != null) { log.info("Creating Hazelcast map to store OAuth Codes"); authCodes = GoogleTokenGenDSComponent.getHazelcastInstance().getMap("GOOGLE_TOKENGEN_AUTHCODE_HOLDER"); } else { log.info("Creating simple HashMap to store OAuth Codes since clustering is not enabled"); authCodes = new HashMap<String, AuthCode>(2); } //retry interval 1 hour long interval = 1; //expiration time in milliseconds - default set to 30 mins. expirationTime = 1000 * 60 * 30; globalExecutorService = Executors.newSingleThreadScheduledExecutor(); globalExecutorService.scheduleAtFixedRate(this, interval, interval, TimeUnit.HOURS); }
From source file:org.apache.lens.server.user.DatabaseUserConfigLoader.java
/** * Instantiates a new database user config loader. * * @param conf the conf//from w w w . java 2s . co m * @throws UserConfigLoaderException the user config loader exception */ public DatabaseUserConfigLoader(HiveConf conf) throws UserConfigLoaderException { this.hiveConf = conf; querySql = conf.get(LensConfConstants.USER_RESOLVER_DB_QUERY); keys = conf.get(LensConfConstants.USER_RESOLVER_DB_KEYS).split("\\s*,\\s*", -1); cache = CacheBuilder.newBuilder() .expireAfterWrite(conf.getInt(LensConfConstants.USER_RESOLVER_CACHE_EXPIRY, 2), TimeUnit.HOURS) .maximumSize(conf.getInt(LensConfConstants.USER_RESOLVER_CACHE_MAX_SIZE, 100)).build(); }
From source file:org.wso2.carbon.device.mgt.core.task.impl.ArchivalTask.java
private String getDurationBreakdown(long millis) { if (millis < 0) { throw new IllegalArgumentException("Duration must be greater than zero!"); }/*from www . ja v a 2 s. co m*/ long days = TimeUnit.MILLISECONDS.toDays(millis); millis -= TimeUnit.DAYS.toMillis(days); long hours = TimeUnit.MILLISECONDS.toHours(millis); millis -= TimeUnit.HOURS.toMillis(hours); long minutes = TimeUnit.MILLISECONDS.toMinutes(millis); millis -= TimeUnit.MINUTES.toMillis(minutes); long seconds = TimeUnit.MILLISECONDS.toSeconds(millis); StringBuilder sb = new StringBuilder(64); sb.append(days); sb.append(" Days "); sb.append(hours); sb.append(" Hours "); sb.append(minutes); sb.append(" Minutes "); sb.append(seconds); sb.append(" Seconds"); return (sb.toString()); }
From source file:org.apache.hadoop.hive.common.type.HiveIntervalDayTime.java
public int getMinutes() { return (int) (TimeUnit.SECONDS.toMinutes(totalSeconds) % TimeUnit.HOURS.toMinutes(1)); }
From source file:com.janrain.backplane.server.MessageProcessor.java
@Override public void takeLeadership(CuratorFramework curatorFramework) throws Exception { setLeader(true);//w w w.ja v a2 s. c o m logger.info("[" + BackplaneSystemProps.getMachineName() + "] v1 leader elected for message processing"); ScheduledFuture<?> cleanupTask = scheduledExecutor.scheduleAtFixedRate(cleanupRunnable, 2, 2, TimeUnit.HOURS); insertMessages(); cleanupTask.cancel(false); logger.info("[" + BackplaneSystemProps.getMachineName() + "] v1 leader ended message processing"); }