Ableverse™
TOB 6.0

av.tob
Class OnlinePriority

java.lang.Object
  extended by av.tob.OnlinePriority

public abstract class OnlinePriority
extends Object

At runtime, TOB tends to set as more objects online as possible regarding the jvm memory condition and online priorities returned by TheObject.getOnlinePriority(). How the returned value is interpreted by TOB and how it affects an object's online state swapping are explained here. The priority is approximate to 100 * the threshold percentage of free jvm memory above which an object should be kept in memory, aka being online. This rule of thumb is only approximately and is not precisely guaranteed for implementations are limited by the java garbage collector algorithm. The smaller the value is, the higher the priority that object is to be kept in memory (aka being online) And another important effect of the priority value is used to determin the loading order upon TOB initialization - at startup, TOB will load objects from those with the smallest priority values, until reach its concerted memory usage. Though TOB can always load objects that cross connected precisely (thus a unloaded object will be triggered a load if any other object in its connection network are loaded), first load objects only being referenced than those referencing others can somewhat reduce the trigger queue size during the chained process thus might be a little memory economic. Note the priority category/value of a persistent object are only meant during initial loading procedure upon TOB initialization and for TOB runtime space management policy. Any time the application code explicitly requires an existing persistent object from TOB, it will be set online (load into mem and resolve connections) if not already and returned. Unless a loading was initiated but the jvm experienced critical low mem condition during loading and resolving process that a OutOfMemoryError was thrown. See each constant's description for more information.

Author:
Compl
See Also:
TheObject.getOnlinePriority(), TheObject.setOnlinePriority(short)

Field Summary
static short ALWAYS
          For p <= 300 - Strong Reference.
static short FREQUENT
          For 300 < p <= 3000 - Strong Reference + Soft Reference.
static short NORMAL
          For 3000 < p < 7000 (between FREQUENT and RARE) - Soft Reference.
static short PERREAD
          For p >= 9700 - No Reference.
static short RARE
          For 7000 <= p < 9700 - Weak Reference.
 
Constructor Summary
OnlinePriority()
           
 
Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALWAYS

public static final short ALWAYS
For p <= 300 - Strong Reference.

Objects with priorities in this category will never be garbage collected unless TOB shutdown. They will be definitly loaded automatically upon each TOB initialization.

Try live with as small number of objects in this category as possible, especially in servers with tight memory budget.

See Also:
Constant Field Values

FREQUENT

public static final short FREQUENT
For 300 < p <= 3000 - Strong Reference + Soft Reference.

The strong reference will be cleared under detected low free memory condition, if free memory percentage drops below (p/100)%, TOB will set the strong reference to null, so later it may be cleared by java gc.

Objects with priorities in this category will not be discarded unless free mem drops under 30% (the smaller the value, the harder to drive them out of runtime TOB space). But due to unpredictability of java garbage collector, it is not guaranteed objects with priorities in this category get discarded AFTER those in NORMAL cagetory and lower when free mem is below 30%.

And at the same time TOB's dectection of low mem condition and clearing of strong references are not conscientious, just because TOB has no way to listen to the gc's complain about memory urgency. So finally there is NO guarantee that all objects in this category should be discarded before letting the jvm throw a OutOfMemoryError and terminate.

This category is suitable for frequently used objects.

See Also:
Constant Field Values

NORMAL

public static final short NORMAL
For 3000 < p < 7000 (between FREQUENT and RARE) - Soft Reference.

Objects with priorities in this category are kept by TOB via SoftReference, those may be automatically cleared by java garbage collector when it feels hungry for memory. But soft references to objects with present strong references to the referees are guaranteed never cleared, so long as these objects are used in the application code, they will remain online once ever been. Maybe the condition get beneath 30% free memory is commonly not urgent enough to drive java gc start collecting soft reachable objects, so objects in this category are possibly to be discard after objects in FREQUENT category.

Most mundane objects fall into this category.

See Also:
Constant Field Values

RARE

public static final short RARE
For 7000 <= p < 9700 - Weak Reference.

Objects in this category are kept by TOB via WeakReference, those may be automatically cleared by java garbage collector when it decids to, not necessarily under low mem condition. But weak references to objects with present strong references to the referees are guaranteed never cleared, so long as these objects are used in the application code, they will remain online once ever been.

This category is ideal for rarely used objects.

See Also:
Constant Field Values

PERREAD

public static final short PERREAD
For p >= 9700 - No Reference.

Objects in this category are never kept by TOB, instead, TOB load them once on each request.

Warning: Unless objects at this priority are immutable after creation, it is likely to break data integrity of TOB. The special behavior of this category can make TOB supply mutiple copies of one single persistent object to the application code, while in all other categories TOB can guarantee that only one copy for a single persistent object will be provided to all applications in the jvm at any particular time. This special behavior raises risks that potentially break imposed isolation level for data integrity, which in all other categories TOB can guarantee.

Use this category at your own risk, if you ever decided it is absolutly necessary.

See Also:
Constant Field Values
Constructor Detail

OnlinePriority

public OnlinePriority()

Ableverse™
TOB 6.0

Copyright© 2006 Ableverse Platform. All rights reserved.