Package es.bsc.dataclay.heap
Class ExecutionEnvironmentHeapManager
- java.lang.Object
-
- java.util.TimerTask
-
- es.bsc.dataclay.heap.HeapManager
-
- es.bsc.dataclay.heap.ExecutionEnvironmentHeapManager
-
- All Implemented Interfaces:
Runnable
public class ExecutionEnvironmentHeapManager extends HeapManager
This class is responsible to manage objects in EE memory and update or store them in disk.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<ObjectID,DataClayObject>
retainedObjects
It is very important to be a sorted list, so first elements to arrive are cleaned before, in any deserialization from DB or parameter, objects deserialized first are referrers to objects deserialized later.-
Fields inherited from class es.bsc.dataclay.heap.HeapManager
DEBUG_ENABLED, inmemoryObjects, logger, runtime
-
-
Constructor Summary
Constructors Constructor Description ExecutionEnvironmentHeapManager(DataServiceRuntime theruntime)
Contructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToHeap(DataClayObject dcObject)
Add object into Heap.void
flushAll()
Update all objects in memory (or store them if new).DataClayExecutionObject
getObject(ObjectID objectID)
Get object from HeapSet<ObjectID>
getObjectIDsRetained()
Get object ids retainedvoid
releaseFromHeap(ObjectID objectID)
Release hard reference to object with ID provided.void
retainInHeap(DataClayObject object)
Add a new Hard reference to the object provided.void
run()
-
Methods inherited from class es.bsc.dataclay.heap.HeapManager
addToHeapMap, cleanReferencesAndLockers, existsObject, heapSize, numLoadedObjs, removeFromHeap, updateObjectID
-
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
-
-
-
-
Field Detail
-
retainedObjects
protected final Map<ObjectID,DataClayObject> retainedObjects
It is very important to be a sorted list, so first elements to arrive are cleaned before, in any deserialization from DB or parameter, objects deserialized first are referrers to objects deserialized later. Second ones cannot be GC if first ones are not cleaned. During GC,we should know that somehow. It's a hint but improves GC a lot. List must be thread-safe!! NOTE: Java concurrent hash map is more efficient than list. However, no insertion order is mantained. ConcurrentHashMap gain in performance is more than being unable to clean some objecs since it is in Critical Path (creation of objects).
-
-
Constructor Detail
-
ExecutionEnvironmentHeapManager
public ExecutionEnvironmentHeapManager(DataServiceRuntime theruntime)
Contructor.- Parameters:
theruntime
- The DataServiceRuntime.
-
-
Method Detail
-
getObjectIDsRetained
public final Set<ObjectID> getObjectIDsRetained()
Get object ids retained- Returns:
- object ids retained
-
getObject
public DataClayExecutionObject getObject(ObjectID objectID)
Description copied from class:HeapManager
Get object from Heap- Overrides:
getObject
in classHeapManager
- Parameters:
objectID
- ID of object- Returns:
- DataClayObject or NULL if not found.
-
addToHeap
public void addToHeap(DataClayObject dcObject)
Description copied from class:HeapManager
Add object into Heap. This function can be different in EE or client. Therefore, it is abstract.- Specified by:
addToHeap
in classHeapManager
- Parameters:
dcObject
- the object to add
-
retainInHeap
public void retainInHeap(DataClayObject object)
Add a new Hard reference to the object provided. All code in stubs/exec classes using objects in dataClayheap are using weak references. In order to avoid objects to be GC without a flush in DB, HeapManager has hard-references to them and is the only one able to release them. This function creates the hard-reference.- Parameters:
object
- Object to add
-
releaseFromHeap
public final void releaseFromHeap(ObjectID objectID)
Release hard reference to object with ID provided. Without hard reference, the object can be Garbage collected by Java GC.- Parameters:
objectID
- ID of the object
-
flushAll
public void flushAll()
Update all objects in memory (or store them if new). Function called at shutdown.- Specified by:
flushAll
in classHeapManager
-
-