/** * Returns a {@link FrozenRollUpStructure}, frozen at now. */ public FrozenRollUpStructure getStructure() { return struct.freeze(timeSvc.nowNanoTime()); }
boolean lockAndPurgeAllBefore(GranularityTimes oldestAllowedTimes) { Time running = timeSvc.nowNanoTime().minus(lastPurgeStartTime.get()); if (purgeLock.tryLock() == false) { if (running.getSeconds() > 1) { // Avoid warning on quick purge attempts log.warn("Attempted to purge, but purge is already running. It has been running for " + running.getSeconds() + " seconds"); } return false; } lastPurgeStartTime.set(timeSvc.nowNanoTime()); try { return purgeAllBefore(oldestAllowedTimes) != 0; } finally { purgeLock.unlock(); } }
/** * Waits for the license manager to update the license state. The manager * may update the state in an asynchronous fashion. This method waits until * the state's {@link com.springsource.vfabric.licensing.state.LicenseState#getTimestamp()} * is after the given time. * * @param timestampAfter The resulting state will have a timestamp > timestampAfter * @param timeout How long should we wait before returning? * * @return null if an updated license state could not be obtained */ LicenseState awaitStateUpdate(Date timestampAfter, Time timeout) { Time now = timeSvc.nowNanoTime(); Time end = now.plus(timeout); while (now.isBefore(end)) { LicenseState state = licenseManager.getComponentLicenseState(); if (state != null && state.getTimestamp().after(timestampAfter)) { return state; } timeSvc.sleep(Time.inSeconds(1)); now = timeSvc.nowNanoTime(); } return null; }
public boolean purgeBefore(Time endTime) { if (endTime.isAfter(timeSvc.nowNanoTime())) { nukeTheWorld(); return true; } GranularityTimes oldestAllowedTimes = getOldestAllowedTimesOrEndTime(endTime); return lockAndPurgeAllBefore(oldestAllowedTimes); }
boolean iAmLicensed() { Date stateTimestamp = timeSvc.nowNanoTime().minus(Time.inSeconds(1)).asDate(); Time timeout = LICENSE_ACQUIRE_TIMEOUT; LicenseState state = awaitStateUpdate(stateTimestamp, timeout); if (state == null) { log.warn("Unable to retrieve license state after " + stateTimestamp + " in " + timeout.getSeconds() + " seconds"); return false; } if (state.getTotalAvailable() < 1) { log.warn("No available licenses found. totalAvailable=" + state.getTotalAvailable() + " totalUsed=" + state.getTotalUsed()); return false; } return true; }
public synchronized int purgeExpiredData() { Time endTime = timeSvc.nowNanoTime().minus(defaultMSAged); int totalDeleted = 0; try { setPurgeProgress("Starting purge of data older than " + endTime.asDate()); totalDeleted = purgeData(endTime); } finally { endIncrementalPurgeProgress(); } return totalDeleted; }
/** * Returns a map from granularity to the oldest datapoint which should * exist for it. */ GranularityTimes getOldestAllowedTimeForGranularity() { Time now = timeSvc.nowNanoTime(); FrozenRollUpStructure frozenStruct = this.struct.freeze(now); GranularityTimes res = new GranularityTimes(); for (FrozenGranularityLayer layer : frozenStruct.getFrozenLayers()) { res.put(layer.getGranularity(), layer.getTotalRange().getStartTime()); } return res; }
log.warn("Dropping metric data at timestamp=" + val.getTimeStamp().asDate() + " which is out" + "of storage bounds. All systems pushing data to Insight should use NTP or another service to keep clocks " + "synchronized. Current time = " + timeSvc.nowNanoTime().asDate());