lucene 异常 Lock obtain timed out 解决方法
生活随笔
收集整理的這篇文章主要介紹了
lucene 异常 Lock obtain timed out 解决方法
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
http://terje.blog.163.com/blog/static/119243712008102122316595/
一般都是索引建立的過程中,不正常操作影響了IndexWriter正常使用,那么下次在使用這個(gè)IndexWriter就有這種問題了。最簡單的方法,手動(dòng)刪掉文件鎖,重新創(chuàng)建一個(gè)IndexWriter實(shí)例。或者在創(chuàng)建實(shí)例的時(shí)候刪掉鎖。 經(jīng)驗(yàn),將保持的IndexWriter實(shí)例取出來(為提高效率,減少對磁盤的IO,管理了IndexWriter的實(shí)例),關(guān)閉后(異常之前建立的索引是沒問題的,關(guān)閉是使他生效),重新構(gòu)造一個(gè)實(shí)例。 實(shí)戰(zhàn)代碼:? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??// org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: NativeFSLock@/data/index/ipsos/weibo24/cache/201209/write.lock ????????????????????????????????????????????????// 獲取文件鎖超時(shí),IndexWriter關(guān)閉后,刪掉鎖,重新獲取 ????????????????????????????????????????????????if?(e.getMessage().indexOf("Lock obtain timed out") != -1) { ??????????????????????????????????????????????????????LoggerUtil.debugTrace(bizTypeEnName, _objId +?" IndexWriter{ "?+ indexFilePath +?" }獲取文件鎖超時(shí),IndexWriter關(guān)閉,等待重新獲取"); ??????????????????????????????????????????????????????if?(!Validate.isEmpty(indexFilePath)) { ????????????????????????????????????????????????????????????IndexWriter indexWriter = writerMap.get(indexFilePath); ????????????????????????????????????????????????????????????LoggerUtil.debugTrace(bizTypeEnName, _objId +?" IndexWriter{ "?+ indexFilePath +?" }關(guān)閉開始,是否為空 "?+ (null?== indexWriter)); ????????????????????????????????????????????????????????????if?(null?!= indexWriter) { ??????????????????????????????????????????????????????????????????indexWriter.close(); ??????????????????????????????????????????????????????????????????LoggerUtil.debugTrace(bizTypeEnName, _objId +?" IndexWriter{ "?+ indexFilePath +?" }關(guān)閉成功,等待重新獲取已開始"); ??????????????????????????????????????????????????????????????????indexWriter =?null; ????????????????????????????????????????????????????????????} ??????????????????????????????????????????????????????} ????????????????????????????????????????????????}
?
轉(zhuǎn)載于:https://www.cnblogs.com/svennee/p/4080613.html
總結(jié)
以上是生活随笔為你收集整理的lucene 异常 Lock obtain timed out 解决方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: (王道考研计算机网络)第一章计算机网络体
- 下一篇: (软件工程复习核心重点)第十二章软件项目