Class VespaHeaders


  • public final class VespaHeaders
    extends java.lang.Object
    Static helper methods which implement the mapping between the ErrorMessage API and HTTP headers and return codes.
    Author:
    Einar M R Rosenvinge, Steinar Knutsen, Simon Thoresen Hult, bratseth
    • Constructor Summary

      Constructors 
      Constructor Description
      VespaHeaders()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean benchmarkCoverage​(boolean benchmarkOutput, com.yahoo.jdisc.HeaderFields headers)  
      static boolean benchmarkOutput​(HttpRequest request)
      Returns true if this is a benchmarking request, according to headers
      static void benchmarkOutput​(com.yahoo.jdisc.HeaderFields responseHeaders, boolean benchmarkCoverage, Timing t, com.yahoo.container.logging.HitCounts c, int errorCount, Coverage coverage)
      Add search benchmark output to the HTTP getHeaders.
      static int getEagerErrorStatus​(ErrorMessage mainError, java.util.Iterator<? extends ErrorMessage> allErrors)
      Returns 5xx or 4xx if there is any error present in the result, 200 otherwise
      static int getStatus​(boolean isSuccess, ErrorMessage mainError, java.util.Iterator<? extends ErrorMessage> allErrors)
      (during normal execution) return 200 unless this is not a success or a 4xx error is requested.
      • Methods inherited from class java.lang.Object

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

      • VespaHeaders

        public VespaHeaders()
    • Method Detail

      • benchmarkCoverage

        public static boolean benchmarkCoverage​(boolean benchmarkOutput,
                                                com.yahoo.jdisc.HeaderFields headers)
      • benchmarkOutput

        public static boolean benchmarkOutput​(HttpRequest request)
        Returns true if this is a benchmarking request, according to headers
      • benchmarkOutput

        public static void benchmarkOutput​(com.yahoo.jdisc.HeaderFields responseHeaders,
                                           boolean benchmarkCoverage,
                                           Timing t,
                                           com.yahoo.container.logging.HitCounts c,
                                           int errorCount,
                                           Coverage coverage)
        Add search benchmark output to the HTTP getHeaders.
        Parameters:
        responseHeaders - the response to write the headers to
        benchmarkCoverage - true to include coverage headers
        t - the Timing to read data from
        c - the Counts to read data from
        errorCount - the error count
        coverage - the Coverage to read data from
      • getStatus

        public static int getStatus​(boolean isSuccess,
                                    ErrorMessage mainError,
                                    java.util.Iterator<? extends ErrorMessage> allErrors)
        (during normal execution) return 200 unless this is not a success or a 4xx error is requested.
        Parameters:
        isSuccess - whether or not the response represents a success
        mainError - the main error of the response, if any
        allErrors - all the errors of the response, if any
        Returns:
        the status code of the given response
      • getEagerErrorStatus

        public static int getEagerErrorStatus​(ErrorMessage mainError,
                                              java.util.Iterator<? extends ErrorMessage> allErrors)
        Returns 5xx or 4xx if there is any error present in the result, 200 otherwise
        Parameters:
        mainError - The main error of the response.
        allErrors - All the errors of the response, if any.
        Returns:
        The error status code of the given response.