Package es.bsc.dataclay.commonruntime
Class DataClayRuntime
- java.lang.Object
-
- es.bsc.dataclay.commonruntime.DataClayRuntime
-
- Direct Known Subclasses:
ClientRuntime
,DataServiceRuntime
public abstract class DataClayRuntime extends Object
This class contains functions to interact with DataClay. This is an abstract class in order to provide same functionalities to calls done from client-side and the ones done from a backend side.
-
-
Field Summary
Fields Modifier and Type Field Description protected MemoryCache<String,Triple<ObjectID,MetaClassID,BackendID>>
aliasCache
Cache of alias -> oid.protected HeapManager
dataClayHeapManager
DataClay Heap manager to manage GC, reference counting, lockers and others.DataClayObjectLoader
dataClayObjLoader
DataClay object loader.static boolean
DEBUG_ENABLED
Indicates if debug is enabled.int
hits
protected LockerPool
lockerPool
Pool of lockers.static org.apache.logging.log4j.Logger
LOGGER
Logger.protected LogicModuleAPI
logicModule
Logic Module API for communication.MemoryCache<ObjectID,MetaDataInfo>
metaDataCache
Cache of metaData.int
misses
protected ScheduledExecutorService
threadPool
Pool for tasks.Map<ObjectID,ObjectWithDataParamOrReturn>
underDeserializationVolatiles
Under deserialization volatiles per thread.protected Set<ObjectID>
volatileParametersBeingSend
Set of object ids of volatile parameters that were send but did not arrive to any node yet.
-
Constructor Summary
Constructors Modifier Constructor Description protected
DataClayRuntime()
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
activateTracing(boolean initializeWrapper)
Activate tracingvoid
activateTracingInDataClayServices()
Activate tracing in dataClay servicesvoid
addSessionReference(ObjectID objectID)
ONLY for EE.void
addToHeap(DataClayObject dcObject)
Add to Heapvoid
addVolatileUnderDeserialization(Collection<ObjectWithDataParamOrReturn> volatileSet)
All volatiles provided are under deserialization.Object
callExecuteToDS(DataClayObject dcObject, Object[] params, ImplementationID remoteImplID, BackendID remoteLocationID, boolean usingHint)
Execute a remote implementation in Location specified.SessionID
checkAndGetSession(String[] paramNames, Object[] params)
Check parameters and connections and sessionvoid
checkConnectionAndParams(String[] paramNames, Object[] params)
Check connection and parametersprotected BackendID
chooseLocation(DataClayObject dcObject, String alias)
Choose execution/make persistent location.void
cleanLockers()
Clean lockersvoid
consolidateVersion(ObjectID versionOID, ExecutionEnvironmentID objectHint)
Makes the object with finalVersionID the definitive version of the object with originalObjectID.void
deactivateTracing(boolean finalizeWrapper)
Deactivate tracingvoid
deactivateTracingInDataClayServices()
Dectivate tracingabstract void
deleteAlias(DataClayObject dcObject)
Method that deletes the alias of an object providedvoid
deleteAlias(String alias)
Method that deletes the alias of an objectObject[]
deserializeIntoHeap(Map<MetaClassID,byte[]> ifaceBitMaps, List<ObjectWithDataParamOrReturn> serializedParams)
Deserialize int heap objects provided for a make persistent call.Object[]
deserializeParams(DataClayObject objectInWhichToExec, Map<MetaClassID,byte[]> ifaceBitMaps, ImplementationID implID, SerializedParametersOrReturn serializedParams)
Deserialize parameters.Object
deserializeReturn(DataClayObject objectInWhichToExec, Map<MetaClassID,byte[]> ifaceBitMaps, ImplementationID implID, SerializedParametersOrReturn serializedReturn)
Deserialize return.abstract void
detachObjectFromSession(ObjectID objectID, ExecutionEnvironmentID hint)
Detach object from current session in use, i.e.Object
executeRemoteImplementation(DataClayObject objectInWichToExec, String implIDStr, Object[] params)
Method that executes an implementation.protected abstract Object
executeRemoteImplementationInternal(DataClayObject objectInWhichToExec, ImplementationID implID, Object[] params)
Internal Method that executes an implementation depending on client or server.Object
executeRemoteTask(ObjectID objectID, String className, String operationNameAndSignature, Object[] params, BackendID target)
Method that executes an implementationboolean
existsInHeap(ObjectID objectID)
Check if there is an object with ID provided.void
federateAllObjects(DataClayInstanceID destinationDataClayID)
Federate all dataClay objects from specified current dataClay destination dataclay.void
federateObject(DataClayObject dcObject, DataClayInstanceID externalDataClayID, boolean recursive)
Federate an object with an external dataClayabstract void
federateToBackend(DataClayObject dcObject, ExecutionEnvironmentID externalExecutionEnvironmentID, boolean recursive)
Federate an object with an external dataClayvoid
finishConnections()
Finish connections to servervoid
flushAll()
ADVANCED FUNCTION.Set<String>
getAllBackendsNames(CommonMessages.Langs lang, boolean forceUpdateCache)
Get all backend namesMap<ExecutionEnvironmentID,ExecutionEnvironment>
getAllExecutionEnvironmentsAtDataClay(CommonMessages.Langs lang, DataClayInstanceID dataClayInstanceID, boolean forceUpdate)
Get all execution environments in provided dataClay instanceMap<BackendID,ExecutionEnvironment>
getAllExecutionEnvironmentsAtHost(CommonMessages.Langs lang, String hostname)
Get all execution environments in provided hostMap<ExecutionEnvironmentID,ExecutionEnvironment>
getAllExecutionEnvironmentsInfo(CommonMessages.Langs lang, boolean forceUpdateCache)
Get all execution environments information.Set<BackendID>
getAllLocations(ObjectID objectID)
Get the IDs of the backends in which the object identified by the stub instance provided is located.protected ExecutionEnvironmentID
getBackendIDFromAlias(String alias)
ExecutionEnvironmentID
getBackendIDFromObjectID(ObjectID objectID)
Get execution locationSet<BackendID>
getBackendsWithName(CommonMessages.Langs lang, String backendName)
Get exec.String
getClassName(MetaClassID classID)
Get class name from IDabstract String
getClassNameInternal(MetaClassID classID)
Get class name from ID.CommonGrpcClient
getCommonGrpcClient()
DataClayObject
getCopyOfObject(ObjectID oid, boolean recursive)
Retrieves a copy of the specified object and all its subobjectsabstract HeapManager
getDataClayHeapManager()
Get Heap ManagerDataClayInstanceID
getDataClayID()
Get ID of the current instance of dataClayprotected abstract DataClayObjectLoader
getDataClayObjectLoader()
Get DataClay object loader.DataSetID
getDataSetIDFromObject(ObjectID oid)
Method that gets DataSetID from an object with id providedString
getDSNameOfHint(BackendID hint)
Get name of node associated to hint.ExecutionEnvironment
getExecutionEnvironmentInfo(BackendID execLocationID)
Get ExecutionEnvironment informationDataClayInstanceID
getExternalDataClayID(String hostname, int port)
Get external dataClay infoDataClayInstance
getExternalDataClayInfo(DataClayInstanceID extDataClayID)
Get external dataClay infoDataClayObject
getFromHeap(ObjectID objectID)
Get from Heapabstract BackendID
getHint()
Get hint of current backend.protected abstract Map<MetaClassID,byte[]>
getIfaceBitMaps()
Get interface bitmaps.abstract BackendID
getLocalBackend()
BackendID
getLocation(ObjectID objectID)
Get the ID of some backend in which the object identified by the stub instance provided is locatedLogicModuleAPI
getLogicModuleAPI()
Get the logic module API.int
getNumObjects()
Get number of objects in dataClayDataClayObject
getObjectByAlias(String alias)
Method that gets an object given its alias.DataClayObject
getObjectByAlias(String alias, MetaClassID metaClassID, boolean safe)
Method that gets an object given its alias and metaclass id.static ObjectID
getObjectIDFromAlias(String alias)
Triple<ObjectID,MetaClassID,BackendID>
getObjectInfoByAlias(String alias)
Method that gets info of an object given its ID if the object is accessible by using the given sesion.MetaDataInfo
getObjectMetadata(ObjectID objectID)
Get the IDs of the backends in which the object identified by the stub instance provided is located and the classname of the object.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.abstract DataClayObject
getOrNewPersistentInstance(MetaClassID classID, ObjectID objectID, BackendID hint)
Check if instance exists in Heap or create a new PERSISTENT instance if neededDataClayObject
getPersistedObjectByOID(ObjectID objectID, MetaClassID classID, BackendID hint)
Recovers Object from OID and class IDDataServiceAPI
getRemoteDSAPI(ExecutionEnvironmentID execLocationID)
Get remote execution environmentDataServiceAPI
getRemoteExecutionEnvironment(BackendID execLocationID)
Get remote execution environmentabstract SessionID
getSessionID()
Get session IDvoid
getTracesInDataClayServices()
Get traces in dataClay services and store it in current workspaceint
heapSize()
Get number of objects in heap.void
importModelsFromExternalDataClay(String externalNamespace, DataClayInstanceID extDataClayID)
Import classes in namespace specified from an external dataClayprotected void
initialize(String logicModuleHost, int logicModulePort, String originHostName)
Initialize session and connections.abstract boolean
isDSLib()
boolean
isInitialized()
Indicates if runtime was initialized or notvoid
lock(ObjectID objectID)
Lock objectabstract 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
migrateFederatedObjects(DataClayInstanceID originDataClayID, DataClayInstanceID destinationDataClayID)
Migrate (unfederate and federate) all current dataClay objects from specified external dataclay di to destination dataclay.void
moveObject(ObjectID objectID, MetaClassID classID, BackendID hint, BackendID srcBackendID, BackendID destBackendID, boolean recursive)
Move the replica of an object from one backend to another.ObjectID
newRemotePersistentInstance(MetaClassID classID, StubInfo stubInfo, ImplementationID implID, Object[] params, BackendID locID)
Create a new instance in a remote server and persist it.BackendID
newReplica(ObjectID objectID, BackendID objectHint, BackendID optDestBackendID, String optDestHostname, boolean recursive)
Replicates an object.Tuple<ObjectID,BackendID>
newVersion(ObjectID objectID, ExecutionEnvironmentID objectHint, MetaClassID classID, DataSetID dataSetID, BackendID optDestBackendID, String optDestHostname)
Creates a persistent new version of an object and its subobjects (always recursive).int
numLoadedObjs()
Get number of loaded objects in heap.int
numLockers()
Get number of lockersboolean
objectExistsInDataClay(ObjectID objectID)
Check if object exists in dataClay.DataClayInstanceID
registerExternalDataClay(String dcHost, Integer dcPort)
Method that registers the info of a dataClay instanceDataClayInstanceID
registerExternalDataClayOverrideAuthority(AccountID adminAccountID, PasswordCredential adminCredential, String dcHost, int dcPort, String authority)
ADMIN usage only.void
removeFromHeap(ObjectID objectID)
Remove reference from Heap.void
removeObjectMetadataFromCache(ObjectID objectID)
Remove metadata of object from cachevoid
removeVolatilesUnderDeserialization(Collection<ObjectWithDataParamOrReturn> volatileSet)
Remove volatiles under deserialization.SerializedParametersOrReturn
serializeParams(DataClayObject objectInWhichToExec, Map<MetaClassID,byte[]> ifaceBitMaps, ImplementationID implID, Object[] params, boolean forUpdate, BackendID hintVolatiles)
Serialize parameters.SerializedParametersOrReturn
serializeReturn(DataClayObject objectInWhichToExec, Map<MetaClassID,byte[]> ifaceBitMaps, ImplementationID implID, Object ret)
Serialize parameters.void
setDataSetID(ObjectID objectID, DataSetID newDataSetID)
Set DataSet IDvoid
setInitialized(boolean theinitialized)
Set initialized flagvoid
setObjectReadOnly(ObjectID objectID, MetaClassID classID, BackendID hint)
Set a persistent object as read only Logic module API used for communicationvoid
setObjectReadWrite(ObjectID objectID, MetaClassID classID, BackendID hint)
Set a persistent object as read writeabstract void
synchronize(DataClayObject dcObject, Object[] params, ImplementationID remoteImplID)
Synchronizevoid
unfederateAllObjects(DataClayInstanceID extDataClayID)
Unfederate all objects belonging/federated with external dataClay with id providedvoid
unfederateAllObjectsWithAllDCs()
Unfederate all objects belonging/federated with ANY external dataClayabstract void
unfederateFromBackend(DataClayObject dcObject, ExecutionEnvironmentID externalExecutionEnvironmentID, boolean recursive)
Unfederate an object with an external backendvoid
unfederateObject(DataClayObject dcObject, DataClayInstanceID externalDataClayID, boolean recursive)
Unfederate an object with an external dataClayvoid
unfederateObjectWithAllDCs(DataClayObject dcObject, boolean recursive)
Unfederate an object with all external dataClaysvoid
unlock(ObjectID objectID)
Unlock objectvoid
updateObject(ObjectID into, DataClayObject from)
Updates a specific object (into) with the fields of another one (from)protected void
updateObjectID(DataClayObject dcObject, ObjectID newObjectID)
Update the object id in both DataClayObject and HeapManagervoid
waitForAsyncRequestToFinish()
Wait for asynchronous requests to finish.
-
-
-
Field Detail
-
LOGGER
public static final org.apache.logging.log4j.Logger LOGGER
Logger.
-
DEBUG_ENABLED
public static final boolean DEBUG_ENABLED
Indicates if debug is enabled.
-
logicModule
protected LogicModuleAPI logicModule
Logic Module API for communication.
-
dataClayHeapManager
protected HeapManager dataClayHeapManager
DataClay Heap manager to manage GC, reference counting, lockers and others.
-
lockerPool
protected final LockerPool lockerPool
Pool of lockers.
-
metaDataCache
public MemoryCache<ObjectID,MetaDataInfo> metaDataCache
Cache of metaData.
-
aliasCache
protected MemoryCache<String,Triple<ObjectID,MetaClassID,BackendID>> aliasCache
Cache of alias -> oid.
-
dataClayObjLoader
public DataClayObjectLoader dataClayObjLoader
DataClay object loader.
-
underDeserializationVolatiles
public final Map<ObjectID,ObjectWithDataParamOrReturn> underDeserializationVolatiles
Under deserialization volatiles per thread.
-
threadPool
protected ScheduledExecutorService threadPool
Pool for tasks. Initialized in sub-classes.
-
volatileParametersBeingSend
protected final Set<ObjectID> volatileParametersBeingSend
Set of object ids of volatile parameters that were send but did not arrive to any node yet.
-
misses
public int misses
-
hits
public int hits
-
-
Method Detail
-
initialize
protected void initialize(String logicModuleHost, int logicModulePort, String originHostName) throws Exception
Initialize session and connections.- 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.
-
getLogicModuleAPI
public final LogicModuleAPI getLogicModuleAPI()
Get the logic module API.- Returns:
- The logic module API
-
getAllExecutionEnvironmentsInfo
public final Map<ExecutionEnvironmentID,ExecutionEnvironment> getAllExecutionEnvironmentsInfo(CommonMessages.Langs lang, boolean forceUpdateCache)
Get all execution environments information.- Parameters:
lang
- LanguageforceUpdateCache
- Indicates cache must be forcibly updated- Returns:
- All execution locations information
-
getExecutionEnvironmentInfo
public final ExecutionEnvironment getExecutionEnvironmentInfo(BackendID execLocationID)
Get ExecutionEnvironment information- Parameters:
execLocationID
- Execution location ID- Returns:
- Execution location information
-
getAllExecutionEnvironmentsAtHost
public Map<BackendID,ExecutionEnvironment> getAllExecutionEnvironmentsAtHost(CommonMessages.Langs lang, String hostname)
Get all execution environments in provided host- Parameters:
lang
- Languagehostname
- Host name- Returns:
- Set of execution environments in provided host
-
getAllExecutionEnvironmentsAtDataClay
public Map<ExecutionEnvironmentID,ExecutionEnvironment> getAllExecutionEnvironmentsAtDataClay(CommonMessages.Langs lang, DataClayInstanceID dataClayInstanceID, boolean forceUpdate)
Get all execution environments in provided dataClay instance- Parameters:
lang
- LanguagedataClayInstanceID
- ID of dataClay to checkforceUpdate
- Indicates exec envs must be updated- Returns:
- Set of execution environments in provided dataClay instance
-
getAllBackendsNames
public Set<String> getAllBackendsNames(CommonMessages.Langs lang, boolean forceUpdateCache)
Get all backend names- Parameters:
lang
- LanguageforceUpdateCache
- Indicates cache must be forcibly updated- Returns:
- All backed names information
-
getBackendsWithName
public Set<BackendID> getBackendsWithName(CommonMessages.Langs lang, String backendName)
Get exec. environments with name provided- Parameters:
lang
- LanguagebackendName
- Name of backend- Returns:
- All backends with name provided
-
getBackendIDFromObjectID
public final ExecutionEnvironmentID getBackendIDFromObjectID(ObjectID objectID)
Get execution location- Parameters:
objectID
- ID of the object connected.- Returns:
- ExecutionEnvironmentID by hash
-
getRemoteExecutionEnvironment
public final DataServiceAPI getRemoteExecutionEnvironment(BackendID execLocationID)
Get remote execution environment- Parameters:
execLocationID
- ID of remote execution environment- Returns:
- Remote execution environment
-
getRemoteDSAPI
public DataServiceAPI getRemoteDSAPI(ExecutionEnvironmentID execLocationID)
Get remote execution environment- Parameters:
execLocationID
- ID of remote execution environment- Returns:
- Remote execution environment
-
getExternalDataClayInfo
public DataClayInstance getExternalDataClayInfo(DataClayInstanceID extDataClayID)
Get external dataClay info- Parameters:
extDataClayID
- id of the external dataClay instance- Returns:
- info of the external dataClay instance
-
registerExternalDataClay
public DataClayInstanceID registerExternalDataClay(String dcHost, Integer dcPort)
Method that registers the info of a dataClay instance- Parameters:
dcHost
- entry port host of the external dataClaydcPort
- entry point port of the external dataClay- Returns:
- ID of external registered dataClay.
-
registerExternalDataClayOverrideAuthority
public DataClayInstanceID registerExternalDataClayOverrideAuthority(AccountID adminAccountID, PasswordCredential adminCredential, String dcHost, int dcPort, String authority)
ADMIN usage only. Method that registers the info of a dataClay instance but with overriden authority for SSL connections.- Parameters:
adminAccountID
- admin account idadminCredential
- admin credentialsdcHost
- entry port host of the external dataClaydcPort
- entry point port of the external dataClayauthority
- authority to use- Returns:
- ID of external registered dataClay.
-
getExternalDataClayID
public DataClayInstanceID getExternalDataClayID(String hostname, int port)
Get external dataClay info- Parameters:
hostname
- host name of the external dataClay instanceport
- port of the external dataClay instance.- Returns:
- info of the external dataClay instance
-
getDataClayID
public DataClayInstanceID getDataClayID()
Get ID of the current instance of dataClay- Returns:
- the dataClay ID
-
getHint
public abstract BackendID getHint()
Get hint of current backend. If client, returns null.- Returns:
- ID of current backend.
-
finishConnections
public final void finishConnections()
Finish connections to server
-
getObjectMetadata
public final MetaDataInfo getObjectMetadata(ObjectID objectID)
Get the IDs of the backends in which the object identified by the stub instance provided is located and the classname of the object.- Parameters:
objectID
- ID of the object- Returns:
- Object metadata.
-
removeObjectMetadataFromCache
public final void removeObjectMetadataFromCache(ObjectID objectID)
Remove metadata of object from cache- Parameters:
objectID
- ID of the object
-
getCopyOfObject
public final DataClayObject getCopyOfObject(ObjectID oid, boolean recursive)
Retrieves a copy of the specified object and all its subobjects- Parameters:
oid
- id of the object to be retrievedrecursive
- retrieve a copy of the whole object copying also its subobjects or only the main object- Returns:
- a volatile instance of the object
-
updateObject
public final void updateObject(ObjectID into, DataClayObject from)
Updates a specific object (into) with the fields of another one (from)- Parameters:
into
- target object where data is putfrom
- object containing the data to put
-
addVolatileUnderDeserialization
public void addVolatileUnderDeserialization(Collection<ObjectWithDataParamOrReturn> volatileSet)
All volatiles provided are under deserialization. This function solves problems of 'hashcode' and other special functions needed during deserializations. See executeImpl.- Parameters:
volatileSet
- Volatiles under deserialization.
-
removeVolatilesUnderDeserialization
public void removeVolatilesUnderDeserialization(Collection<ObjectWithDataParamOrReturn> volatileSet)
Remove volatiles under deserialization.- Parameters:
volatileSet
- Volatiles under deserialization.
-
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.- 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.
-
getSessionID
public abstract SessionID getSessionID()
Get session ID- Returns:
- Session ID
-
checkConnectionAndParams
public final void checkConnectionAndParams(String[] paramNames, Object[] params)
Check connection and parameters- Parameters:
paramNames
- Names of parametersparams
- Parameters to check
-
checkAndGetSession
public final SessionID checkAndGetSession(String[] paramNames, Object[] params)
Check parameters and connections and session- Parameters:
paramNames
- Names of parametersparams
- Parameters to check- Returns:
- Session ID
-
getObjectInfoByAlias
public final Triple<ObjectID,MetaClassID,BackendID> getObjectInfoByAlias(String alias)
Method that gets info of an object given its ID if the object is accessible by using the given sesion.- Parameters:
alias
- alias of the object- Returns:
- Currently id of object and hint.
-
getObjectByAlias
public final DataClayObject getObjectByAlias(String alias)
Method that gets an object given its alias.- Parameters:
alias
- alias of the object- Returns:
- The object identified by alias provided
-
getObjectByAlias
public final DataClayObject getObjectByAlias(String alias, MetaClassID metaClassID, boolean safe)
Method that gets an object given its alias and metaclass id.- Parameters:
alias
- alias of the objectmetaClassID
- if of the object's metaclasssafe
- if true, check that alias exists- Returns:
- The object identified by the proved alias and metaclass.
-
deleteAlias
public final void deleteAlias(String alias)
Method that deletes the alias of an object- Parameters:
alias
- alias of the object to be removed
-
deleteAlias
public abstract void deleteAlias(DataClayObject dcObject)
Method that deletes the alias of an object provided- Parameters:
dcObject
- the object
-
getDataSetIDFromObject
public final DataSetID getDataSetIDFromObject(ObjectID oid)
Method that gets DataSetID from an object with id provided- Parameters:
oid
- ID of the object- Returns:
- DataSet of the object
-
getClassNameInternal
public abstract String getClassNameInternal(MetaClassID classID)
Get class name from ID.- Parameters:
classID
- ID of class- Returns:
- Class name
-
getClassName
public final String getClassName(MetaClassID classID)
Get class name from ID- Parameters:
classID
- Class ID- Returns:
- Class name
-
newVersion
public final Tuple<ObjectID,BackendID> newVersion(ObjectID objectID, ExecutionEnvironmentID objectHint, MetaClassID classID, DataSetID dataSetID, BackendID optDestBackendID, String optDestHostname)
Creates a persistent new version of an object and its subobjects (always recursive). If a Backend is provided the object is versioned to this backend, otherwise it is versioned to any backend- Parameters:
objectID
- ID of the objectobjectHint
- object hintclassID
- ID of the class of the objectdataSetID
- ID of the dataset of the objectoptDestBackendID
- ID of the backend in which to store the version the object (optional)optDestHostname
- Hostname of the backend in which to replicate the object (optional)- Returns:
- Version ID and destination backend ID
-
consolidateVersion
public final void consolidateVersion(ObjectID versionOID, ExecutionEnvironmentID objectHint)
Makes the object with finalVersionID the definitive version of the object with originalObjectID. The original version is deleted.- Parameters:
versionOID
- ID of version object to consolidateobjectHint
- object hint
-
newReplica
public final BackendID newReplica(ObjectID objectID, BackendID objectHint, BackendID optDestBackendID, String optDestHostname, boolean recursive)
Replicates an object. If a Backend is provided the object is replicated to this backend, otherwise it is replicated to any backend- Parameters:
objectID
- ID of the objectobjectHint
- object hintoptDestBackendID
- ID of the backend in which to replicate the object (optional)optDestHostname
- Hostname of the backend in which to replicate the object (optional)recursive
- Indicates if we should also replicate all sub-objects or not.- Returns:
- The ID of the backend in which the replica was created or NULL if some error is thrown.
-
moveObject
public final void moveObject(ObjectID objectID, MetaClassID classID, BackendID hint, BackendID srcBackendID, BackendID destBackendID, boolean recursive)
Move the replica of an object from one backend to another.- Parameters:
objectID
- ID of the objectclassID
- Class ID of the objecthint
- Hint of the objectsrcBackendID
- ID of the backend containing the replicadestBackendID
- ID of the destination backendrecursive
- Indicates if movement must be recursive or not.
-
setObjectReadOnly
public final void setObjectReadOnly(ObjectID objectID, MetaClassID classID, BackendID hint)
Set a persistent object as read only Logic module API used for communication- Parameters:
objectID
- ID of the objectclassID
- Class ID of the objecthint
- Hint of the object
-
setObjectReadWrite
public final void setObjectReadWrite(ObjectID objectID, MetaClassID classID, BackendID hint)
Set a persistent object as read write- Parameters:
objectID
- ID of the objectclassID
- Class ID of the objecthint
- Hint of the object
-
getLocation
public final BackendID getLocation(ObjectID objectID)
Get the ID of some backend in which the object identified by the stub instance provided is located- Parameters:
objectID
- ID of the object- Returns:
- ID of some backend in which the object is located or NULL if some error is thrown.
-
getAllLocations
public final Set<BackendID> getAllLocations(ObjectID objectID)
Get the IDs of the backends in which the object identified by the stub instance provided is located.- Parameters:
objectID
- ID of the object- Returns:
- IDs of the backends in which the object is located or NULL if some error is thrown.
-
getDSNameOfHint
public final String getDSNameOfHint(BackendID hint)
Get name of node associated to hint.- Parameters:
hint
- Hint- Returns:
- name of node associated to hint
-
serializeParams
public final SerializedParametersOrReturn serializeParams(DataClayObject objectInWhichToExec, Map<MetaClassID,byte[]> ifaceBitMaps, ImplementationID implID, Object[] params, boolean forUpdate, BackendID hintVolatiles)
Serialize parameters.- Parameters:
objectInWhichToExec
- Object in which to run method that needs serialization of parametersifaceBitMaps
- Interface bitmapsimplID
- ImplementationIDparams
- Parameters or return to serializeforUpdate
- Indicates whether this serialization is for an update or nothintVolatiles
- Hint to set to volatiles- Returns:
- Serialized parameters
-
serializeReturn
public final SerializedParametersOrReturn serializeReturn(DataClayObject objectInWhichToExec, Map<MetaClassID,byte[]> ifaceBitMaps, ImplementationID implID, Object ret)
Serialize parameters.- Parameters:
objectInWhichToExec
- Object in which to run method that needs serialization of parametersifaceBitMaps
- Interface bitmapsimplID
- ImplementationIDret
- Return to serialize- Returns:
- Serialized parameters
-
deserializeParams
public final Object[] deserializeParams(DataClayObject objectInWhichToExec, Map<MetaClassID,byte[]> ifaceBitMaps, ImplementationID implID, SerializedParametersOrReturn serializedParams)
Deserialize parameters.- Parameters:
objectInWhichToExec
- Object in which to run method that needs deserialization of parameters.ifaceBitMaps
- Interface bitmapsimplID
- ImplementationIDserializedParams
- Parameters to deserialize- Returns:
- Serialized parameters
-
deserializeIntoHeap
public final Object[] deserializeIntoHeap(Map<MetaClassID,byte[]> ifaceBitMaps, List<ObjectWithDataParamOrReturn> serializedParams)
Deserialize int heap objects provided for a make persistent call.- Parameters:
ifaceBitMaps
- Interface bitmapsserializedParams
- Objects to deserialize- Returns:
- the deserialized parameters
-
deserializeReturn
public final Object deserializeReturn(DataClayObject objectInWhichToExec, Map<MetaClassID,byte[]> ifaceBitMaps, ImplementationID implID, SerializedParametersOrReturn serializedReturn)
Deserialize return.- Parameters:
objectInWhichToExec
- Object in which to run method that needs deserialization of return.ifaceBitMaps
- Interface bitmapsimplID
- ImplementationIDserializedReturn
- Return to deserialize- Returns:
- Deserialized return
-
executeRemoteImplementationInternal
protected abstract Object executeRemoteImplementationInternal(DataClayObject objectInWhichToExec, ImplementationID implID, Object[] params)
Internal Method that executes an implementation depending on client or server.- Parameters:
objectInWhichToExec
- Object in which to execimplID
- Implementation IDparams
- Parameters- Returns:
- the result of execution.
-
executeRemoteImplementation
public final Object executeRemoteImplementation(DataClayObject objectInWichToExec, String implIDStr, Object[] params)
Method that executes an implementation.- Parameters:
objectInWichToExec
- Object in which to execimplIDStr
- Implementation ID as stringparams
- Parameters- Returns:
- the result of execution.
-
getIfaceBitMaps
protected abstract Map<MetaClassID,byte[]> getIfaceBitMaps()
Get interface bitmaps.- Returns:
- Interface bitmaps
-
callExecuteToDS
public final Object callExecuteToDS(DataClayObject dcObject, Object[] params, ImplementationID remoteImplID, BackendID remoteLocationID, boolean usingHint)
Execute a remote implementation in Location specified.- Parameters:
dcObject
- Object used as a 'portal' to other DS.params
- Parameters to sendremoteImplID
- ID of implementation to executeremoteLocationID
- Location in which to executeusingHint
- TRUE if using hint.- Returns:
- Result of execution.
-
synchronize
public abstract void synchronize(DataClayObject dcObject, Object[] params, ImplementationID remoteImplID)
Synchronize- Parameters:
dcObject
- Object used as a 'portal' to other DS.params
- Parameters to sendremoteImplID
- ID of implementation to execute
-
executeRemoteTask
public final Object executeRemoteTask(ObjectID objectID, String className, String operationNameAndSignature, Object[] params, BackendID target)
Method that executes an implementation- Parameters:
objectID
- ID of the objectclassName
- Name of the class of the objectoperationNameAndSignature
- Name and Signature of the operation to be executedparams
- parameters for the operationtarget
- the backend where the execution must be performed- Returns:
- the resulting object corresponding to the execution of the operation if it succeeds. null otherwise.
if the method is void, it returns null also but no ERROR is prompt.
-
getOrNewPersistentInstance
public abstract DataClayObject getOrNewPersistentInstance(MetaClassID classID, ObjectID objectID, BackendID hint)
Check if instance exists in Heap or create a new PERSISTENT instance if needed- 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
-
newRemotePersistentInstance
public final ObjectID newRemotePersistentInstance(MetaClassID classID, StubInfo stubInfo, ImplementationID implID, Object[] params, BackendID locID)
Create a new instance in a remote server and persist it.- Parameters:
classID
- ID of the class of the instance to createstubInfo
- Stub informationimplID
- ID of the implementation of the constructorparams
- Parameters to send to constructorlocID
- (optional) Storage Location/ Execution Environment in which to store object.- Returns:
- ObjectID of persisted instance.
-
makePersistent
public abstract 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 communication- 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.
-
federateObject
public void federateObject(DataClayObject dcObject, DataClayInstanceID externalDataClayID, boolean recursive)
Federate an object with an external dataClay- Parameters:
dcObject
- object to federateexternalDataClayID
- id of the external dataClay IDrecursive
- Indicates if subobjects should be federated as well
-
federateToBackend
public abstract void federateToBackend(DataClayObject dcObject, ExecutionEnvironmentID externalExecutionEnvironmentID, boolean recursive)
Federate an object with an external dataClay- Parameters:
dcObject
- object to federateexternalExecutionEnvironmentID
- id of the external execution environment idrecursive
- Indicates if subobjects should be federated as well
-
unfederateObject
public void unfederateObject(DataClayObject dcObject, DataClayInstanceID externalDataClayID, boolean recursive)
Unfederate an object with an external dataClay- Parameters:
dcObject
- object to unfederateexternalDataClayID
- id of the external dataClayrecursive
- Indicates if subobjects should be unfederated as well
-
unfederateFromBackend
public abstract void unfederateFromBackend(DataClayObject dcObject, ExecutionEnvironmentID externalExecutionEnvironmentID, boolean recursive)
Unfederate an object with an external backend- Parameters:
dcObject
- object to unfederateexternalExecutionEnvironmentID
- id of the external execution environment idrecursive
- Indicates if subobjects should be unfederated as well
-
unfederateObjectWithAllDCs
public void unfederateObjectWithAllDCs(DataClayObject dcObject, boolean recursive)
Unfederate an object with all external dataClays- Parameters:
dcObject
- object to unfederaterecursive
- Indicates if subobjects should be federated as well
-
unfederateAllObjects
public void unfederateAllObjects(DataClayInstanceID extDataClayID)
Unfederate all objects belonging/federated with external dataClay with id provided- Parameters:
extDataClayID
- External dataClay ID
-
unfederateAllObjectsWithAllDCs
public void unfederateAllObjectsWithAllDCs()
Unfederate all objects belonging/federated with ANY external dataClay
-
federateAllObjects
public void federateAllObjects(DataClayInstanceID destinationDataClayID)
Federate all dataClay objects from specified current dataClay destination dataclay.- Parameters:
destinationDataClayID
- Destination dataclay id
-
importModelsFromExternalDataClay
public void importModelsFromExternalDataClay(String externalNamespace, DataClayInstanceID extDataClayID)
Import classes in namespace specified from an external dataClay- Parameters:
externalNamespace
- External namespace to getextDataClayID
- External dataClay ID
-
migrateFederatedObjects
public void migrateFederatedObjects(DataClayInstanceID originDataClayID, DataClayInstanceID destinationDataClayID)
Migrate (unfederate and federate) all current dataClay objects from specified external dataclay di to destination dataclay.- Parameters:
originDataClayID
- Origin dataclay iddestinationDataClayID
- Destination dataclay id
-
setDataSetID
public final void setDataSetID(ObjectID objectID, DataSetID newDataSetID)
Set DataSet ID- Parameters:
objectID
- ID of the objectnewDataSetID
- New DataSetID
-
getPersistedObjectByOID
public final DataClayObject getPersistedObjectByOID(ObjectID objectID, MetaClassID classID, BackendID hint)
Recovers Object from OID and class ID- Parameters:
objectID
- ObjectID of the objectclassID
- ClassID of the object. Can be NULL. Null class ID makes dataClay to ask for object Mdata.hint
- Hint of the object. Can be NULL if no hint.- Returns:
- Instance of the object.
-
waitForAsyncRequestToFinish
public final void waitForAsyncRequestToFinish()
Wait for asynchronous requests to finish.
-
getDataClayHeapManager
public abstract HeapManager getDataClayHeapManager()
Get Heap Manager- Returns:
- Heap Manager
-
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
-
addToHeap
public final void addToHeap(DataClayObject dcObject)
Add to Heap- Parameters:
dcObject
- the object
-
objectExistsInDataClay
public boolean objectExistsInDataClay(ObjectID objectID)
Check if object exists in dataClay.- Parameters:
objectID
- ID of the object- Returns:
- TRUE if object exists. FALSE otherwise.
-
getNumObjects
public int getNumObjects()
Get number of objects in dataClay
-
getFromHeap
public DataClayObject getFromHeap(ObjectID objectID)
Get from Heap- Parameters:
objectID
- ID of the object- Returns:
- The object in Heap or null if not present
-
existsInHeap
public final boolean existsInHeap(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.
-
detachObjectFromSession
public abstract void detachObjectFromSession(ObjectID objectID, ExecutionEnvironmentID hint)
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"- Parameters:
objectID
- ID of the object to detachhint
- Hint of the object to detach (can be null)
-
flushAll
public final void flushAll()
ADVANCED FUNCTION. Try not to use it. This function flushes all objects in Heap.
-
heapSize
public final int heapSize()
Get number of objects in heap.- Returns:
- Heap size.
-
numLoadedObjs
public final int numLoadedObjs()
Get number of loaded objects in heap.- Returns:
- number of loaded objects in heap.
-
activateTracingInDataClayServices
public final void activateTracingInDataClayServices()
Activate tracing in dataClay services
-
deactivateTracingInDataClayServices
public final void deactivateTracingInDataClayServices()
Dectivate tracing
-
activateTracing
public final void activateTracing(boolean initializeWrapper)
Activate tracing
-
deactivateTracing
public final void deactivateTracing(boolean finalizeWrapper)
Deactivate tracing
-
getTracesInDataClayServices
public final void getTracesInDataClayServices()
Get traces in dataClay services and store it in current workspace
-
getCommonGrpcClient
public final CommonGrpcClient getCommonGrpcClient()
- Returns:
- GRPC client.
-
getDataClayObjectLoader
protected abstract DataClayObjectLoader getDataClayObjectLoader()
Get DataClay object loader.- Returns:
- Object loader.
-
lock
public final void lock(ObjectID objectID)
Lock object- Parameters:
objectID
- ID of object
-
unlock
public final void unlock(ObjectID objectID)
Unlock object- Parameters:
objectID
- ID of object
-
cleanLockers
public final void cleanLockers()
Clean lockers
-
numLockers
public final int numLockers()
Get number of lockers- Returns:
- Number of lockers
-
isDSLib
public abstract boolean isDSLib()
- Returns:
- TRUE if library is for DataClay, FALSE for clients.
-
getLocalBackend
public abstract BackendID getLocalBackend()
- Returns:
- the 'LOCAL' location if defined
-
addSessionReference
public void addSessionReference(ObjectID objectID)
ONLY for EE. Add +1 reference associated to thread session- Parameters:
objectID
- ID of the object
-
isInitialized
public boolean isInitialized()
Indicates if runtime was initialized or not- Returns:
- TRUE if runtime is initialized. FALSE otherwise.
-
setInitialized
public void setInitialized(boolean theinitialized)
Set initialized flag- Parameters:
theinitialized
- Value to set
-
getBackendIDFromAlias
protected ExecutionEnvironmentID getBackendIDFromAlias(String alias)
-
chooseLocation
protected BackendID chooseLocation(DataClayObject dcObject, String alias)
Choose execution/make persistent location.- Parameters:
dcObject
- DataClay object.- Returns:
- Chosen location.
-
updateObjectID
protected void updateObjectID(DataClayObject dcObject, ObjectID newObjectID)
Update the object id in both DataClayObject and HeapManager- Parameters:
dcObject
- DataClay object.newObjectID
- the new object id.
-
-