Class IdlePurgePolicy
java.lang.Object
org.apache.logging.log4j.core.AbstractLifeCycle
org.apache.logging.log4j.core.appender.routing.IdlePurgePolicy
- All Implemented Interfaces:
Runnable,PurgePolicy,LifeCycle,LifeCycle2
@Plugin(name="IdlePurgePolicy",
category="Core",
printObject=true)
@Scheduled
public class IdlePurgePolicy
extends AbstractLifeCycle
implements PurgePolicy, Runnable
Policy is purging appenders that were not in use specified time in minutes
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap<String, Long> private final longprivate ScheduledFuture<?> private RoutingAppenderprivate final ConfigurationSchedulerprivate final longFields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER -
Constructor Summary
ConstructorsConstructorDescriptionIdlePurgePolicy(long timeToLive, long checkInterval, ConfigurationScheduler scheduler) -
Method Summary
Modifier and TypeMethodDescriptionstatic PurgePolicycreatePurgePolicy(String timeToLive, String checkInterval, String timeUnit, Configuration configuration) Create the PurgePolicyvoidinitialize(RoutingAppender routingAppender) Initializes with routing appendervoidpurge()Purging appenders that were not in use specified timevoidrun()private voidbooleanBlocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.toString()voidMethods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, start, stop, stop
-
Field Details
-
timeToLive
private final long timeToLive -
checkInterval
private final long checkInterval -
appendersUsage
-
routingAppender
-
scheduler
-
future
-
-
Constructor Details
-
IdlePurgePolicy
-
-
Method Details
-
initialize
Description copied from interface:PurgePolicyInitializes with routing appender- Specified by:
initializein interfacePurgePolicy- Parameters:
routingAppender-
-
stop
Description copied from interface:LifeCycle2Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.- Specified by:
stopin interfaceLifeCycle2- Overrides:
stopin classAbstractLifeCycle- Parameters:
timeout- the maximum time to waittimeUnit- the time unit of the timeout argument- Returns:
- true if the receiver was stopped cleanly and normally, false otherwise.
-
purge
public void purge()Purging appenders that were not in use specified time- Specified by:
purgein interfacePurgePolicy
-
update
- Specified by:
updatein interfacePurgePolicy- Parameters:
key- routed appender keyevent-
-
run
public void run() -
scheduleNext
private void scheduleNext() -
createPurgePolicy
@PluginFactory public static PurgePolicy createPurgePolicy(@PluginAttribute("timeToLive") String timeToLive, @PluginAttribute("checkInterval") String checkInterval, @PluginAttribute("timeUnit") String timeUnit, @PluginConfiguration Configuration configuration) Create the PurgePolicy- Parameters:
timeToLive- the number of increments of timeUnit before the Appender should be purged.checkInterval- when all appenders purged, the number of increments of timeUnit to check if any appenders appearedtimeUnit- the unit of time the timeToLive and the checkInterval is expressed in.- Returns:
- The Routes container.
-
toString
-