红色部分的调用
4.4.2 HttpSolrCall
/** * This method processes the request. */ public Action call() throwsIOException { MDCLoggingContext.reset(); MDCLoggingContext.setNode(cores); if (cores == null) { sendError(503, "Server is shutting down or failed to initialize"); returnRETURN; } if (solrDispatchFilter.abortErrorMessage != null) { sendError(500, solrDispatchFilter.abortErrorMessage); returnRETURN; } try{ init();//1 /* Authorize the request if 1. Authorization is enabled, and 2. The requested resource is not a known static file */ if (cores.getAuthorizationPlugin() != null &&shouldAuthorize()) { AuthorizationContext context =getAuthCtx(); log.debug("AuthorizationContext : {}", context); AuthorizationResponse authResponse =cores.getAuthorizationPlugin().authorize(context); if (authResponse.statusCode ==AuthorizationResponse.PROMPT.statusCode) { Map headers = (Map) getReq().getAttribute(AuthenticationPlugin.class.getName()); if (headers != null) { for (Map.Entrye : headers.entrySet()) response.setHeader(e.getKey(), e.getValue()); } log.debug("USER_REQUIRED "+req.getHeader("Authorization")+" "+req.getUserPrincipal()); } if (!(authResponse.statusCode == HttpStatus.SC_ACCEPTED) && !(authResponse.statusCode ==HttpStatus.SC_OK)) { log.info("USER_REQUIRED auth header {} context : {} ", req.getHeader("Authorization"), context); sendError(authResponse.statusCode, "Unauthorized request, Response code: " +authResponse.statusCode); returnRETURN; } } HttpServletResponse resp =response; switch(action) { caseADMIN: handleAdminRequest(); returnRETURN; caseREMOTEQUERY: remoteQuery(coreUrl +path, resp); returnRETURN; casePROCESS: final Method reqMethod =Method.getMethod(req.getMethod()); HttpCacheHeaderUtil.setCacheControlHeader(config, resp, reqMethod); // unless we have been explicitly told not to, do cache validation // if we fail cache validation, execute the query if (config.getHttpCachingConfig().isNever304() || !HttpCacheHeaderUtil.doCacheHeaderValidation(solrReq, req, reqMethod, resp)) { SolrQueryResponse solrRsp = newSolrQueryResponse(); /* even for HEAD requests, we need to execute the handler to * ensure we don't get an error (and to make sure the correct * QueryResponseWriter is selected and we get the correct * Content-Type) */SolrRequestInfo.setRequestInfo(newSolrRequestInfo(solrReq, solrRsp)); execute(solrRsp); //2 HttpCacheHeaderUtil.checkHttpCachingVeto(solrRsp, resp, reqMethod); Iterator> headers =solrRsp.httpHeaders(); while(headers.hasNext()) { Map.Entry entry =headers.next(); resp.addHeader(entry.getKey(), entry.getValue()); } QueryResponseWriter responseWriter =getResponseWriter(); if (invalidStates != null) solrReq.getContext().put(CloudSolrClient.STATE_VERSION, invalidStates); writeResponse(solrRsp, responseWriter, reqMethod); } returnRETURN; default: returnaction; } } catch(Throwable ex) { sendError(ex); // walk the the entire cause chain to search for an Error Throwable t =ex; while (t != null) { if (t instanceofError) { if (t !=ex) { log.error("An Error was wrapped in another exception - please report complete stacktrace on SOLR-6161", ex); } throw(Error) t; } t =t.getCause(); } returnRETURN; } finally {
MDCLoggingContext.clear();
}
}
其中 1初始化,2.执行请求调用