SOLR dataimport data import source code analysis (1)

Source: Internet
Author: User

SOLR's request processing interface is solrrequesthandler. java. The handlerequest method is used to process requests from HTTP.

/*************************************** ********************************
* Module: solrrequesthandler. Java
* Author: Administrator
* Purpose: defines the interface solrrequesthandler
**************************************** *******************************/

Import java. util .*;

/** @ Pdoid 92641501-9fac-4850-bf72-43e262d42eff */
Public interface solrrequesthandler {
/** @ Param ARGs
* @ Pdoid 0d916c92-cb61-408c-844d-a756cc1e9a41 */
Void Init (namedlist ARGs );
/** @ Param req
* @ Param RSP
* @ Pdoid 35c91800-4167-49d1-aefe-c961fb7082d1 */
Void handlerequest (solrqueryrequest req, solrqueryresponse RSP );

}

The common implementation class is requesthandlerbase. java.

/*************************************** ********************************

* Module: requesthandlerbase. Java
* Author: Administrator
* Purpose: defines the class requesthandlerbase
**************************************** *******************************/

Import java. util .*;

/** @ Pdoid 9e2891cc-6977-4d7e-86f8-d406a3493599 */
Public abstract class requesthandlerbase implements solrrequesthandler {
/** @ Param ARGs
* @ Pdoid 48f0c55d-b3a3-4736-8e47-1c866398eeef */
Public void Init (namedlist ARGs ){

}

/** @ Param req
* @ Param RSP
* @ Exception
* @ Pdoid 3eec0a97-ed48-4f4e-b78b-142247478b69 */
Public abstract void handlerequestbody (solrqueryrequest req, solrqueryresponse RSP) throws exception;
/** @ Param req
* @ Param RSP
* @ Pdoid 7b97a1ac-509c-4a03-aaed-a2bbd320dbcc */
Public void handlerequest (solrqueryrequest req, solrqueryresponse RSP ){

}

}

This is an abstract class. The abstract method handlerequestbody is implemented by sub-classes. The real processing logic is implemented by the sub-class handlerequestbody method.

Handlerequest calls the handlerequestbody method of the subclass. This is a typical template method design mode.

The implementation class for data import is dataimporthandler. java. The sample code is as follows:

/*************************************** ********************************

* Module: dataimporthandler. Java
* Author: Administrator
* Purpose: defines the class dataimporthandler
**************************************** *******************************/

Import java. util .*;

/** @ Pdoid 1277dd7d-601d-45c7-a2ef-1836f46db6f3 */
Public class dataimporthandler extends requesthandlerbase {
/** @ Pdoid 6e53bcab-98f0-4ce1-97a0-1c15e9be51ac */
Private dataimporter importer;

/** @ Param req
* @ Param RSP
* @ Exception
* @ Pdoid 15ebeea5-1faf-4d9d-89bb-3c4be63bf15a */
Public void handlerequestbody (solrqueryrequest req, solrqueryresponse RSP) throws exception {
Importer. runcmd (requestparams, SW );

}

}

The dataimporthandler class holds the reference of dataimporter and calls the related methods of the dataimporter class for further processing.

The brief class diagram is as follows:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.