/** Inactivity checker, run in a seperate thread */ public void run() { // DEBUG if (logger.isDebugEnabled()) logger.debug("Content quota manager checker thread starting"); // Loop forever StringList removeNameList = new StringList(); m_shutdown = false; while (m_shutdown == false) { // Sleep for the required interval try { Thread.sleep(UserQuotaCheckInterval); } catch (InterruptedException ex) { } // Check for shutdown if (m_shutdown == true) { // Debug if (logger.isDebugEnabled()) logger.debug("Content quota manager checker thread closing"); return; } // Check if there are any user quota details to check synchronized (m_liveUsageLock) { if (m_liveUsage != null && m_liveUsage.size() > 0) { try { // Timestamp to check if the quota details is inactive long checkTime = System.currentTimeMillis() - UserQuotaExpireInterval; // Loop through the user quota details removeNameList.remoteAllStrings(); Iterator<String> userNames = m_liveUsage.keySet().iterator(); while (userNames.hasNext()) { // Get the user quota details and check if it has been inactive in the last check // interval String userName = userNames.next(); UserQuotaDetails quotaDetails = m_liveUsage.get(userName); synchronized (quotaDetails) { if (quotaDetails.getLastUpdated() < checkTime) { // Add the user name to the remove list, inactive removeNameList.addString(userName); } } } // Remove inactive records from the live quota tracking while (removeNameList.numberOfStrings() > 0) { // Get the current user name and remove the record String userName = removeNameList.removeStringAt(0); UserQuotaDetails quotaDetails = m_liveUsage.remove(userName); // DEBUG if (logger.isDebugEnabled()) logger.debug("Removed inactive usage tracking, " + quotaDetails); } } catch (Exception ex) { // Log errors if not shutting down if (m_shutdown == false) logger.debug(ex); } } } } }