zoukankan      html  css  js  c++  java
  • Solr Data Import Request Handler Scheduler

    转载自: http://www.cnblogs.com/ezhangliang/archive/2012/04/11/2441945.html

    Scheduler主要解决两个问题:

    1.定时增量更新索引。

    2.定时重做索引。

    经过测试,Scheduler已经可以实现完全基于配置,无需开发功能,无需人工干预的情况下实现以上两个功能(结合 Solr 的 Data Import Request Handler前提下)。

    为了方便以后使用,我将代码放到http://code.google.com上,地址是:http://code.google.com/p/solr-dataimport-scheduler/ 

    这里贴出一下主要的代码备忘:

    SolrDataImportProperties.java 配置文件读取:

    View Code

    BaseTimerTask.java  TimerTask基类,封装了一些基本的属性读取、请求发送方法:

    View Code

    DeltaImportHTTPPostScheduler.java 增量索引更新任务计划:

    View Code

    FullImportHTTPPostScheduler.java 重做索引任务计划:

    View Code

    ApplicationListener.java 调用任务计划的Listener:

    View Code

     

    使用说明
    1.将上面的编译文件打包成 apache-solr-dataimportscheduler-1.0.jar, 然后和solr自带的 apache-solr-dataimporthandler-*.jar, apache-solr-dataimporthandler-extras-*.jar 放到solr.war的lib目录下面
    2.修改solr.war中WEB-INF/web.xml, 在servlet节点前面增加:

    <listener> <listener-class> org.apache.solr.handler.dataimport.scheduler.ApplicationListener </listener-class> </listener>

    3.将apache-solr-dataimportscheduler-.jar 中 dataimport.properties 取出并根据实际情况修改,然后放到 solr.home/conf (不是solr.home/core/conf) 目录下面
    4.重启tomcat或者jboss 即可

    dataimport.properties 配置项说明

    复制代码
    ################################################# # # # dataimport scheduler properties # # # #################################################  # to sync or not to sync # 1 - active; anything else - inactive syncEnabled=1  # which cores to schedule # in a multi-core environment you can decide which cores you want syncronized # leave empty or comment it out if using single-core deployment syncCores=core1,core2  # solr server name or IP address # [defaults to localhost if empty] server=localhost  # solr server port # [defaults to 80 if empty] port=8080  # application name/context # [defaults to current ServletContextListener's context (app) name] webapp=solr  # URL params [mandatory] # remainder of URL params=/dataimport?command=delta-import&clean=false&commit=true# schedule interval # number of minutes between two runs # [defaults to 30 if empty] interval=1  # 重做索引的时间间隔,单位分钟,默认7200,即5天;  # 为空,为0,或者注释掉:表示永不重做索引 reBuildIndexInterval=7200  # 重做索引的参数 reBuildIndexParams=/dataimport?command=full-import&clean=true&commit=true# 重做索引时间间隔的计时开始时间,第一次真正执行的时间=reBuildIndexBeginTime+reBuildIndexInterval*60*1000; # 两种格式:2012-04-11 03:10:00 或者 03:10:00,后一种会自动补全日期部分为服务启动时的日期 reBuildIndexBeginTime=03:10:00
    复制代码
  • 相关阅读:
    celery 定时任务demo
    zip函数的使用
    关于数论的知识整理——待更新
    线性基
    博弈论博客推荐
    BZOJ1597: [Usaco2008 Mar]土地购买——斜率优化
    BZOJ1096 [ZJOI2007]仓库建设——斜率优化
    bzoj1010: [HNOI2008]玩具装箱toy——斜率优化
    斜率优化
    HDU3480 Division——四边形不等式或斜率优化
  • 原文地址:https://www.cnblogs.com/chenying99/p/2613416.html
Copyright © 2011-2022 走看看