Lucene - Lock获得超时:快速请求的SimpleFSLock

时间:2012-08-22 19:26:22

标签: lucene httpmodule

我有一个httpmodule,它将对网站的每次访问记录为lucene索引。 该网站托管在godaddy上,甚至由于我在页面上几乎没有任何东西我做了测试(大约3kb包括css),它运行缓慢。

如果我尝试刷新几次,在第二次或第三次刷新后,我会收到Lock obtain timed out: SimpleFSLock错误。

我的问题是,我做错了什么?或这是正常的行为? 有没有办法克服这个问题?

我的代码:

        //state the file location of the index
        string indexFileLocation = System.IO.Path.Combine(HttpContext.Current.ApplicationInstance.Server.MapPath("~/App_Data"), "Analytics");
        Lucene.Net.Store.Directory dir = Lucene.Net.Store.FSDirectory.GetDirectory(indexFileLocation, false);

        //create an analyzer to process the text
        Lucene.Net.Analysis.Analyzer analyzer = new Lucene.Net.Analysis.Standard.StandardAnalyzer();

        //create the index writer with the directory and analyzer defined.
        Lucene.Net.Index.IndexWriter indexWriter = new Lucene.Net.Index.IndexWriter(dir, analyzer, false);

        //create a document, add in a single field
        Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
        doc.Add(new Lucene.Net.Documents.Field("TimeStamp", DateTime.Now.ToString(), Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NOT_ANALYZED, Lucene.Net.Documents.Field.TermVector.NO));
        doc.Add(new Lucene.Net.Documents.Field("IP", request.UserHostAddress.ToString(), Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NOT_ANALYZED, Lucene.Net.Documents.Field.TermVector.NO));

        //write the document to the index
        indexWriter.AddDocument(doc);

        //optimize and close the writer
        //indexWriter.Optimize();
        indexWriter.Close();

0 个答案:

没有答案