@Plugin(name="IdlePurgePolicy", category="Core", printObject=true) @Scheduled public class IdlePurgePolicy extends AbstractLifeCycle implements PurgePolicy, java.lang.Runnable
LifeCycle.State
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Long> |
appendersUsage |
private long |
checkInterval |
private java.util.concurrent.ScheduledFuture<?> |
future |
private RoutingAppender |
routingAppender |
private ConfigurationScheduler |
scheduler |
private long |
timeToLive |
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
Constructor and Description |
---|
IdlePurgePolicy(long timeToLive,
long checkInterval,
ConfigurationScheduler scheduler) |
Modifier and Type | Method and Description |
---|---|
static PurgePolicy |
createPurgePolicy(java.lang.String timeToLive,
java.lang.String checkInterval,
java.lang.String timeUnit,
Configuration configuration)
Create the PurgePolicy
|
void |
initialize(RoutingAppender routingAppender)
Initializes with routing appender
|
void |
purge()
Purging appenders that were not in use specified time
|
void |
run() |
private void |
scheduleNext() |
boolean |
stop(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current
thread is interrupted, whichever happens first.
|
java.lang.String |
toString() |
void |
update(java.lang.String key,
LogEvent event) |
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, start, stop, stop
private final long timeToLive
private final long checkInterval
private final java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Long> appendersUsage
private RoutingAppender routingAppender
private final ConfigurationScheduler scheduler
private volatile java.util.concurrent.ScheduledFuture<?> future
public IdlePurgePolicy(long timeToLive, long checkInterval, ConfigurationScheduler scheduler)
public void initialize(RoutingAppender routingAppender)
PurgePolicy
initialize
in interface PurgePolicy
public boolean stop(long timeout, java.util.concurrent.TimeUnit timeUnit)
LifeCycle2
stop
in interface LifeCycle2
stop
in class AbstractLifeCycle
timeout
- the maximum time to waittimeUnit
- the time unit of the timeout argumentpublic void purge()
purge
in interface PurgePolicy
public void update(java.lang.String key, LogEvent event)
update
in interface PurgePolicy
key
- routed appender keypublic void run()
run
in interface java.lang.Runnable
private void scheduleNext()
@PluginFactory public static PurgePolicy createPurgePolicy(@PluginAttribute(value="timeToLive") java.lang.String timeToLive, @PluginAttribute(value="checkInterval") java.lang.String checkInterval, @PluginAttribute(value="timeUnit") java.lang.String timeUnit, @PluginConfiguration Configuration configuration)
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.public java.lang.String toString()
toString
in class java.lang.Object