gpt4 book ai didi

google-app-engine - Google App Engine : Lucene org. apache.lucene.store.LockObtainFailedException:锁定获取超时

转载 作者:行者123 更新时间:2023-12-04 05:13:30 27 4
gpt4 key购买 nike

Google APP engine , 我正在使用 Lucene 4.1 .

我能够在本地生成索引文件,但在谷歌服务器上我收到以下异常(尽管相同的代码在本地机器上运行良好):

org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out:
com.googlecode.lucene.appengine.GaeLockFactory$1@104a681

这是我的代码:
package com.search.domain;

import java.io.IOException;
import java.util.Set;

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.util.Version;

import com.domain.dataobjects.Item;
import com.googlecode.lucene.appengine.GaeDirectory;
import com.googlecode.lucene.appengine.GaeLuceneUtil;


public class ItemDataIndexWriter {

public String createIndexes(){
IndexWriter indexWriter = null;
GaeDirectory indexDirectory = null;
try{
indexDirectory = new GaeDirectory();

StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_41 );

IndexWriterConfig config = GaeLuceneUtil.getIndexWriterConfig(Version.LUCENE_41, analyzer);//get configuration

config.setOpenMode(OpenMode.CREATE_OR_APPEND);
indexWriter = new IndexWriter(indexDirectory, config);

addToDoc(indexWriter,"test");
}catch(Exception e){
e.printStackTrace();
System.out.println(e.getMessage());
return e.toString();
}
finally{
try {
if(indexWriter!=null)
indexWriter.close();
if(indexDirectory!=null)
indexDirectory.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println(e.getMessage());
}
}
return "Good";
}


private static void addToDoc(IndexWriter w, String item) throws IOException {

Document doc = new Document();
doc.add(new TextField("item", item, Field.Store.YES));
w.addDocument(doc);
}
}

任何人都可以指导我吗?怎么了?

最佳答案

只需进入 Google AppEngine administration -> Datastore viewer , 选择 GaeLock 实体并删除所有实体,这样做您将解锁因任何原因被锁定的每个 Lucene 索引。

小心!可能您的数据存储处于脏状态,因此您必须通过删除以下所有条目来手动删除索引:LuceneIndex , Segment , SegmentHunk , GaeLock .

当 Lucene AppEngine 没有正确配置时,您可能会遇到这个问题。查看 lucene-appengine site 上的配置说明.

关于google-app-engine - Google App Engine : Lucene org. apache.lucene.store.LockObtainFailedException:锁定获取超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14598958/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com