public Map<ServerResource, ActiveAgent> getActiveAgentMap() { pruneAgents(timeSvc.nowMillis()); synchronized(agentMap) { if (agentMap.isEmpty()) { return Collections.emptyMap(); } else { return new HashMap<ServerResource, ActiveAgent>(agentMap); } } }
public List<ActiveAgent> getActiveAgents() { pruneAgents(timeSvc.nowMillis()); synchronized(timeoutList) { if (timeoutList.isEmpty()) { return Collections.emptyList(); } else { return new ArrayList<ActiveAgent>(timeoutList); } } }
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); }
/** * 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(); }
long currentTime = timeSvc.nowMillis(); long expiredTime = currentTime - ACTIVE_AGENT_TIMEOUT_MS; if (lastChangedEvent.get() > expiredTime) {