Class JabbixRequest

  • All Implemented Interfaces:
    java.lang.Runnable

    public class JabbixRequest
    extends java.lang.Object
    implements java.lang.Runnable
    A task object that is used to asynchronously query the value of a metric.
    Author:
    Paul Wolneykien
    • Constructor Summary

      Constructors 
      Constructor Description
      JabbixRequest​(AgentServer srv, java.net.Socket sock)
      Creates a request task object with the specified parametres.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getCommand()
      Returns the command that is set to be processed.
      boolean isParsed()
      Indicates if the request is parsed.
      void run()
      Starts the request process.
      void setCommand​(java.lang.String cmd)
      Sets the command to be processed by this request.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JabbixRequest

        public JabbixRequest​(AgentServer srv,
                             java.net.Socket sock)
        Creates a request task object with the specified parametres.
        Parameters:
        srv - a metric agent server using to get the suitable metric agent for a key being requested
        sock - a connected socket to read the request data from and send the retrieved metric value to
    • Method Detail

      • isParsed

        public boolean isParsed()
        Indicates if the request is parsed. If the command parameter isn't set on the request process start, then an attempt is made to read the command from the socket and parse it.
        Returns:
        true if the command is parsed, false otherwise
        See Also:
        run()
      • getCommand

        public java.lang.String getCommand()
        Returns the command that is set to be processed.
        Returns:
        the command to be processed by this request
      • setCommand

        public void setCommand​(java.lang.String cmd)
        Sets the command to be processed by this request. Normally, no command is set prior to the request process start and an attempt is made to read the command from the socket and parse it.
        Parameters:
        cmd - a command to set
        See Also:
        run()
      • run

        public void run()
        Starts the request process. If the command parameter isn't set on the request process start, then an attempt is made to read the command from the socket and parse it. If the command is parsed successfully the parsed and command properties are set. Then the command is processed. If it is identified as a metric key then a metric agent is requested from the agent server and the fresh metric value is retrieved from it. The new metric value is then sent to the requester as a data response.
        Specified by:
        run in interface java.lang.Runnable
        Throws:
        java.lang.RuntimeException - if there was an exception during the request-response process
        See Also:
        isParsed(), getCommand()