/** * Returns a {@link FrozenRollUpStructure}, frozen at now. */ public FrozenRollUpStructure getStructure() { return struct.freeze(timeSvc.nowNanoTime()); }
public List<ActiveAgent> getActiveAgents() { pruneAgents(timeSvc.nowMillis()); synchronized(timeoutList) { if (timeoutList.isEmpty()) { return Collections.emptyList(); } else { return new ArrayList<ActiveAgent>(timeoutList); } } }
/** * 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; }
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(); } }
public Map<ServerResource, ActiveAgent> getActiveAgentMap() { pruneAgents(timeSvc.nowMillis()); synchronized(agentMap) { if (agentMap.isEmpty()) { return Collections.emptyMap(); } else { return new HashMap<ServerResource, ActiveAgent>(agentMap); } } }
public boolean purgeBefore(Time endTime) { if (endTime.isAfter(timeSvc.nowNanoTime())) { nukeTheWorld(); return true; } GranularityTimes oldestAllowedTimes = getOldestAllowedTimesOrEndTime(endTime); return lockAndPurgeAllBefore(oldestAllowedTimes); }
public void initialize(ServerResource serverResource, InsightAgentRuntimeState agentState, int currentBeat, Time senderTime) { this.server = serverResource; this.config = agentState; this.expectedBeat = currentBeat + 1; this.agentTimestamp = timeSvc.nowMillis(); this.senderTimestamp = senderTime.getMillis(); this.beatsSynchronized = false; updateTrackedStateValues(agentState); }
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; }
/** * Update the timestamp of this agent, and set * the beatsSynchronized flag if the expected * beat does not match the one given. * * @param agentState New configuration for the agent. If null, it is assumed that the * current configuration is the same as the last. * @param currBeat Current beat count value * @param senderTime Reported agent {@link Time} value */ public final void update(InsightAgentRuntimeState agentState, int currBeat, Time senderTime) { if (expectedBeat != currBeat) { beatsSynchronized = false; expectedBeat = currBeat; } else { beatsSynchronized = true; } expectedBeat++; // Only update the configuration if there is a configuration to update if (agentState != null) { updateConfig(agentState); } agentTimestamp = timeSvc.nowMillis(); senderTimestamp = senderTime.getMillis(); }
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; }
long currentTime = timeSvc.nowMillis(); long expiredTime = currentTime - ACTIVE_AGENT_TIMEOUT_MS; if (lastChangedEvent.get() > expiredTime) {
/** * 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());