Top Description Inners Fields Constructors Methods
ch.qos.logback.core.spi

public abstract Class AbstractComponentTracker<C>

extends Object
implements ComponentTracker<C>
Class Inheritance
All Implemented Interfaces
ch.qos.logback.core.spi.ComponentTracker
Known Direct Subclasses
ch.qos.logback.core.spi.CyclicBufferTracker, ch.qos.logback.core.sift.AppenderTracker
Type Parameters
<C>
component type
Imports
ch.qos.logback.core.CoreConstants, java.util.*

An abstract implementation of the ComponentTracker interface. Derived classes must implement buildComponent(String), processPriorToRemoval(Object), and isComponentStale(Object) methods as appropriate for their component type.
Authors
Tommy Becker, Ceki Gulcu, David Roussel

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static interface

Field Summary

Modifier and TypeField and Description
private static final boolean
private AbstractComponentTracker.RemovalPredicator<C>
private AbstractComponentTracker.RemovalPredicator<C>
private AbstractComponentTracker.RemovalPredicator<C>
pack-priv long
pack-priv LinkedHashMap<String, AbstractComponentTracker.Entry<C>>
public static final long
pack-priv LinkedHashMap<String, AbstractComponentTracker.Entry<C>>
protected int
protected long
public static final long
WAIT_BETWEEN_SUCCESSIVE_REMOVAL_ITERATIONS

The minimum amount of time that has to elapse between successive removal iterations.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Collection<C>
allComponents()

Implements ch.qos.logback.core.spi.ComponentTracker.allComponents.

Returns the collection of all components tracked by this instance.
public Set<String>
allKeys()

Implements ch.qos.logback.core.spi.ComponentTracker.allKeys.

Set of all keys in this tracker in no particular order.
protected abstract C
buildComponent(String key)

Build a component based on the key.

public void
endOfLife(String key)

Implements ch.qos.logback.core.spi.ComponentTracker.endOfLife.

Mark component identified by 'key' as having reached its end-of-life.
public synchronized C

Returns:

corresponding component, may be null
find
(String key)

Implements ch.qos.logback.core.spi.ComponentTracker.find.

Find the component identified by 'key', without updating the timestamp.
private void
public int
getComponentCount()

Implements ch.qos.logback.core.spi.ComponentTracker.getComponentCount.

Returns the number of components tracked.
private AbstractComponentTracker.Entry<C>
getFromEitherMap(String key)

Get an entry from the liveMap, if not found search the lingerersMap.

public int
public synchronized C
getOrCreate(String key, long timestamp)

Implements ch.qos.logback.core.spi.ComponentTracker.getOrCreate.

Get the component identified by 'key', updating its timestamp in the process.
public long
protected abstract boolean
isComponentStale(C c)

Components can declare themselves stale.

private boolean
private boolean
private boolean
protected abstract void
processPriorToRemoval(C component)

Stop or clean the component.

private void
public synchronized void
removeStaleComponents(long now)

Implements ch.qos.logback.core.spi.ComponentTracker.removeStaleComponents.

Clear (and detach) components which are stale.
private void
private void
public void
setMaxComponents(int maxComponents)

public void
setTimeout(long timeout)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ACCESS_ORDEREDback to summary
private static final boolean ACCESS_ORDERED
byExcedentback to summary
private AbstractComponentTracker.RemovalPredicator<C> byExcedent
byLingeringback to summary
private AbstractComponentTracker.RemovalPredicator<C> byLingering
byTimeoutback to summary
private AbstractComponentTracker.RemovalPredicator<C> byTimeout
lastCheckback to summary
pack-priv long lastCheck
lingerersMapback to summary
pack-priv LinkedHashMap<String, AbstractComponentTracker.Entry<C>> lingerersMap
LINGERING_TIMEOUTback to summary
public static final long LINGERING_TIMEOUT
liveMapback to summary
pack-priv LinkedHashMap<String, AbstractComponentTracker.Entry<C>> liveMap
maxComponentsback to summary
protected int maxComponents
timeoutback to summary
protected long timeout
WAIT_BETWEEN_SUCCESSIVE_REMOVAL_ITERATIONSback to summary
public static final long WAIT_BETWEEN_SUCCESSIVE_REMOVAL_ITERATIONS

The minimum amount of time that has to elapse between successive removal iterations.

Constructor Detail

AbstractComponentTrackerback to summary
public AbstractComponentTracker()

Method Detail

allComponentsback to summary
public Collection<C> allComponents()

Implements ch.qos.logback.core.spi.ComponentTracker.allComponents.

