Class DaemonClient

  • All Implemented Interfaces:
    Loggable

    public class DaemonClient
    extends LoggedObject
    Client for the Cargo daemon
    • Constructor Detail

      • DaemonClient

        public DaemonClient​(URL url)
        Creates a Cargo daemon wrapper for the specified URL which has public access (no username nor password required).
        Parameters:
        url - the full URL of the Cargo daemon instance to use
      • DaemonClient

        public DaemonClient​(URL url,
                            String username,
                            String password)
        Creates a Cargo daemon wrapper for the specified URL, username and password that uses UTF-8 URL encoding.
        Parameters:
        url - the full URL of the Cargo daemon instance to use
        username - the username to use when authenticating with Cargo daemon
        password - the password to use when authenticating with Cargo daemon
    • Method Detail

      • setLogger

        public void setLogger​(Logger logger)
        Overriden in order to set the logger on ancillary components.
        Specified by:
        setLogger in interface Loggable
        Overrides:
        setLogger in class LoggedObject
        Parameters:
        logger - the logger to set and set in the ancillary objects
      • getURL

        public URL getURL()
        Gets the full URL of the Cargo daemon instance.
        Returns:
        the full URL of the Cargo daemon instance
      • getUserName

        public String getUserName()
        Gets the username to use when authenticating with Cargo daemon.
        Returns:
        the username to use when authenticating with Cargo daemon
      • getPassword

        public String getPassword()
        Gets the password to use when authenticating with Cargo daemon.
        Returns:
        the password to use when authenticating with Cargo daemon
      • getUserAgent

        public String getUserAgent()
        Gets the user agent name to use when communicating with Cargo daemon.
        Returns:
        the user agent name to use when communicating with Cargo daemon
      • setUserAgent

        public void setUserAgent​(String userAgent)
        Sets the user agent name to use when communicating with Cargo daemon.
        Parameters:
        userAgent - the user agent name to use when communicating with Cargo daemon
      • stop

        public void stop​(String handleId)
                  throws DaemonException,
                         IOException
        Stops the container with the specified handle identifier.
        Parameters:
        handleId - The unique identifier of the container
        Throws:
        DaemonException - if the Cargo daemon request fails
        IOException - if an i/o error occurs
      • invoke

        protected String invoke​(String path,
                                DaemonParameters parameters)
                         throws DaemonException,
                                IOException
        Invokes Cargo daemon with a specified command and content data.
        Parameters:
        path - the Cargo daemon command to invoke
        parameters - an input stream to the content data
        Returns:
        the result of the invoking command, as returned by the Cargo daemon application
        Throws:
        DaemonException - if the Cargo daemon request fails
        IOException - if an i/o error occurs