public static final class CacheManager.CacheFlusher extends java.lang.Object
Configure the asynchronous thread that periodically removes instances from all active caches, flush notifications, and support for explicit object flushing.
Modifier and Type | Method and Description |
---|---|
static Notifier<?> |
clearNotifier(java.lang.Class<?> managedClass)
Clear the flush notifier for the given managed class.
|
static void |
flush(java.lang.Object object)
Flush a Managed object from shared memory.
|
void |
setFlushIntervalSeconds(long seconds)
Set the number of seconds to sleep between runs of the flusher.
|
void |
setMaximumObjectsPerFlush(long numberObjects)
Set the maximum number of object instances to flush.
|
static Notifier<?> |
setNotifier(Notifier<?> notifier)
Associate a flush notifier with a Managed class.
|
public void setFlushIntervalSeconds(long seconds) throws java.lang.IllegalArgumentException
The default value is to have the flusher run every second, a value of 0 disables the flusher. Note that disabling the flusher will allow caches bounded by size to exceed their configured sizes.
seconds
- Number of seconds.java.lang.IllegalArgumentException
- The seconds value is negative.public void setMaximumObjectsPerFlush(long numberObjects) throws java.lang.IllegalArgumentException
Sets the number of object instances to flush each time the flush thread executes. A value of 0 indicates no limit.
numberObjects
- Maximum number of objects to flush.java.lang.IllegalArgumentException
- The numberObjects value is negative.public static final Notifier<?> setNotifier(Notifier<?> notifier) throws ManagedClassError
The Managed class is the type T from the user implementation
of Notifier
If a Notifier instance is already associated with a class,
the new value overwrites the previous one. The lifecycle of
the returned instance is not affected.
The system automatically unregisters the passed in Notifier
instance when this JVM shutdowns down. The lifecycle of
the Notifier instance is not affected. If the JVM is
restarted, the Notifer is not automatically reregistered.
Inheritance
The Notifier will also be used for any classes which
extend type T which don't have their own Notifier set.
During an object flush, if there are Notifiers set on
multiple classes in the inheritance chain, only a single
Notifier will be called.
The Notifier is selected by first looking at the target
object's class, and if no Notifier is set, searching up
the inheritance chain until a Notifier is found.
notifier
- User defined Notifier instance.ManagedClassError
- The managedClass is not a Managed object.clearNotifier(java.lang.Class<?>)
public static final Notifier<?> clearNotifier(java.lang.Class<?> managedClass) throws ManagedClassError
If no flush notifier is associated with the managed class, this operation does nothing.
Notifiers registered for parent or child classes are not affected.
managedClass
- Managed object class.ManagedClassError
- The managedClass parameter is not a Managed class.setNotifier(com.kabira.platform.flusher.Notifier<?>)
public static void flush(java.lang.Object object) throws ManagedClassError
If the operand is a partitioned object on the active node the flush is equivalent to ManagedObject.delete() and will remove the object and its keys for all nodes in its partition.
If the operand is a partitioned object on a replica node, no action is taken.
If the operand is a non-partitioned, remote object, it will be removed along with its keys, from the local node, where flush() is being invoked.
If the operand is a local object, flush is equivalent to ManagedObject.delete().
Delete Triggers
Any defined delete triggers will be called on the local node for flushes of local objects and partitioned objects on the active node.
Flush Notifier
If a flush Notifier has been set for the class type of the operand (or a class in its parent inheritance chain), it is called before the flush occurs. If the Notifier.isFlushable() method returns false flush() returns immediately without having flushed the operand. See the setNotifier Inheritance section for for a description of how the Notifier is chosen.
object
- Object to flush.ManagedClassError
- if object is not Managed.setNotifier(com.kabira.platform.flusher.Notifier<?>)
,
Notifier
,
DeleteTrigger