qrtt1

Untitled

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