Class StorageQueueHandler

    • Field Detail

      • m_Name

        protected String m_Name
        the name of the queue.
      • m_Limit

        protected int m_Limit
        the limit for the queue (-1 is unlimited).
      • m_Logging

        protected Actor m_Logging
        the (optional) logging actor.
      • m_Monitoring

        protected Actor m_Monitoring
        the (optional) monitoring actor.
    • Constructor Detail

      • StorageQueueHandler

        public StorageQueueHandler​(String name)
        Initializes the limitless queue with no logging.
        Parameters:
        name - the name of the queue
      • StorageQueueHandler

        public StorageQueueHandler​(String name,
                                   int limit,
                                   Actor logging,
                                   Actor monitoring)
        Initializes the queue with the specified limit and logging.
        Parameters:
        name - the name of the queue
        limit - the size limit, use <= 0 for unlimited
        logging - the logging actor for sending the LogEntry objects to
        monitoring - the monitoring actor for sending the LogEntry objects to
    • Method Detail

      • setLoggingLevel

        public void setLoggingLevel​(LoggingLevel value)
        Sets the logging level.
        Parameters:
        value - the level
      • getname

        public String getname()
        Returns the name of the queue.
        Returns:
        the name
      • getLimit

        public int getLimit()
        Returns the limit of the queue.
        Returns:
        the limit
      • hasLogging

        public boolean hasLogging()
        Checks whether a logging actor is available.
        Returns:
        true if available
      • getLogging

        public Actor getLogging()
        Returns the logging actor.
        Returns:
        the actor, null if not available
      • hasMonitoring

        public boolean hasMonitoring()
        Checks whether a monitoring actor is available.
        Returns:
        true if available
      • getMonitoring

        public Actor getMonitoring()
        Returns the monitoring actor.
        Returns:
        the actor, null if not available
      • log

        protected void log​(LogEntry log,
                           Actor actor)
        Logs the log entry with the specified actor.
        Parameters:
        log - the log entry to send
        actor - the logging actor to send the LogEntry to
      • logError

        protected void logError​(String msg,
                                Object obj)
        Creates a log entry and sends it to the logging actor.
        Parameters:
        msg - the msg
        obj - the object
      • logMonitor

        protected void logMonitor​(String type,
                                  Object obj)
        Creates a log entry and sends it to the monitoring actor.
        Parameters:
        type - the monitoring event type (Add or Remove)
        obj - the object to add, null in case of remove
      • add

        public boolean add​(Object obj)
        Adds the object to the queue.
        Parameters:
        obj - the object to add
        Returns:
        true if successfully added
      • remove

        public Object remove()
        Removes the first element from the queue and returns it.
        Returns:
        the first element from the queue
      • size

        public int size()
        Returns the size of the queue.
        Returns:
        the size
      • poll

        public Object poll​(long timeout,
                           TimeUnit unit)
                    throws InterruptedException
        Polls the queue in a blocking fashion.
        Parameters:
        timeout - the timeout for the poll
        unit - the time unit
        Returns:
        the value from the queue
        Throws:
        InterruptedException - if interrupted
      • toString

        public String toString()
        Returns a short description of the queue.
        Overrides:
        toString in class Object
        Returns:
        the description