Class MessageSoftRef


  • public final class MessageSoftRef
    extends Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private AgentId deadNotAgentId
      The agent responsible of treating the notification when it expires.
      private static boolean DEBUG  
      private long expiration
      The expiration date of the notification hold by the message, if any.
      private static Logger logger  
      private String messageId
      If the notification is stored independently of its containing message, messageId contains the persistent name of this notification.
      private String name
      Name for persistent message, used to retrieve garbaged message from persistent storage.
      private Message ref
      Reference for transient message, used to pin non persistent in memory.
      private SoftReference<Message> softRef
      The SoftReference to the message, which permits to the message to be garbaged in response to memory demand.
      private int stamp
      The stamp of the referenced message.
    • Field Detail

      • logger

        private static final Logger logger
      • DEBUG

        private static final boolean DEBUG
      • name

        private String name
        Name for persistent message, used to retrieve garbaged message from persistent storage.
      • ref

        private Message ref
        Reference for transient message, used to pin non persistent in memory.
      • softRef

        private SoftReference<Message> softRef
        The SoftReference to the message, which permits to the message to be garbaged in response to memory demand.
      • stamp

        private int stamp
        The stamp of the referenced message. It is useful to avoid reloading messages from disk when looking for a particular message.
      • messageId

        private String messageId
        If the notification is stored independently of its containing message, messageId contains the persistent name of this notification.
      • expiration

        private long expiration
        The expiration date of the notification hold by the message, if any.
      • deadNotAgentId

        private AgentId deadNotAgentId
        The agent responsible of treating the notification when it expires. It is useful to avoid reloading messages from disk before deleting them if the field is empty.
    • Constructor Detail

      • MessageSoftRef

        MessageSoftRef​(Message msg)
    • Method Detail

      • isExpired

        public boolean isExpired​(long time)
        Tests whether the message has expired.
        Parameters:
        time - the current time.
        Returns:
        true if the message has expired.
      • getDeadNotAgentId

        public AgentId getDeadNotAgentId()
        Returns the agent responsible of treating the notification when it expires.
        Returns:
        the unique identifier of the agent responsible of treating the notification after expiration.
      • getMessage

        public Message getMessage()
        Returns this reference message's referent. If the message has been swap out it returns null.
        Returns:
        The message to which this reference refers.
      • getStamp

        public int getStamp()
        Returns the stamp of the message backed by this MessageSoftRef, without reloading it if it has been swapped.
        Returns:
        the stamp of the message.
      • loadMessage

        public Message loadMessage()
                            throws MessageSoftRef.TransactionError
        Returns the message to which this reference refers, loading it from disk if the message has been swapped out. If loading from disk is done, the SoftReference is renewed to avoid reloading the message each time this method is called.
        Returns:
        The message to which this reference refers.
        Throws:
        MessageSoftRef.TransactionError
      • delete

        public void delete()
        Deletes the message in persistent storage. This method must be called during a Transaction.
      • toString

        public String toString()
        Returns a string representation of this MessageSoftRef object.
        Overrides:
        toString in class Object
        Returns:
        A string representation of this object.