Package es.bsc.dataclay.api
Class DataClay
- java.lang.Object
-
- es.bsc.dataclay.api.DataClay
-
public final class DataClay extends Object
This class contains the dataClay public API.
-
-
Field Summary
Fields Modifier and Type Field Description static ClientRuntime
commonLib
UserClientLib for the session.static String
CONFIGFILEPATH_ENV
Environment variable where configuration file can be specified.static String
DATASET_SEPARATOR_TOKEN
Separator token for datasets.protected static boolean
DEBUG_ENABLED
Indicates if debug is enabled.static BackendID
jLOCAL
LOCAL BackendIDstatic BackendID
pLOCAL
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
activateTracing(boolean initializeWrapper)
Activate tracingstatic void
activateTracingInDataClayServices()
Activate tracing in dataClay servicesstatic void
deactivateTracing(boolean finalizeWrapper)
Dectivate tracingstatic void
deactivateTracingInDataClayServices()
Dectivate tracingstatic String
executeTask(String objectIDstr, Method method, Object[] params, CallbackHandler callback)
Executes a method on a specific target assynchronously.static String
executeTask(String objectIDstr, String operationSignature, Object[] params, CallbackHandler callback)
Executes a method on a specific target assynchronously.static void
federateAllObjects(DataClayInstanceID destinationDataClayID)
Federate all dataClay objects from specified current dataClay destination dataclay.static void
finish()
Finish connections to DataClay.static Backend
getBackendInfo(BackendID backendID)
Retrieves the info of a backendstatic Object
getByID(String objectIDstr)
If the object is accessible, initializes an instance of a stub with the given objectID.static ClientRuntime
getCommonLib()
Getter for commonLib property.static DataClayInstanceID
getDataClayID()
Retrieves current dataClay instance IDstatic DataClayInstanceID
getDataClayID(String dcHost, int dcPort)
Retrieves the id of the external dataClay which Logic Module is located at provided host and listening on specified port.static BackendID
getExternalJavaBackend(String dsName, DataClayInstanceID externalDcID)
Retrieves the id of external java backend with name provided in external dataClay specifiedstatic BackendID
getJavaBackend(String dsName)
Retrieves the id of ANY java backend with name providedstatic Set<BackendID>
getJavaBackends()
Retrieves all Java backendsstatic String
getLocation(String objectIDstr)
Gets any location of an object.static List<String>
getLocations(String objectIDstr)
Gets all the locations of an object.static int
getMDhits()
static int
getMDmisses()
static int
getNumObjects()
Get number of objects in dataClaystatic Object
getResult(CallbackEvent callbackEvent)
Processes and retrieves the callback event produced by a task execution.static SessionID
getSessionID()
Getter for sessionID property.static void
getTracesInDataClayServices()
Get traces in dataClay services and store it in current workspacestatic String
ids2String(ObjectID objectID, BackendID hint, MetaClassID classID)
Translates from ObjectID to string representation.static void
importModelsFromExternalDataClay(String externalNamespace, DataClayInstanceID extDataClayID)
Import classes in namespace specified from an external dataClaystatic void
init()
Method that initializes the lib.static void
init(int numBackends, CommonMessages.Langs language)
Initialize dataClay waiting for the following number of backends of language provided.static void
migrateFederatedObjects(DataClayInstanceID originDataClayID, DataClayInstanceID destinationDataClayID)
Migrate (unfederate and federate) all current dataClay objects from specified external dataclay di to destination dataclay.static void
moveReplica(String objectIDstr, String srcHost, String destHost)
Move a replica from source host to dest host.static void
newReplica(String objectIDstr, String destHost)
Create a new replica of the given object.static DataClayInstanceID
registerDataClay(String dcHost, int dcPort)
Registers an external dataClay to enable future object federation with it.static void
setSessionFile(String path)
static Triple<ObjectID,BackendID,MetaClassID>
string2IDandHintID(String objectIDstr)
Translates from string representation of an objectID to an ObjectID.static void
unfederateAllObjects()
Unfederate all objects belonging/federated with ANY external dataClaystatic void
unfederateAllObjects(DataClayInstanceID extDataClayID)
Unfederate all objects belonging/federated with external dataClay with id provided
-
-
-
Field Detail
-
CONFIGFILEPATH_ENV
public static final String CONFIGFILEPATH_ENV
Environment variable where configuration file can be specified.- See Also:
- Constant Field Values
-
DEBUG_ENABLED
protected static final boolean DEBUG_ENABLED
Indicates if debug is enabled.
-
DATASET_SEPARATOR_TOKEN
public static final String DATASET_SEPARATOR_TOKEN
Separator token for datasets.- See Also:
- Constant Field Values
-
commonLib
public static ClientRuntime commonLib
UserClientLib for the session. WARNING: CURRENTLY IS PUBLIC IN ORDER TO ALLOW THREADS CREATED IN CLIENT TO USE THE COMMONLIB. Check design.
-
jLOCAL
public static BackendID jLOCAL
LOCAL BackendID
-
pLOCAL
public static BackendID pLOCAL
-
-
Method Detail
-
setSessionFile
public static void setSessionFile(String path) throws DataClayException
- Throws:
DataClayException
-
finish
public static void finish() throws DataClayException
Finish connections to DataClay.- Throws:
DataClayException
- if an exception occurs
-
init
public static void init() throws DataClayException
Method that initializes the lib.- Throws:
DataClayException
- if an exception occurs
-
init
public static void init(int numBackends, CommonMessages.Langs language) throws DataClayException
Initialize dataClay waiting for the following number of backends of language provided.- Parameters:
numBackends
- Number of backends to wait forlanguage
- language of backend to wait for- Throws:
DataClayException
- if an exception occurs
-
getByID
public static Object getByID(String objectIDstr) throws DataClayException
If the object is accessible, initializes an instance of a stub with the given objectID.- Parameters:
objectIDstr
- ID of the object- Returns:
- An instance of the stub representing the given objectID
- Throws:
DataClayException
- if an exception occurs
-
getLocation
public static String getLocation(String objectIDstr) throws DataClayException
Gets any location of an object.- Parameters:
objectIDstr
- object to retrieve its location- Returns:
- a location of the object.
- Throws:
DataClayException
- if an exception occurs
-
getLocations
public static List<String> getLocations(String objectIDstr) throws DataClayException
Gets all the locations of an object.- Parameters:
objectIDstr
- object to retrieve its locations.- Returns:
- locations of an object.
- Throws:
DataClayException
- if an exception occurs
-
moveReplica
public static void moveReplica(String objectIDstr, String srcHost, String destHost) throws DataClayException
Move a replica from source host to dest host.- Parameters:
objectIDstr
- object which replica must be moved.srcHost
- source location of the object replica.destHost
- target location of the object replica.- Throws:
DataClayException
- if an exception occurs. E.g. if source or dest hosts have no backend registered.
-
newReplica
public static void newReplica(String objectIDstr, String destHost) throws DataClayException
Create a new replica of the given object.- Parameters:
objectIDstr
- objectID to be replicated.destHost
- target location of the object replica.- Throws:
DataClayException
- if an exception occurs
-
executeTask
public static String executeTask(String objectIDstr, Method method, Object[] params, CallbackHandler callback) throws DataClayException
Executes a method on a specific target assynchronously.- Parameters:
objectIDstr
- ID of the target object.method
- method to be executedparams
- parameters for the operation.callback
- callback handler to communicate the result when the execution finishes.- Returns:
- an id of the executed request that will receive the callback handler with the corresponding response
- Throws:
DataClayException
- if an exception occurs.
-
executeTask
public static String executeTask(String objectIDstr, String operationSignature, Object[] params, CallbackHandler callback) throws DataClayException
Executes a method on a specific target assynchronously.- Parameters:
objectIDstr
- ID of the target object.operationSignature
- signature of the method to be executed.params
- parameters for the operation.callback
- callback handler to communicate the result when the execution finishes.- Returns:
- an id of the executed request that will receive the callback handler with the corresponding response
- Throws:
DataClayException
- if an exception occurs.
-
getResult
public static Object getResult(CallbackEvent callbackEvent) throws DataClayException
Processes and retrieves the callback event produced by a task execution.- Parameters:
callbackEvent
- the event to be processed- Returns:
- The task result.
- Throws:
DataClayException
- if any exception occurs
-
string2IDandHintID
public static Triple<ObjectID,BackendID,MetaClassID> string2IDandHintID(String objectIDstr) throws DataClayException
Translates from string representation of an objectID to an ObjectID.- Parameters:
objectIDstr
- string representation of the object.- Returns:
- the ObjectID built from its string representation.
- Throws:
DataClayException
-
ids2String
public static String ids2String(ObjectID objectID, BackendID hint, MetaClassID classID)
Translates from ObjectID to string representation.- Parameters:
objectID
- ID of the object.hint
- hint where the object should beclassID
- class id of the object- Returns:
- string representation of the giving object.
-
getJavaBackends
public static Set<BackendID> getJavaBackends()
Retrieves all Java backends- Returns:
- info of the backends
-
getBackendInfo
public static Backend getBackendInfo(BackendID backendID)
Retrieves the info of a backend- Parameters:
backendID
- id of the backend- Returns:
- info of the backend
-
getCommonLib
public static ClientRuntime getCommonLib()
Getter for commonLib property.- Returns:
- common lib reference
-
getSessionID
public static SessionID getSessionID()
Getter for sessionID property.- Returns:
- sessionID
-
getMDmisses
public static int getMDmisses()
-
getMDhits
public static int getMDhits()
-
getDataClayID
public static DataClayInstanceID getDataClayID()
Retrieves current dataClay instance ID- Returns:
- id of current dataClay instance
-
getJavaBackend
public static BackendID getJavaBackend(String dsName)
Retrieves the id of ANY java backend with name provided- Parameters:
dsName
- DS name- Returns:
- id of ANY java backend with name provided
-
getExternalJavaBackend
public static BackendID getExternalJavaBackend(String dsName, DataClayInstanceID externalDcID)
Retrieves the id of external java backend with name provided in external dataClay specified- Parameters:
dsName
- DS nameexternalDcID
- External dataClay instance ID- Returns:
- id of external java backend with name provided in external dataClay specified
-
getDataClayID
public static DataClayInstanceID getDataClayID(String dcHost, int dcPort)
Retrieves the id of the external dataClay which Logic Module is located at provided host and listening on specified port.- Parameters:
dcHost
- host where the external dataClay is located.dcPort
- port where the external dataClay is listening.- Returns:
- id of the external dataClay
-
registerDataClay
public static DataClayInstanceID registerDataClay(String dcHost, int dcPort)
Registers an external dataClay to enable future object federation with it. Also returns its dataClay instance id.- Parameters:
dcHost
- host where the external dataClay is located.dcPort
- port where the external dataClay is listening.- Returns:
- id of the external dataClay
-
activateTracingInDataClayServices
public static void activateTracingInDataClayServices()
Activate tracing in dataClay services
-
deactivateTracingInDataClayServices
public static void deactivateTracingInDataClayServices()
Dectivate tracing
-
activateTracing
public static void activateTracing(boolean initializeWrapper)
Activate tracing
-
deactivateTracing
public static void deactivateTracing(boolean finalizeWrapper)
Dectivate tracing
-
getTracesInDataClayServices
public static final void getTracesInDataClayServices()
Get traces in dataClay services and store it in current workspace
-
unfederateAllObjects
public static void unfederateAllObjects(DataClayInstanceID extDataClayID)
Unfederate all objects belonging/federated with external dataClay with id provided- Parameters:
extDataClayID
- External dataClay ID
-
unfederateAllObjects
public static void unfederateAllObjects()
Unfederate all objects belonging/federated with ANY external dataClay
-
getNumObjects
public static int getNumObjects()
Get number of objects in dataClay
-
migrateFederatedObjects
public static 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
-
federateAllObjects
public static void federateAllObjects(DataClayInstanceID destinationDataClayID)
Federate all dataClay objects from specified current dataClay destination dataclay.- Parameters:
destinationDataClayID
- Destination dataclay id
-
importModelsFromExternalDataClay
public static void importModelsFromExternalDataClay(String externalNamespace, DataClayInstanceID extDataClayID)
Import classes in namespace specified from an external dataClay- Parameters:
externalNamespace
- External namespace to getextDataClayID
- External dataClay ID
-
-