Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DB table lucene_sync(seqNo, path, timestamp)
- writer (num_of_buffer, time_margin):
- 1. 持續地建 lucence index
- 2. 建完 index 後,clone 至新的資料夾 /tmp/lucene_201207191230
- 2.1 如果上一筆記錄時間小於 time_margin 則 goto 1.
- 3. 寫入 db
- 3.1 檢查 lucene_sync 數量,大於等 num_of_buffer 時,從最舊的開始刪,刪到 num_of_buffer -1
- 3.2 增加一部記錄 (/tmp/lucene_201207191230, NOW())
- 4. goto 1.
- PS. time_margin 建議值為 20 分鐘,num_of_buffer 建議值為 3
- reader
- 1. 每當 user search 後,檢查 lucene_sync table 是否有比目前資料新的資料
- 2. 當有新的 lucene_sync entry 時:
- 2.1 檢查是不是有 /tmp/lucence_next,若沒有則 呼叫 rsync_from_tw1.sh ${path}
- 2.2 檢查是不是有 /tmp/lucene_text/DONE 檔案,若沒有則略過,若有著進行 3. 目錄交換。
- 3. 目錄交換
- 3.1 reader.close()
- 3.2 rename /tmp/luceneIndex -> /tmp/lucene_old (如果有舊的先砍掉)
- 3.3 rename /tmp/lucene_next -> /tmp/luceneIndex
- 3.4 reader.open()
- PS. 如果有 exception 發生,則 rename /tmp/lucene_old -> /tmp/luceneIndex,回到原點。
Advertisement
Add Comment
Please, Sign In to add comment