/** * {@inheritDoc} * * <p>Note that this method is atomic, i.e. synchronized.</p> * * @param key {@inheritDoc} * @param timestamp {@inheritDoc} * @return {@inheritDoc} */ public synchronized C getOrCreate(String key, long timestamp) { Entry<C> entry = getFromEitherMap(key); if (entry == null) { C c = buildComponent(key); entry = new Entry(key, c, timestamp); // new entries go into the main map liveMap.put(key, entry); } else { entry.setTimestamp(timestamp); } return entry.component; }
private void removeStaleComponentsFromMainMap(long now) { genericStaleComponentRemover(liveMap, now, byTimeout); }
private boolean isEntryStale(Entry<C> entry, long now) { // stopped or improperly started appenders are considered stale // see also http://jira.qos.ch/browse/LBCLASSIC-316 C c = entry.component; if (isComponentStale(c)) return true; return ((entry.timestamp + timeout) < now); }
/** * Clear (and detach) components which are stale. Components which have not * been accessed for more than a user-specified duration are deemed stale. * * @param now */ public synchronized void removeStaleComponents(long now) { if (isTooSoonForRemovalIteration(now)) return; removeExcedentComponents(); removeStaleComponentsFromMainMap(now); removeStaleComponentsFromLingerersMap(now); }
/** * {@inheritDoc} * * <p>Note that this method is synchronized.</p> * * @param key {@inheritDoc} * @return {@inheritDoc} * */ public synchronized C find(String key) { Entry<C> entry = getFromEitherMap(key); if (entry == null) return null; else return entry.component; }
private void genericStaleComponentRemover(LinkedHashMap<String, Entry<C>> map, long now, RemovalPredicator<C> removalPredicator) { Iterator<Map.Entry<String, Entry<C>>> iter = map.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<String, Entry<C>> mapEntry = iter.next(); Entry<C> entry = mapEntry.getValue(); if (removalPredicator.isSlatedForRemoval(entry, now)) { iter.remove(); C c = entry.component; processPriorToRemoval(c); } else { break; } } }
/** * Clear (and detach) components which are stale. Components which have not * been accessed for more than a user-specified duration are deemed stale. * * @param now */ public synchronized void removeStaleComponents(long now) { if (isTooSoonForRemovalIteration(now)) return; removeExcedentComponents(); removeStaleComponentsFromMainMap(now); removeStaleComponentsFromLingerersMap(now); }
/** * {@inheritDoc} * * <p>Note that this method is synchronized.</p> * * @param key {@inheritDoc} * @return {@inheritDoc} * */ public synchronized C find(String key) { Entry<C> entry = getFromEitherMap(key); if (entry == null) return null; else return entry.component; }
private void genericStaleComponentRemover(LinkedHashMap<String, Entry<C>> map, long now, RemovalPredicator<C> removalPredicator) { Iterator<Map.Entry<String, Entry<C>>> iter = map.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<String, Entry<C>> mapEntry = iter.next(); Entry<C> entry = mapEntry.getValue(); if (removalPredicator.isSlatedForRemoval(entry, now)) { iter.remove(); C c = entry.component; processPriorToRemoval(c); } else { break; } } }
/** * Clear (and detach) components which are stale. Components which have not * been accessed for more than a user-specified duration are deemed stale. * * @param now */ public synchronized void removeStaleComponents(long now) { if (isTooSoonForRemovalIteration(now)) return; removeExcedentComponents(); removeStaleComponentsFromMainMap(now); removeStaleComponentsFromLingerersMap(now); }
/** * {@inheritDoc} * * <p>Note that this method is atomic, i.e. synchronized.</p> * * @param key {@inheritDoc} * @param timestamp {@inheritDoc} * @return {@inheritDoc} */ public synchronized C getOrCreate(String key, long timestamp) { Entry<C> entry = getFromEitherMap(key); if (entry == null) { C c = buildComponent(key); entry = new Entry<C>(key, c, timestamp); // new entries go into the main map liveMap.put(key, entry); } else { entry.setTimestamp(timestamp); } return entry.component; }
private void removeExcedentComponents() { genericStaleComponentRemover(liveMap, 0, byExcedent); }
private boolean isEntryStale(Entry<C> entry, long now) { // stopped or improperly started appenders are considered stale // see also http://jira.qos.ch/browse/LBCLASSIC-316 C c = entry.component; if (isComponentStale(c)) return true; return ((entry.timestamp + timeout) < now); }
/** * {@inheritDoc} * * <p>Note that this method is synchronized.</p> * * @param key {@inheritDoc} * @return {@inheritDoc} * */ public synchronized C find(String key) { Entry<C> entry = getFromEitherMap(key); if (entry == null) return null; else return entry.component; }
private void genericStaleComponentRemover(LinkedHashMap<String, Entry<C>> map, long now, RemovalPredicator<C> removalPredicator) { Iterator<Map.Entry<String, Entry<C>>> iter = map.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<String, Entry<C>> mapEntry = iter.next(); Entry<C> entry = mapEntry.getValue(); if (removalPredicator.isSlatedForRemoval(entry, now)) { iter.remove(); C c = entry.component; processPriorToRemoval(c); } else { break; } } }
/** * Clear (and detach) components which are stale. Components which have not * been accessed for more than a user-specified duration are deemed stale. * * @param now */ public synchronized void removeStaleComponents(long now) { if (isTooSoonForRemovalIteration(now)) return; removeExcedentComponents(); removeStaleComponentsFromMainMap(now); removeStaleComponentsFromLingerersMap(now); }
/** * {@inheritDoc} * * <p>Note that this method is atomic, i.e. synchronized.</p> * * @param key {@inheritDoc} * @param timestamp {@inheritDoc} * @return {@inheritDoc} */ public synchronized C getOrCreate(String key, long timestamp) { Entry<C> entry = getFromEitherMap(key); if (entry == null) { C c = buildComponent(key); entry = new Entry<C>(key, c, timestamp); // new entries go into the main map liveMap.put(key, entry); } else { entry.setTimestamp(timestamp); } return entry.component; }
private void removeStaleComponentsFromLingerersMap(long now) { genericStaleComponentRemover(lingerersMap, now, byLingering); }
private boolean isEntryStale(Entry<C> entry, long now) { // stopped or improperly started appenders are considered stale // see also http://jira.qos.ch/browse/LBCLASSIC-316 C c = entry.component; if (isComponentStale(c)) return true; return ((entry.timestamp + timeout) < now); }
/** * {@inheritDoc} * * <p>Note that this method is synchronized.</p> * * @param key {@inheritDoc} * @return {@inheritDoc} * */ public synchronized C find(String key) { Entry<C> entry = getFromEitherMap(key); if (entry == null) return null; else return entry.component; }