org.cdlib.xtf.crossQuery.test
Class TestableCrossQuery

Object
  extended by GenericServlet
      extended by HttpServlet
          extended by TextServlet
              extended by CrossQuery
                  extended by TestableCrossQuery
All Implemented Interfaces:
Serializable, Servlet, ServletConfig

public class TestableCrossQuery
extends CrossQuery

Derived version of the crossQuery servlet, used to abuse crossQuery during load tests. The main difference is that it throws exceptions upward instead of formatting an error page. This ensures that exceptions don't get hidden in the noise. Also, for each thread we track the number of hits returned by the last request.

Author:
Martin Haye
See Also:
Serialized Form

Field Summary
private  ThreadLocal<Integer> nHits
           
 
Fields inherited from class CrossQuery
config, decimalFormat
 
Fields inherited from class TextServlet
stylesheetCache
 
Constructor Summary
TestableCrossQuery()
           
 
Method Summary
protected  void formatHits(String mainTagName, HttpServletRequest req, HttpServletResponse res, AttribList attribs, QueryRequest queryRequest, QueryResult queryResult, long startTime)
          Formats a list of hits using the resultFormatter stylesheet.
protected  void genErrorPage(HttpServletRequest req, HttpServletResponse res, Exception exc)
          Generate an error page based on the given exception.
 int nHits()
          Return the number of hits in the last request processed by this thread
 
Methods inherited from class CrossQuery
apply, doGet, getConfig, getConfigName, getServletInfo, readConfig, runQueryParser, runQueryRouter, shuntQueryReq, stepSetup
 
Methods inherited from class TextServlet
addParam, addToken, addTokens, buildParamBlock, calcMimeType, convertUTF8inURL, cqlTokenize, createFilteredReceiver, createQueryProcessor, decodeURL, defaultTokenize, doPost, getCurRequest, getCurResponse, getCurServlet, getRealPath, getRequestURL, getText, isEmpty, isSessionTrackingEnabled, makeAttribList, makeHtmlString, makeHtmlString, rawTokenize, readBranding, requireOrElse, restoreWildcards, saveWildcards, service, setErrorGenSheet, stuffAttribs, stuffAttribs, stuffSpecialAttribs
 
Methods inherited from class HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service
 
Methods inherited from class GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nHits

private ThreadLocal<Integer> nHits
Constructor Detail

TestableCrossQuery

public TestableCrossQuery()
Method Detail

nHits

public int nHits()
Return the number of hits in the last request processed by this thread


formatHits

protected void formatHits(String mainTagName,
                          HttpServletRequest req,
                          HttpServletResponse res,
                          AttribList attribs,
                          QueryRequest queryRequest,
                          QueryResult queryResult,
                          long startTime)
                   throws Exception
Description copied from class: CrossQuery
Formats a list of hits using the resultFormatter stylesheet.

Overrides:
formatHits in class CrossQuery
Parameters:
mainTagName - Name of the top-level tag to generate (e.g. "crossQueryResult", etc.)
req - The original HTTP request
res - Where to send the HTML response
attribs - Parameters to pass to the stylesheet
queryRequest - Query request that produced the hits
queryResult - Hits resulting from the query request
startTime - Time (in milliseconds) request began
Throws:
Exception

genErrorPage

protected void genErrorPage(HttpServletRequest req,
                            HttpServletResponse res,
                            Exception exc)
Description copied from class: TextServlet
Generate an error page based on the given exception. Utilizes the system error stylesheet to produce a nicely formatted HTML page.

Overrides:
genErrorPage in class TextServlet
Parameters:
req - The HTTP request we're responding to
res - The HTTP result to write to
exc - The exception producing the error. If it's a DynaXMLException, the attributes will be passed to the error stylesheet.