Package es.bsc.dataclay.commonruntime
Class DataServiceRuntime
- java.lang.Object
-
- es.bsc.dataclay.commonruntime.DataClayRuntime
-
- es.bsc.dataclay.commonruntime.DataServiceRuntime
-
public final class DataServiceRuntime extends DataClayRuntime
This class contains functions for node to interact with other nodes.
-
-
Field Summary
Fields Modifier and Type Field Description DataService
dsRef
Ref to DS if this lib serves to a DS.boolean
tasksScheduled
Indicates if tasks (garbage collectors,...) were scheduled or not.-
Fields inherited from class es.bsc.dataclay.commonruntime.DataClayRuntime
aliasCache, dataClayHeapManager, dataClayObjLoader, DEBUG_ENABLED, hits, lockerPool, logicModule, metaDataCache, misses, threadPool, underDeserializationVolatiles, volatileParametersBeingSend
-
-
Constructor Summary
Constructors Constructor Description DataServiceRuntime(DataService newdsRef)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSessionReference(ObjectID objectID)
Add +1 reference associated to thread sessionvoid
checkSession(DataSetID dataSetID, SessionID sessionID)
Checks session is valid.void
cleanCaches()
Clean caches.void
closeSessionInEE(SessionID sessionID)
Close session in EE.void
deleteAlias(DataClayObject dcObject)
Method that deletes the alias of an object providedvoid
deserializeDataIntoInstance(DataClayExecutionObject instance, ObjectWithDataParamOrReturn data, Map<MetaClassID,byte[]> ifaceBitMaps)
Deserialize data into instance.void
detachObjectFromSession(ObjectID objectID, ExecutionEnvironmentID hint)
Detach object from current session in use, i.e.protected Object
executeRemoteImplementationInternal(DataClayObject object, ImplementationID implID, Object[] params)
Internal Method that executes an implementation depending on client or server.void
federateToBackend(DataClayObject dcObject, ExecutionEnvironmentID externalExecutionEnvironmentID, boolean recursive)
Federate an object with an external dataClayvoid
finishCacheThreads()
Finish cache threads.String
getClassNameInternal(MetaClassID classID)
Get class name from ID.HeapManager
getDataClayHeapManager()
Get Heap Managerprotected DataClayObjectLoader
getDataClayObjectLoader()
Get DataClay object loader.DataService
getDataService()
Get DataService referenceExecutionEnvironmentID
getExecutionEnvironmentIDOfDS()
Get ID of execution environment of this node.DataClayExecutionObject
getFromHeap(ObjectID objectID)
Get from HeapExecutionEnvironmentID
getHint()
Get hint of current backend.protected Map<MetaClassID,byte[]>
getIfaceBitMaps()
Get interface bitmaps.ExecutionEnvironmentID
getLocalBackend()
DataClayObject
getOrNewAndLoadVolatile(MetaClassID classID, ObjectID objectID, BackendID hint, ObjectWithDataParamOrReturn objWithData, Map<MetaClassID,byte[]> ifaceBitMaps)
Get from Heap or create a new volatile in EE and load data on it.DataClayExecutionObject
getOrNewInstanceFromDB(ObjectID objectID, boolean retry)
Get object from memory or database and WAIT in case we are still waiting for it to be persisted.DataClayExecutionObject
getOrNewPersistentInstance(MetaClassID classID, ObjectID objectID, BackendID hint)
Check if instance exists in Heap or create a new PERSISTENT instance if neededDataServiceAPI
getRemoteDSAPI(ExecutionEnvironmentID execLocationID)
Get remote execution environmentSet<ObjectID>
getRetainedReferences()
Get IDs of references retained by EE.SessionID
getSessionID()
Get session IDvoid
initialize(String logicModuleHost, int logicModulePort, String originHostName)
Initialize connections.boolean
isDSLib()
BackendID
makePersistent(DataClayObject dcObject, BackendID optionalDestBackendID, boolean recursive, String alias)
This method creates a new Persistent Object using the provided stub instance and, if indicated, all its associated objects also Logic module API used for communicationvoid
releaseFromHeap(ObjectID objectID)
Release hard reference to object with ID provided.void
removeCurrentThreadSessionID()
Remove session ID for threadvoid
retainInHeap(DataClayObject object)
Add a new Hard reference to the object provided.void
setCurrentThreadSessionID(SessionID sessionID)
Set session ID for threadvoid
setWeakProxy(DataClayExecutionObject instance, ExecutionEnvironmentID newHint)
Set instance to be weak proxy.void
storeObjects(SessionID sessionID, List<ObjectWithDataParamOrReturn> objsToStore)
Directly store objects in DS.void
synchronize(DataClayObject dcObject, Object[] params, ImplementationID remoteImplID)
Synchronizevoid
unfederateFromBackend(DataClayObject dcObject, ExecutionEnvironmentID externalExecutionEnvironmentID, boolean recursive)
Unfederate an object with an external backend-
Methods inherited from class es.bsc.dataclay.commonruntime.DataClayRuntime
activateTracing, activateTracingInDataClayServices, addToHeap, addVolatileUnderDeserialization, callExecuteToDS, checkAndGetSession, checkConnectionAndParams, chooseLocation, cleanLockers, consolidateVersion, deactivateTracing, deactivateTracingInDataClayServices, deleteAlias, deserializeIntoHeap, deserializeParams, deserializeReturn, executeRemoteImplementation, executeRemoteTask, existsInHeap, federateAllObjects, federateObject, finishConnections, flushAll, getAllBackendsNames, getAllExecutionEnvironmentsAtDataClay, getAllExecutionEnvironmentsAtHost, getAllExecutionEnvironmentsInfo, getAllLocations, getBackendIDFromAlias, getBackendIDFromObjectID, getBackendsWithName, getClassName, getCommonGrpcClient, getCopyOfObject, getDataClayID, getDataSetIDFromObject, getDSNameOfHint, getExecutionEnvironmentInfo, getExternalDataClayID, getExternalDataClayInfo, getLocation, getLogicModuleAPI, getNumObjects, getObjectByAlias, getObjectByAlias, getObjectIDFromAlias, getObjectInfoByAlias, getObjectMetadata, getPersistedObjectByOID, getRemoteExecutionEnvironment, getTracesInDataClayServices, heapSize, importModelsFromExternalDataClay, isInitialized, lock, migrateFederatedObjects, moveObject, newRemotePersistentInstance, newReplica, newVersion, numLoadedObjs, numLockers, objectExistsInDataClay, registerExternalDataClay, registerExternalDataClayOverrideAuthority, removeFromHeap, removeObjectMetadataFromCache, removeVolatilesUnderDeserialization, serializeParams, serializeReturn, setDataSetID, setInitialized, setObjectReadOnly, setObjectReadWrite, unfederateAllObjects, unfederateAllObjectsWithAllDCs, unfederateObject, unfederateObjectWithAllDCs, unlock, updateObject, updateObjectID, waitForAsyncRequestToFinish
-
-
-
-
Field Detail
-
dsRef
public DataService dsRef
Ref to DS if this lib serves to a DS.
-
tasksScheduled
public boolean tasksScheduled
Indicates if tasks (garbage collectors,...) were scheduled or not. This is done to manage. multiple initializations.
-
-
Constructor Detail
-
DataServiceRuntime
public DataServiceRuntime(DataService newdsRef)
Constructor.- Parameters:
newdsRef
- DS reference
-
-
Method Detail
-
initialize
public void initialize(String logicModuleHost, int logicModulePort, String originHostName) throws Exception
Initialize connections.- Overrides:
initialize
in classDataClayRuntime
- Parameters:
logicModuleHost
- Name of the host of the logic modulelogicModulePort
- Port of the logic moduleoriginHostName
- Name of the host using the lib.- Throws:
Exception
- if connection could not be done for some reason.
-
getOrNewPersistentInstance
public DataClayExecutionObject getOrNewPersistentInstance(MetaClassID classID, ObjectID objectID, BackendID hint)
Description copied from class:DataClayRuntime
Check if instance exists in Heap or create a new PERSISTENT instance if needed- Specified by:
getOrNewPersistentInstance
in classDataClayRuntime
- Parameters:
classID
- ID of the class in case it is needed (not need to query) if null, look for class id in metadata.objectID
- ID of objecthint
- Can be null. Hint in case object is a volatile in another DS and we need information.- Returns:
- Instance
-
getOrNewInstanceFromDB
public DataClayExecutionObject getOrNewInstanceFromDB(ObjectID objectID, boolean retry)
Get object from memory or database and WAIT in case we are still waiting for it to be persisted.- Parameters:
objectID
- ID of the object to getretry
- Indicates if we should retry and wait.- Returns:
- The the object.
-
getOrNewAndLoadVolatile
public DataClayObject getOrNewAndLoadVolatile(MetaClassID classID, ObjectID objectID, BackendID hint, ObjectWithDataParamOrReturn objWithData, Map<MetaClassID,byte[]> ifaceBitMaps)
Get from Heap or create a new volatile in EE and load data on it.- Overrides:
getOrNewAndLoadVolatile
in classDataClayRuntime
- Parameters:
classID
- ID of class of the objectobjectID
- ID of the objecthint
- Hint of the objectobjWithData
- Data of the objectifaceBitMaps
- Interface bitmaps- Returns:
- Loaded volatile instance in EE.
-
deserializeDataIntoInstance
public void deserializeDataIntoInstance(DataClayExecutionObject instance, ObjectWithDataParamOrReturn data, Map<MetaClassID,byte[]> ifaceBitMaps)
Deserialize data into instance.- Parameters:
instance
- Instance to be filled.data
- DataifaceBitMaps
- Interface bitmaps
-
getSessionID
public SessionID getSessionID()
Description copied from class:DataClayRuntime
Get session ID- Specified by:
getSessionID
in classDataClayRuntime
- Returns:
- Session ID
-
checkSession
public void checkSession(DataSetID dataSetID, SessionID sessionID)
Checks session is valid.- Parameters:
dataSetID
- dataSetID to be accessedsessionID
- id of the session
-
setWeakProxy
public void setWeakProxy(DataClayExecutionObject instance, ExecutionEnvironmentID newHint)
Set instance to be weak proxy.- Parameters:
instance
- Instance to modify.newHint
- Hint to set into instance.
-
executeRemoteImplementationInternal
protected Object executeRemoteImplementationInternal(DataClayObject object, ImplementationID implID, Object[] params)
Description copied from class:DataClayRuntime
Internal Method that executes an implementation depending on client or server.- Specified by:
executeRemoteImplementationInternal
in classDataClayRuntime
- Parameters:
object
- Object in which to execimplID
- Implementation IDparams
- Parameters- Returns:
- the result of execution.
-
makePersistent
public BackendID makePersistent(DataClayObject dcObject, BackendID optionalDestBackendID, boolean recursive, String alias)
Description copied from class:DataClayRuntime
This method creates a new Persistent Object using the provided stub instance and, if indicated, all its associated objects also Logic module API used for communication- Specified by:
makePersistent
in classDataClayRuntime
- Parameters:
dcObject
- Instance to make persistentoptionalDestBackendID
- Indicates which is the destination backendrecursive
- Indicates if make persistent is recursivealias
- Alias for the object- Returns:
- ID of the backend in which te object was persisted.
-
synchronize
public final void synchronize(DataClayObject dcObject, Object[] params, ImplementationID remoteImplID)
Description copied from class:DataClayRuntime
Synchronize- Specified by:
synchronize
in classDataClayRuntime
- Parameters:
dcObject
- Object used as a 'portal' to other DS.params
- Parameters to sendremoteImplID
- ID of implementation to execute
-
getClassNameInternal
public String getClassNameInternal(MetaClassID classID)
Description copied from class:DataClayRuntime
Get class name from ID.- Specified by:
getClassNameInternal
in classDataClayRuntime
- Parameters:
classID
- ID of class- Returns:
- Class name
-
setCurrentThreadSessionID
public void setCurrentThreadSessionID(SessionID sessionID)
Set session ID for thread- Parameters:
sessionID
- ID of session
-
removeCurrentThreadSessionID
public void removeCurrentThreadSessionID()
Remove session ID for thread
-
getExecutionEnvironmentIDOfDS
public ExecutionEnvironmentID getExecutionEnvironmentIDOfDS()
Get ID of execution environment of this node.- Returns:
- execution environment id
-
getRemoteDSAPI
public final DataServiceAPI getRemoteDSAPI(ExecutionEnvironmentID execLocationID)
Get remote execution environment- Overrides:
getRemoteDSAPI
in classDataClayRuntime
- Parameters:
execLocationID
- ID of remote execution environment- Returns:
- Remote execution environment
-
storeObjects
public void storeObjects(SessionID sessionID, List<ObjectWithDataParamOrReturn> objsToStore)
Directly store objects in DS.- Parameters:
sessionID
- ID of sessionobjsToStore
- serialized objects to store.
-
getDataClayHeapManager
public HeapManager getDataClayHeapManager()
Get Heap Manager- Specified by:
getDataClayHeapManager
in classDataClayRuntime
- Returns:
- Heap Manager
-
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 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
-
detachObjectFromSession
public void detachObjectFromSession(ObjectID objectID, ExecutionEnvironmentID hint)
Description copied from class:DataClayRuntime
Detach object from current session in use, i.e. remove reference from current session provided to object, "dear garbage-collector, current session is not using the object anymore"- Specified by:
detachObjectFromSession
in classDataClayRuntime
- Parameters:
objectID
- ID of the object to detachhint
- Hint of the object to detach (can be null)
-
deleteAlias
public void deleteAlias(DataClayObject dcObject)
Description copied from class:DataClayRuntime
Method that deletes the alias of an object provided- Specified by:
deleteAlias
in classDataClayRuntime
- Parameters:
dcObject
- the object
-
federateToBackend
public void federateToBackend(DataClayObject dcObject, ExecutionEnvironmentID externalExecutionEnvironmentID, boolean recursive)
Description copied from class:DataClayRuntime
Federate an object with an external dataClay- Specified by:
federateToBackend
in classDataClayRuntime
- Parameters:
dcObject
- object to federateexternalExecutionEnvironmentID
- id of the external execution environment idrecursive
- Indicates if subobjects should be federated as well
-
unfederateFromBackend
public void unfederateFromBackend(DataClayObject dcObject, ExecutionEnvironmentID externalExecutionEnvironmentID, boolean recursive)
Description copied from class:DataClayRuntime
Unfederate an object with an external backend- Specified by:
unfederateFromBackend
in classDataClayRuntime
- Parameters:
dcObject
- object to unfederateexternalExecutionEnvironmentID
- id of the external execution environment idrecursive
- Indicates if subobjects should be unfederated as well
-
isDSLib
public boolean isDSLib()
- Specified by:
isDSLib
in classDataClayRuntime
- Returns:
- TRUE if library is for DataClay, FALSE for clients.
-
getLocalBackend
public ExecutionEnvironmentID getLocalBackend()
- Specified by:
getLocalBackend
in classDataClayRuntime
- Returns:
- the 'LOCAL' location if defined
-
getDataService
public DataService getDataService()
Get DataService reference- Returns:
- DataService reference
-
getHint
public ExecutionEnvironmentID getHint()
Description copied from class:DataClayRuntime
Get hint of current backend. If client, returns null.- Specified by:
getHint
in classDataClayRuntime
- Returns:
- ID of current backend.
-
getIfaceBitMaps
protected Map<MetaClassID,byte[]> getIfaceBitMaps()
Description copied from class:DataClayRuntime
Get interface bitmaps.- Specified by:
getIfaceBitMaps
in classDataClayRuntime
- Returns:
- Interface bitmaps
-
addSessionReference
public void addSessionReference(ObjectID objectID)
Add +1 reference associated to thread session- Overrides:
addSessionReference
in classDataClayRuntime
- Parameters:
objectID
- ID of the object
-
closeSessionInEE
public void closeSessionInEE(SessionID sessionID)
Close session in EE. Subtract session references for GC.- Parameters:
sessionID
- ID of session closing.
-
getRetainedReferences
public Set<ObjectID> getRetainedReferences()
Get IDs of references retained by EE.- Returns:
- References retained by EE (sessions, alias...)
-
getDataClayObjectLoader
protected DataClayObjectLoader getDataClayObjectLoader()
Description copied from class:DataClayRuntime
Get DataClay object loader.- Specified by:
getDataClayObjectLoader
in classDataClayRuntime
- Returns:
- Object loader.
-
getFromHeap
public DataClayExecutionObject getFromHeap(ObjectID objectID)
Description copied from class:DataClayRuntime
Get from Heap- Overrides:
getFromHeap
in classDataClayRuntime
- Parameters:
objectID
- ID of the object- Returns:
- The object in Heap or null if not present
-
finishCacheThreads
public void finishCacheThreads()
Finish cache threads.
-
cleanCaches
public void cleanCaches()
Clean caches.
-
-