Doc from ch.qos.logback.core.spi.ComponentTracker.allComponents.

Returns the collection of all components tracked by this instance.

Returns:Collection<C>

collection of components

allKeysback to summary
public Set<String> allKeys()

Implements ch.qos.logback.core.spi.ComponentTracker.allKeys.

Doc from ch.qos.logback.core.spi.ComponentTracker.allKeys.

Set of all keys in this tracker in no particular order.

buildComponentback to summary
protected abstract C buildComponent(String key)

Build a component based on the key.

endOfLifeback to summary
public void endOfLife(String key)

Implements ch.qos.logback.core.spi.ComponentTracker.endOfLife.

Mark component identified by 'key' as having reached its end-of-life.

findback to summary
public synchronized C find(String key)

Implements ch.qos.logback.core.spi.ComponentTracker.find.

Doc from ch.qos.logback.core.spi.ComponentTracker.find.

Find the component identified by 'key', without updating the timestamp. Returns null if no corresponding component could be found.

Note that this method is synchronized.

Returns:C

corresponding component, may be null

genericStaleComponentRemoverback to summary
private void genericStaleComponentRemover(LinkedHashMap<String, AbstractComponentTracker.Entry<C>> map, long now, AbstractComponentTracker.RemovalPredicator<C> removalPredicator)
getComponentCountback to summary
public int getComponentCount()

Implements ch.qos.logback.core.spi.ComponentTracker.getComponentCount.

Doc from ch.qos.logback.core.spi.ComponentTracker.getComponentCount.

Returns the number of components tracked.

Returns:int

number of components

getFromEitherMapback to summary
private AbstractComponentTracker.Entry<C> getFromEitherMap(String key)

Get an entry from the liveMap, if not found search the lingerersMap.

getMaxComponentsback to summary
public int getMaxComponents()
getOrCreateback to summary
public synchronized C getOrCreate(String key, long timestamp)

Implements ch.qos.logback.core.spi.ComponentTracker.getOrCreate.

Doc from ch.qos.logback.core.spi.ComponentTracker.getOrCreate.

Get the component identified by 'key', updating its timestamp in the process. If the corresponding component could not be found, it is created.

Note that this method is atomic, i.e. synchronized.

getTimeoutback to summary
public long getTimeout()
isComponentStaleback to summary
protected abstract boolean isComponentStale(C c)

Components can declare themselves stale. Such components may be removed before they time out.

isEntryDoneLingeringback to summary
private boolean isEntryDoneLingering(AbstractComponentTracker.Entry<C> entry, long now)
isEntryStaleback to summary
private boolean isEntryStale(AbstractComponentTracker.Entry<C> entry, long now)
isTooSoonForRemovalIterationback to summary
private boolean isTooSoonForRemovalIteration(long now)
processPriorToRemovalback to summary
protected abstract void processPriorToRemoval(C component)

Stop or clean the component.

removeExcedentComponentsback to summary
private void removeExcedentComponents()
removeStaleComponentsback to summary
public synchronized void removeStaleComponents(long now)

Implements ch.qos.logback.core.spi.ComponentTracker.removeStaleComponents.

Clear (and detach) components which are stale. Components which have not been accessed for more than a user-specified duration are deemed stale.

removeStaleComponentsFromLingerersMapback to summary
private void removeStaleComponentsFromLingerersMap(long now)
removeStaleComponentsFromMainMapback to summary
private void removeStaleComponentsFromMainMap(long now)
setMaxComponentsback to summary
public void setMaxComponents(int maxComponents)
setTimeoutback to summary
public void setTimeout(long timeout)
ch.qos.logback.core.spi back to summary

private Class AbstractComponentTracker.Entry<C>

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv C
pack-priv String
pack-priv long

Constructor Summary

AccessConstructor and Description
pack-priv
Entry(String k, C c, long timestamp)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public void
setTimestamp(long timestamp)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

componentback to summary
pack-priv C component
keyback to summary
pack-priv String key
timestampback to summary
pack-priv long timestamp

Constructor Detail

Entryback to summary
pack-priv Entry(String k, C c, long timestamp)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
setTimestampback to summary
public void setTimestamp(long timestamp)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
ch.qos.logback.core.spi back to summary

private Interface AbstractComponentTracker.RemovalPredicator<C>


Method Summary

Modifier and TypeMethod and Description
public boolean

Method Detail

isSlatedForRemovalback to summary
public boolean isSlatedForRemoval(AbstractComponentTracker.Entry<C> entry, long timestamp)