Class NoHostAvailableException

  • All Implemented Interfaces:
    Serializable

    public class NoHostAvailableException
    extends DriverException
    Exception thrown when a query cannot be performed because no host is available.

    This exception is thrown if either:

    • there is no host live in the cluster at the moment of the query;
    • all hosts that have been tried have failed.

    For debugging purposes, the list of hosts that have been tried along with the failure cause can be retrieved using the getErrors() method.

    See Also:
    Serialized Form
    • Constructor Detail

    • Method Detail

      • getErrors

        public Map<EndPoint,​Throwable> getErrors()
        Return the hosts tried along with the error encountered while trying them.
        Returns:
        a map containing for each tried host the error triggered when trying it.
      • getCustomMessage

        public String getCustomMessage​(int maxErrors,
                                       boolean formatted,
                                       boolean includeStackTraces)
        Builds a custom message for this exception.
        Parameters:
        maxErrors - the maximum number of errors displayed (useful to limit the size of the message for big clusters). Beyond this limit, host names are still displayed, but not the associated errors. Set to Integer.MAX_VALUE to display all hosts.
        formatted - whether to format the output (line break between each host).
        includeStackTraces - whether to include the full stacktrace of each host error. Note that this automatically implies formatted.
        Returns:
        the message.
      • copy

        public NoHostAvailableException copy()
        Description copied from class: DriverException
        Copy the exception.

        This returns a new exception, equivalent to the original one, except that because a new object is created in the current thread, the top-most element in the stacktrace of the exception will refer to the current thread (this is mainly intended for internal use by the driver). The cause of the copied exception will be the original exception.

        Overrides:
        copy in class DriverException
        Returns:
        a copy/clone of this exception.