15. 架构图 端口 1985 IndexRebuilder IndexUpdater Searcher 配置文件 DAL 数据更新 同步通知搜索 搜索客户端调用 Searcher 的 API 搜索管理后台 发出开始重建索引命令 cron 发送重建数据 端口 1986 IndexReceiver Rebuild xml data Update xml data
21. IndexUpdater (续) UpdateExecutor 线程 强制停止: ConfigUtils.getTopTaskFileDir(indexId) + "/stop.sign" 删除 ConfigUtils.getTopTaskFileDir(indexId) 目录 检测是否有新的 rebuild 索引(下页详细说明) 循环处理 getTopTaskFileDir(indexId) 下的 xml 文件 无 xml 文件? Thread sleep ,再次查看 有 xml 文件? 是否需要合并大小库? 处理 xml 文件 ShootSnap 拷贝一份索引的快照到 snap 目录
22. IndexUpdater (续二) UpdateExecutor 线程(续) 如果有新的 rebuild 索引 Backup oldTaskFiles , oldIdxFiles copy new idx to updater's src idx, and rebuilder's update xml to updater's task dir SetRebuildTransIdxFinishSign() to tell receiver that trans idx finished receiver 停止 copy update xml 到 rebuild update 目录,并作一些清理的工作 Updater 线程回到正常更新的循环
30. ControlCenter Bash 脚本 Usage: ./controlCenter.sh {start|stop|restart} {all|receiver|updater|rebuilder|searcher|trans|cleaner} OR: ./controlCenter.sh {start|stop|restart} monitor OR: ./controlCenter.sh {mkdirs} Stop all 的时候, searcher 和 receiver 两个 service 进程不会停止( use stop all all ) 在一台新的机器上部署的时候,先使用 ./controlCenter.sh mkdirs 建立必要的目录结构
31. 开发中的一些收获(一) FileChannel.transferTo 拷贝文件失败: An attempt is made to read up to count bytes starting at the given position in this channel's file and write them to the target channel. An invocation of this method may or may not transfer all of the requested bytes; whether or not it does so depends upon the natures and states of the channels. Fewer than the requested number of bytes are transferred if this channel's file contains fewer than count bytes starting at the given position, or if the target channel is non-blocking and it has fewer than count bytes free in its output buffer. 解决: check copied size ,断点续传
32. 开发中的一些收获(二) Kill 的问题 Never kill smart frog, don't kill -9 Java use Runtime.getRuntime().addShutdownHook to do the cleaning things Lucene IndexWrite need close!