Package es.bsc.dataclay.heap
Class HeapManager
- java.lang.Object
-
- java.util.TimerTask
-
- es.bsc.dataclay.heap.HeapManager
-
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
ClientHeapManager
,ExecutionEnvironmentHeapManager
public abstract class HeapManager extends TimerTask
Heap manager for dataClay runtimes. This class is intended to manage all dataClay objects in runtime's memory.
-
-
Field Summary
Fields Modifier and Type Field Description protected static boolean
DEBUG_ENABLED
Indicates if debug is enabled.protected Map<ObjectID,Reference<DataClayObject>>
inmemoryObjects
Map of objects in memory.protected static org.apache.logging.log4j.Logger
logger
protected DataClayRuntime
runtime
Runtime being monitorized.
-
Constructor Summary
Constructors Constructor Description HeapManager(DataClayRuntime theruntime)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
addToHeap(DataClayObject dcObject)
Add object into Heap.protected void
addToHeapMap(DataClayObject dcObject)
Create a weak reference of the object provided and add it into the heap.void
cleanReferencesAndLockers()
Clean references in Heap pointing to null (weak references) and Lockers not being used.boolean
existsObject(ObjectID objectID)
Check if there is an object with ID provided.abstract void
flushAll()
Flush all objects in Heap.DataClayObject
getObject(ObjectID objectID)
Get object from Heapint
heapSize()
Get number of objects in memory.int
numLoadedObjs()
Get number of loaded objects in memory.void
removeFromHeap(ObjectID objectID)
Remove reference from Heap.void
updateObjectID(ObjectID oldObjectID, ObjectID newObjectID)
Update an objectID.-
Methods inherited from class java.util.TimerTask
cancel, run, scheduledExecutionTime
-
-
-
-
Field Detail
-
logger
protected static final org.apache.logging.log4j.Logger logger
-
DEBUG_ENABLED
protected static final boolean DEBUG_ENABLED
Indicates if debug is enabled.
-
runtime
protected final DataClayRuntime runtime
Runtime being monitorized.
-
inmemoryObjects
protected final Map<ObjectID,Reference<DataClayObject>> inmemoryObjects
Map of objects in memory.
-
-
Constructor Detail
-
HeapManager
public HeapManager(DataClayRuntime theruntime)
Constructor.- Parameters:
theruntime
- Runtime to manage.
-
-
Method Detail
-
cleanReferencesAndLockers
public void cleanReferencesAndLockers()
Clean references in Heap pointing to null (weak references) and Lockers not being used.
-
getObject
public DataClayObject getObject(ObjectID objectID)
Get object from Heap- Parameters:
objectID
- ID of object- Returns:
- DataClayObject or NULL if not found.
-
addToHeapMap
protected void addToHeapMap(DataClayObject dcObject)
Create a weak reference of the object provided and add it into the heap.- Parameters:
dcObject
- Object to add.
-
addToHeap
public abstract void addToHeap(DataClayObject dcObject)
Add object into Heap. This function can be different in EE or client. Therefore, it is abstract.- Parameters:
dcObject
- the object to add
-
removeFromHeap
public final void removeFromHeap(ObjectID objectID)
Remove reference from Heap. Even if we remove it from the heap, the object won't be Garbage collected by JavaGC till HeapManager flushes the object and releases it.- Parameters:
objectID
- ID of the object
-
existsObject
public final boolean existsObject(ObjectID objectID)
Check if there is an object with ID provided.- Parameters:
objectID
- ID of the object.- Returns:
- TRUE if exists in memory. FALSE otherwise.
-
heapSize
public final int heapSize()
Get number of objects in memory.- Returns:
- Number of objects in memory.
-
numLoadedObjs
public final int numLoadedObjs()
Get number of loaded objects in memory.- Returns:
- Number of loaded objects in memory.
-
flushAll
public abstract void flushAll()
Flush all objects in Heap.
-
-