Class DataClayObject

    • Field Detail

      • DEBUG_ENABLED

        protected static final boolean DEBUG_ENABLED
        Indicates if debug is enabled.
      • logger

        public static final org.apache.logging.log4j.Logger logger
        Logger.
      • clientRuntime

        public static DataClayRuntime clientRuntime
        Client runtime.
      • objectID

        protected ObjectID objectID
        ObjectID of the stub instance.
      • isPersistent

        protected AtomicBoolean isPersistent
        Indicates if the object is registered or not.
      • isLoaded

        protected AtomicBoolean isLoaded
        Indicates if the object was filled with data.
      • dataSetID

        protected DataSetID dataSetID
        ID of dataset of object. Used for user to specify which DataSet to use in store.
      • LOCAL

        public static BackendID LOCAL
        'LOCAL' location
    • Constructor Detail

      • DataClayObject

        public DataClayObject()
        Constructor
      • DataClayObject

        public DataClayObject​(ObjectID theobjectID)
        Constructor
        Parameters:
        theobjectID - ID of the object
    • Method Detail

      • initializeObjectAsPersistent

        public void initializeObjectAsPersistent()
        Initialize object with state 'persistent' with proper flags. See same function in DataClayExecutionObject for a different initialization. This design is intended to be clear with object state. Usually, since constructors are calling initializeObjectAsVolatile, this function 'overrides' flags set
      • initializeObjectAsVolatile

        public void initializeObjectAsVolatile()
        Initialize object with state 'volatile' with proper flags. Usually, volatile state is created by a stub, app, exec class,.. See same function in DataClayExecutionObject for a different initialization. This design is intended to be clear with object state.
      • setLoaded

        public final void setLoaded​(boolean newisLoaded)
        Set the DataClayObject::isLoaded
        Parameters:
        newisLoaded - the isLoaded to set
      • getByAlias

        protected static DataClayObject getByAlias​(MetaClassID classID,
                                                   String alias,
                                                   boolean safe)
        Generic static method to instantiate a DataClayObject by its alias
        Parameters:
        classID - id of real class of the instance
        alias - alias of the instance
        safe - if true, checks that an object with the provided alias exists
        Returns:
        the reference to persistent object of given class with given alias
      • getByAliasExt

        public static <E> E getByAliasExt​(String alias)
        This method can be used from registered methods to access objects by alias, this method is parameterized in order to provide to the users a way to implement and compile an application using a model to be registered (extending DataClayObject).
        Type Parameters:
        E - type of the object requested
        Parameters:
        alias - alias of object to be requested
        Returns:
        The object identified by the provided alias
      • getByAliasExt

        public static <E> E getByAliasExt​(String alias,
                                          boolean safe)
        This method can be used from registered methods to access objects by alias, this method is parameterized in order to provide to the users a way to implement and compile an application using a model to be registered (extending DataClayObject).
        Type Parameters:
        E - type of the object requested
        Parameters:
        alias - alias of object to be requested
        safe - if true, checks that an object with the provided alias exists
        Returns:
        The object identified by the provided alias
      • deleteAlias

        public static void deleteAlias​(String className,
                                       String alias)
        Deletes an alias of an object of a specific class
        Parameters:
        className - class name of the object
        alias - alias of the object
      • deleteAlias

        public static void deleteAlias​(String alias)
        Method to be specialized
        Parameters:
        alias - alias to be removed from this object
      • deleteAlias

        public void deleteAlias()
        Delete object's alias
      • setObjectIDUnsafe

        public void setObjectIDUnsafe​(ObjectID newObjectID)
        Set the object's id This method is labeled as unsafe as the user should be aware it is just possible to change ids of non-persistent objects. There no warranty that, once persisted, an object will keep the same id.
        Parameters:
        newObjectID - The ObjectID to set
      • debugStart

        public final void debugStart​(String opNameAndDesc)
        Debug start of running method
        Parameters:
        opNameAndDesc - Operation name and descriptor
      • debugEnd

        public final void debugEnd​(String opNameAndDesc)
        Debug end of running method
        Parameters:
        opNameAndDesc - Operation name and descriptor
      • setNewObjectID

        public final void setNewObjectID()
        Set a new object ID (used for remove objects)
      • getLib

        public static final DataClayRuntime getLib()
        Get DataService client library
        Returns:
        DataService client library
      • setLib

        public static void setLib​(DataClayRuntime theruntime)
        Set runtime
        Parameters:
        theruntime - the runtime to set
      • isPersistent

        public final boolean isPersistent()
        Indicates the object is persistent.
        Returns:
        TRUE if it is persistent. FALSE otherwise.
      • setIsPersistent

        public final void setIsPersistent​(boolean newisPersistent)
        Set the DataClayObject:newisPersistent
        Parameters:
        newisPersistent - the isPersistent to set
      • getMetaClassID

        public static MetaClassID getMetaClassID​(String className)
        Get metaclass ID of the specified class name
        Parameters:
        className - name of the class
        Returns:
        ID of the class
      • run

        public Object run​(ImplementationID implID,
                          Object[] params)
        Runs the method with ID provided and params specified
        Parameters:
        implID - ID of the method to invoke
        params - Parameters of the method
        Returns:
        Result of the method
      • synchronize

        public void synchronize​(ImplementationID implID,
                                Object[] params)
        Synchronize
        Parameters:
        implID - implementation ID to be invoked on federated object
        params - Parameters of the method
      • wrapFieldsSerialization

        public void wrapFieldsSerialization​(List<DataClaySerializable> wrapFields)
        Wraps fields for serialization
        Parameters:
        wrapFields - [out] Wrapped fields
      • wrapFieldsDeserialization

        public void wrapFieldsDeserialization​(List<DataClaySerializable> wrapFields)
        Wraps fields for deserialization
        Parameters:
        wrapFields - [out] Wrapped fields
      • setFieldsDeserialization

        public void setFieldsDeserialization​(Queue<Object> fieldsToSet)
        Set fields
        Parameters:
        fieldsToSet - Fields to set, in order.
      • wrapParameters

        public List<DataClaySerializable> wrapParameters​(ImplementationID implID,
                                                         Object[] params)
        Wraps parameters for serialization
        Parameters:
        implID - ID of the method to invoke
        params - Parameters of the method
        Returns:
        Wrapped parameters
      • wrapReturn

        public List<DataClaySerializable> wrapReturn​(ImplementationID implID,
                                                     Object ret)
        Wraps return for serialization
        Parameters:
        implID - ID of the method to invoke
        ret - Return of the method
        Returns:
        Wrapped return
      • setWrappersParams

        public void setWrappersParams​(ImplementationID implID,
                                      SerializedParametersOrReturn wrapParams)
        Unwraps parameters for deserialization
        Parameters:
        implID - ID of the method to invoke
        wrapParams - Wrapped Parameters of the method
      • setWrappersReturn

        public void setWrappersReturn​(ImplementationID implID,
                                      SerializedParametersOrReturn wrapReturn)
        Unwraps return for deserialization
        Parameters:
        implID - ID of the method to invoke
        wrapReturn - Wrapped return of the method
      • setAll

        public void setAll​(DataClayObject otherObject)
        This method set all fields with values of fields of provided object.
        Parameters:
        otherObject - object with values of fields to set.
      • dcClone

        public DataClayObject dcClone()
        Retrieves a copy of this object
        Returns:
        a non-persistent copy of this object
      • dcClone

        public DataClayObject dcClone​(boolean recursive)
        Retrieves a copy of this object
        Parameters:
        recursive - whether to also copy its subobjects or not
        Returns:
        a non-persistent copy of this object
      • dcCloneByAlias

        public static DataClayObject dcCloneByAlias​(String alias)
        Retrieves a copy of this object (but not the subobjects)
        Parameters:
        alias - alias of the object to be retrieved
        Returns:
        a non-persistent copy of this object
      • dcCloneByAlias

        public static DataClayObject dcCloneByAlias​(String alias,
                                                    boolean recursive)
        Retrieves a copy of this object
        Parameters:
        alias - alias of the object to be retrieved
        recursive - whether to also copy its subobjects or not
        Returns:
        a non-persistent copy of this object
      • dcUpdate

        public final void dcUpdate​(DataClayObject fromObject)
        Updates this object alias with the values in argument object
        Parameters:
        fromObject - object to be copied to this object
      • dcUpdateByAlias

        public static final void dcUpdateByAlias​(String alias,
                                                 DataClayObject fromObject)
        Updates the object identified by the given alias with the values in argument object
        Parameters:
        alias - alias of the object to be updated
        fromObject - object to be copied to this object
      • dcPut

        public final void dcPut​(String alias)
        Equivalent to makePersistent
        Parameters:
        alias - alias for the object
      • dcPut

        public final void dcPut​(String alias,
                                BackendID optBackendID)
        Equivalent to makePersistent
        Parameters:
        alias - alias for the object
        optBackendID - optional backend where to persist this object
      • dcPut

        public final void dcPut​(String alias,
                                boolean recursive)
        Equivalent to makePersistent
        Parameters:
        alias - alias for the object
        recursive - whether subobjects are also persisted or not
      • dcPut

        public final void dcPut​(String alias,
                                BackendID optBackendID,
                                boolean recursive)
        Equivalent to makePersistent
        Parameters:
        alias - alias for the object
        optBackendID - optional backend where to persist this object
        recursive - whether subobjects are also persisted or not
      • makePersistent

        public final void makePersistent​(BackendID optBackendID)
        Overrides:
        makePersistent in class StorageObject
        Parameters:
        optBackendID - optional backend where the object must be stored
      • makePersistent

        public final void makePersistent​(boolean recursive)
        Store this object into DataClay.
        Overrides:
        makePersistent in class StorageObject
        Parameters:
        recursive - Indicates if all referenced objects from this objects that are not already persistent must also be stored. If true, all referenced objects are also stored. If the object is already persistent i.e. contains a DataClay objectID this function will fail.
      • makePersistent

        public final void makePersistent​(boolean recursive,
                                         BackendID optionalBackendID)
        Store this object into DataClay.
        Overrides:
        makePersistent in class StorageObject
        Parameters:
        recursive - Indicates if all referenced objects from this objects that are not already persistent must also be stored. If true, all referenced objects are also stored. If the object is already persistent i.e. contains a DataClay objectID this function will fail.
        optionalBackendID - ID of the backend in which the object must be stored. If null, any backend is accepted.
      • makePersistent

        public final void makePersistent​(String alias,
                                         BackendID destBackendID)
        Store this object into DataClay.
        Overrides:
        makePersistent in class StorageObject
        Parameters:
        alias - alias for the object
        destBackendID - ID of the backend in which the object must be stored. If null, any backend is accepted.
      • makePersistent

        public final void makePersistent​(String alias,
                                         boolean recursive)
        Store this object into DataClay.
        Overrides:
        makePersistent in class StorageObject
        Parameters:
        alias - alias for the object
        recursive - Indicates if all referenced objects from this objects that are not already persistent must also be stored. If true, all referenced objects are also stored. If the object is already persistent i.e. contains a DataClay objectID this function will fail.
      • makePersistent

        public final void makePersistent​(String alias,
                                         BackendID destBackendID,
                                         boolean recursive)
        Store this object into DataClay.
        Overrides:
        makePersistent in class StorageObject
        Parameters:
        alias - alias for the object
        destBackendID - ID of the backend in which the object must be stored. If null, any backend is accepted.
        recursive - Indicates if all referenced objects from this objects that are not already persistent must also be stored. If true, all referenced objects are also stored. If the object is already persistent i.e. contains a DataClay objectID this function will fail.
      • newReplica

        public final BackendID newReplica()
        Creates a new replica of this persistent object and its subobjects in a certain backend.
        Overrides:
        newReplica in class StorageObject
        Returns:
        The ID of the backend in which the replica was created.
      • newReplica

        public final BackendID newReplica​(boolean recursive)
        Creates a new replica of this persistent object in a certain backend.
        Overrides:
        newReplica in class StorageObject
        Parameters:
        recursive - Indicates if all sub-objects must be replicated as well.
        Returns:
        The ID of the backend in which the replica was created.
      • newReplica

        public final BackendID newReplica​(BackendID optionalBackendID)
        Creates a new replica of this persistent object.
        Overrides:
        newReplica in class StorageObject
        Parameters:
        optionalBackendID - ID of the backend in which to create the replica. If null, any backend is accepted. If the object is not persistent i.e. does not contain a DataClay objectID this function will fail.
        Returns:
        The ID of the backend in which the replica was created.
      • newReplica

        public final BackendID newReplica​(BackendID optionalBackendID,
                                          boolean recursive)
        Create a new replica of this persistent object.
        Overrides:
        newReplica in class StorageObject
        Parameters:
        optionalBackendID - ID of the backend in which to create the replica. If null, any backend is accepted. If the object is not persistent i.e. does not contain a DataClay objectID this function will fail.
        recursive - Indicates if all sub-objects must be replicated as well.
        Returns:
        The ID of the backend in which the replica was created.
      • moveObject

        public final void moveObject​(BackendID srcLocID,
                                     BackendID destLocID)
        Moves a persistent object and referenced objects from the source location to the destination location specified. If the object is not persistent i.e. does not contain a DataClay objectID this function will fail.
        Overrides:
        moveObject in class StorageObject
        Parameters:
        srcLocID - of the source location in which the object is stored.
        destLocID - of the destination location in which the object should be moved.
      • moveObject

        public final void moveObject​(BackendID srcLocID,
                                     BackendID destLocID,
                                     boolean recursive)
        Moves a persistent object from the source location to the destination location specified. If the object is not persistent i.e. does not contain a DataClay objectID this function will fail.
        Overrides:
        moveObject in class StorageObject
        Parameters:
        srcLocID - of the source location in which the object is stored.
        destLocID - of the destination location in which the object should be moved.
        recursive - Indicates if all sub-objects must be moved as well.
      • setObjectReadOnly

        public final void setObjectReadOnly()
        Sets this persistent object to be read only. If the object is not persistent i.e. does not contain a DataClay objectID this function will fail.
        Overrides:
        setObjectReadOnly in class StorageObject
      • setObjectReadWrite

        public final void setObjectReadWrite()
        Sets this persistent object to be read write. If the object is not persistent i.e. does not contain a DataClay objectID this function will fail.
        Overrides:
        setObjectReadWrite in class StorageObject
      • getLocation

        public final BackendID getLocation()
        Gets the location of this persistent object.
        Overrides:
        getLocation in class StorageObject
        Returns:
        ID of the backend in which the object is stored. If the object is not persistent i.e. does not contain a DataClay objectID this function will fail.
      • getAllLocations

        public final Set<BackendID> getAllLocations()
        Gets the location of this persistent object and its replicas.
        Overrides:
        getAllLocations in class StorageObject
        Returns:
        A set of IDs of the backend in which this object or its replicas are stored. If the object is not persistent i.e. does not contain a DataClay objectID this function will fail.
      • federate

        public void federate​(DataClayInstanceID extDataClayID,
                             boolean recursive)
        Federates this object with an external dataClay instance
        Parameters:
        extDataClayID - id of the external dataClay instance
        recursive - whether to federate recursively or not
      • unfederate

        public void unfederate​(DataClayInstanceID extDataClayID,
                               boolean recursive)
        Unfederate this object with the provided external dataClay
        Parameters:
        extDataClayID - id of the external dataClay instance
        recursive - whether to unfederate recursively or not
      • unfederate

        public void unfederate​(boolean recursive)
        Unfederate this object with all external dataClays is registered with
        Parameters:
        recursive - whether to unfederate recursively or not
      • federate

        public void federate​(DataClayInstanceID extDataClayID)
        Federates this object with an external dataClay instance
        Parameters:
        extDataClayID - id of the external dataClay instance
      • unfederate

        public void unfederate​(DataClayInstanceID extDataClayID)
        Unfederate this object with the provided external dataClay
        Parameters:
        extDataClayID - id of the external dataClay instance
      • federateToBackend

        public void federateToBackend​(BackendID extBackendID)
        Federates this object with an external backend instance
        Parameters:
        extBackendID - id of the external backend to federate
      • federateToBackend

        public void federateToBackend​(BackendID extBackendID,
                                      boolean recursive)
        Federates this object with an external backend instance
        Parameters:
        extBackendID - id of the external backend to federate
        recursive - Indicates if federation is recursive or not
      • unfederateFromBackend

        public void unfederateFromBackend​(BackendID extBackendID)
        Unfederates this object with an external backend instance
        Parameters:
        extBackendID - id of the external backend to federate
      • unfederateFromBackend

        public void unfederateFromBackend​(BackendID extBackendID,
                                          boolean recursive)
        Unfederates this object with an external backend instance
        Parameters:
        extBackendID - id of the external backend to federate
        recursive - Indicates if unfederation is recursive or not
      • getExternalDataClayID

        public final DataClayInstanceID getExternalDataClayID​(String hostname,
                                                              int port)
        Retrieve dataClay ID
        Parameters:
        hostname - Name of external dataclay
        port - Port of external dataclay
        Returns:
        ID of external dataclay
      • sessionDetach

        public final void sessionDetach()
        Detach object from session, i.e. remove reference from current session provided to current object, "dear garbage-collector, the current session is not using this object anymore"
      • whenFederated

        public void whenFederated()
        Override this function with code to be executed when a federated object arrives into a destination dataClay.
      • whenUnfederated

        public void whenUnfederated()
        Override this function with code to be executed when a federate object is unfederated in destination dataClay.
      • serialize

        public void serialize​(DataClayByteBuffer dcBuffer,
                              boolean ignoreUserTypes,
                              Map<MetaClassID,​byte[]> ifaceBitMaps,
                              IdentityHashMap<Object,​Integer> curSerializedObjs,
                              ListIterator<DataClayObject> pendingObjs,
                              ReferenceCounting referenceCounting)
        Description copied from interface: DataClaySerializable
        Serializes the object into the buffer provided using the interface represented in the bitmap specified.
        Specified by:
        serialize in interface DataClaySerializable
        Parameters:
        dcBuffer - Buffer in which to serialize the object
        ignoreUserTypes - Indicates if user types found during serialization must be ignored or not (for instance, non recursive make persistent)
        ifaceBitMaps - Map of bitmaps representing the interfaces to use
        curSerializedObjs - Current serialized objects Object -> OID tag. This structure must be different during each serialization since OID tags are not shared.
        pendingObjs - Pending objs.
        referenceCounting - Reference counting from this object.
      • deserialize

        public void deserialize​(DataClayByteBuffer dcBuffer,
                                Map<MetaClassID,​byte[]> ifaceBitMaps,
                                DataClayObjectMetaData metadata,
                                Map<Integer,​Object> curDeserializedJavaObjs)
        Description copied from interface: DataClaySerializable
        Deserializes the object from the buffer provided using the interface represented in the bitmap specified.
        Specified by:
        deserialize in interface DataClaySerializable
        Parameters:
        dcBuffer - Buffer from which to deserialize the object
        ifaceBitMaps - Map of bitmaps representing the interfaces to use
        metadata - Useful metadata of the object for execution
        curDeserializedJavaObjs - Currently deserialized Java objects
      • getHint

        public BackendID getHint()
        Get the DataClayObject::hint
        Returns:
        the hint
      • setHint

        public void setHint​(BackendID newhint)
        Set the DataClayObject::hint
        Parameters:
        newhint - the hint to set
      • clearExecStubInfosCache

        public static final void clearExecStubInfosCache()
        Clear exec stub infos cache for enrichments.
      • clearStubInfosCache

        public static final void clearStubInfosCache()
        Clear stub infos cache for enrichments.
      • getStubInfo

        public final StubInfo getStubInfo()
        Get stub information of class
        Returns:
        Stub information
      • isStub

        public static final boolean isStub​(Class<?> clazz)
        Checks if class provided is stub or not.
        Parameters:
        clazz - Class to check.
        Returns:
        True if it is an stub. False otherwise.
      • getStubInfoFromClass

        public static final StubInfo getStubInfoFromClass​(String className)
        Get stubinfo for class with name provided
        Parameters:
        className - Name of the class
        Returns:
        Stub information.
      • executeRemoteImplementation

        public Object executeRemoteImplementation​(String methodSignature,
                                                  String implIDAsStr,
                                                  Object[] params)
        Execute remote method
        Overrides:
        executeRemoteImplementation in class StorageObject
        Parameters:
        methodSignature - Signature of the method
        implIDAsStr - ImplementationID as string
        params - Parameters to send
        Returns:
        Return value.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getDataSetID

        public DataSetID getDataSetID()
        Get DataSetID
        Returns:
        DataSetID
      • setDataSetID

        public void setDataSetID​(DataSetID newDataSetID)
        Set object DataSetID
        Parameters:
        newDataSetID - ID of DataSet this object belongs to
      • getMasterLocation

        public final BackendID getMasterLocation()
        Returns:
        the masterLocation
      • setMasterLocation

        public void setMasterLocation​(BackendID newMasterLocation)
        If called from client side will not have any effect.
        Parameters:
        newMasterLocation - the masterLocation to set
      • getAlias

        public String getAlias()
        Get alias
        Returns:
        the alias of the object
      • setAlias

        public void setAlias​(String alias)
        Set the alias of the object
        Parameters:
        alias - the alias of the object
      • isReadOnly

        public boolean isReadOnly()
        Get if object is read only
        Returns:
        boolean indicating if object is read only or not
      • setReadOnly

        public void setReadOnly​(boolean readOnly)
        Set if object is read only
        Parameters:
        readOnly - boolean indicating if object is read only or not
      • getOriginalObjectID

        public final ObjectID getOriginalObjectID()
        Returns:
        the original object id in case of new version
      • setOriginalObjectID

        public void setOriginalObjectID​(ObjectID newOriginalObjectID)
        Parameters:
        newOriginalObjectID - the original object id to set
      • getRootLocation

        public ExecutionEnvironmentID getRootLocation()
        Returns:
        root location of the object or null if current is original
      • setRootLocation

        public void setRootLocation​(ExecutionEnvironmentID rootLocation)
        Set root location of the object
        Parameters:
        rootLocation - root location to set
      • getOriginLocation

        public ExecutionEnvironmentID getOriginLocation()
        Returns:
        origin location of the object or null if current is original
      • setOriginLocation

        public void setOriginLocation​(ExecutionEnvironmentID originLocation)
        Set origin location of the object
        Parameters:
        originLocation - origin location to set
      • getReplicaLocations

        public Set<ExecutionEnvironmentID> getReplicaLocations()
        Get all replica locations
        Returns:
        Replica locations
      • setReplicaLocations

        public void setReplicaLocations​(Set<ExecutionEnvironmentID> replicaLocations)
        Set replica locations
        Parameters:
        replicaLocations - replica locations to set
      • addReplicaLocations

        public void addReplicaLocations​(ExecutionEnvironmentID replicaLocation)
        Add replica location
        Parameters:
        replicaLocation - replica location to add
      • removeReplicaLocation

        public void removeReplicaLocation​(ExecutionEnvironmentID replicaLocation)
        Remove replica location
        Parameters:
        replicaLocation - replica location to add
      • clearReplicaLocations

        public void clearReplicaLocations()
        Clear replica locations
      • isMasterLocation

        public final boolean isMasterLocation()
        Returns:
        true if masterlocation is the current backend, false otherwise
      • getExternalDataClayID

        public DataClayInstanceID getExternalDataClayID()
        Returns:
        id of the external dataClay instance where the object resides. null if it is local.
      • setExternalDataClayID

        public void setExternalDataClayID​(DataClayInstanceID newID)
        Parameters:
        newID - id of the external dataClay instance
      • isPrefetchingAccess

        public boolean isPrefetchingAccess()
        RT PREFETCHING FIELDS
      • setPrefetchingAccess

        public static void setPrefetchingAccess​(boolean value)
      • getAccessCount

        public static long getAccessCount()
      • getHitCount

        public static long getHitCount()
      • incrementAccessCount

        protected void incrementAccessCount()
      • incrementHitCount

        protected void incrementHitCount()
      • resetObjectAccessStats

        public static void resetObjectAccessStats()
      • printObjectAccessStats

        public static void printObjectAccessStats()