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 DataServicedsRefRef to DS if this lib serves to a DS.booleantasksScheduledIndicates 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 voidaddSessionReference(ObjectID objectID)Add +1 reference associated to thread sessionvoidcheckSession(DataSetID dataSetID, SessionID sessionID)Checks session is valid.voidcleanCaches()Clean caches.voidcloseSessionInEE(SessionID sessionID)Close session in EE.voiddeleteAlias(DataClayObject dcObject)Method that deletes the alias of an object providedvoiddeserializeDataIntoInstance(DataClayExecutionObject instance, ObjectWithDataParamOrReturn data, Map<MetaClassID,byte[]> ifaceBitMaps)Deserialize data into instance.voiddetachObjectFromSession(ObjectID objectID, ExecutionEnvironmentID hint)Detach object from current session in use, i.e.protected ObjectexecuteRemoteImplementationInternal(DataClayObject object, ImplementationID implID, Object[] params)Internal Method that executes an implementation depending on client or server.voidfederateToBackend(DataClayObject dcObject, ExecutionEnvironmentID externalExecutionEnvironmentID, boolean recursive)Federate an object with an external dataClayvoidfinishCacheThreads()Finish cache threads.StringgetClassNameInternal(MetaClassID classID)Get class name from ID.HeapManagergetDataClayHeapManager()Get Heap Managerprotected DataClayObjectLoadergetDataClayObjectLoader()Get DataClay object loader.DataServicegetDataService()Get DataService referenceExecutionEnvironmentIDgetExecutionEnvironmentIDOfDS()Get ID of execution environment of this node.DataClayExecutionObjectgetFromHeap(ObjectID objectID)Get from HeapExecutionEnvironmentIDgetHint()Get hint of current backend.protected Map<MetaClassID,byte[]>getIfaceBitMaps()Get interface bitmaps.ExecutionEnvironmentIDgetLocalBackend()DataClayObjectgetOrNewAndLoadVolatile(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.DataClayExecutionObjectgetOrNewInstanceFromDB(ObjectID objectID, boolean retry)Get object from memory or database and WAIT in case we are still waiting for it to be persisted.DataClayExecutionObjectgetOrNewPersistentInstance(MetaClassID classID, ObjectID objectID, BackendID hint)Check if instance exists in Heap or create a new PERSISTENT instance if neededDataServiceAPIgetRemoteDSAPI(ExecutionEnvironmentID execLocationID)Get remote execution environmentSet<ObjectID>getRetainedReferences()Get IDs of references retained by EE.SessionIDgetSessionID()Get session IDvoidinitialize(String logicModuleHost, int logicModulePort, String originHostName)Initialize connections.booleanisDSLib()BackendIDmakePersistent(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 communicationvoidreleaseFromHeap(ObjectID objectID)Release hard reference to object with ID provided.voidremoveCurrentThreadSessionID()Remove session ID for threadvoidretainInHeap(DataClayObject object)Add a new Hard reference to the object provided.voidsetCurrentThreadSessionID(SessionID sessionID)Set session ID for threadvoidsetWeakProxy(DataClayExecutionObject instance, ExecutionEnvironmentID newHint)Set instance to be weak proxy.voidstoreObjects(SessionID sessionID, List<ObjectWithDataParamOrReturn> objsToStore)Directly store objects in DS.voidsynchronize(DataClayObject dcObject, Object[] params, ImplementationID remoteImplID)SynchronizevoidunfederateFromBackend(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:
initializein 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:DataClayRuntimeCheck if instance exists in Heap or create a new PERSISTENT instance if needed- Specified by:
getOrNewPersistentInstancein 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:
getOrNewAndLoadVolatilein 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:DataClayRuntimeGet session ID- Specified by:
getSessionIDin 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:DataClayRuntimeInternal Method that executes an implementation depending on client or server.- Specified by:
executeRemoteImplementationInternalin 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:DataClayRuntimeThis 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:
makePersistentin 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:DataClayRuntimeSynchronize- Specified by:
synchronizein 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:DataClayRuntimeGet class name from ID.- Specified by:
getClassNameInternalin 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:
getRemoteDSAPIin 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:
getDataClayHeapManagerin 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:DataClayRuntimeDetach 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:
detachObjectFromSessionin 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:DataClayRuntimeMethod that deletes the alias of an object provided- Specified by:
deleteAliasin classDataClayRuntime- Parameters:
dcObject- the object
-
federateToBackend
public void federateToBackend(DataClayObject dcObject, ExecutionEnvironmentID externalExecutionEnvironmentID, boolean recursive)
Description copied from class:DataClayRuntimeFederate an object with an external dataClay- Specified by:
federateToBackendin 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:DataClayRuntimeUnfederate an object with an external backend- Specified by:
unfederateFromBackendin 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:
isDSLibin classDataClayRuntime- Returns:
- TRUE if library is for DataClay, FALSE for clients.
-
getLocalBackend
public ExecutionEnvironmentID getLocalBackend()
- Specified by:
getLocalBackendin 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:DataClayRuntimeGet hint of current backend. If client, returns null.- Specified by:
getHintin classDataClayRuntime- Returns:
- ID of current backend.
-
getIfaceBitMaps
protected Map<MetaClassID,byte[]> getIfaceBitMaps()
Description copied from class:DataClayRuntimeGet interface bitmaps.- Specified by:
getIfaceBitMapsin classDataClayRuntime- Returns:
- Interface bitmaps
-
addSessionReference
public void addSessionReference(ObjectID objectID)
Add +1 reference associated to thread session- Overrides:
addSessionReferencein 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:DataClayRuntimeGet DataClay object loader.- Specified by:
getDataClayObjectLoaderin classDataClayRuntime- Returns:
- Object loader.
-
getFromHeap
public DataClayExecutionObject getFromHeap(ObjectID objectID)
Description copied from class:DataClayRuntimeGet from Heap- Overrides:
getFromHeapin 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.
-
-