maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ifedore...@apache.org
Subject svn commit: r1461840 - in /maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater: DefaultIndexUpdater.java FSDirectoryFactory.java IndexUpdateRequest.java
Date Wed, 27 Mar 2013 20:23:15 GMT
Author: ifedorenko
Date: Wed Mar 27 20:23:15 2013
New Revision: 1461840

URL: http://svn.apache.org/r1461840
Log:
MINDEXER-72 introduced updater FSDirectoryFactory API

FSDirectoryFactory allows host application choose specific
FSDirectory implementation. Default behaviour did not change
and deletages to Lucene FSDirectory.open.


Added:
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/FSDirectoryFactory.java
Modified:
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/DefaultIndexUpdater.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/IndexUpdateRequest.java

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/DefaultIndexUpdater.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/DefaultIndexUpdater.java?rev=1461840&r1=1461839&r2=1461840&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/DefaultIndexUpdater.java
(original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/DefaultIndexUpdater.java
Wed Mar 27 20:23:15 2013
@@ -182,7 +182,7 @@ public class DefaultIndexUpdater
         indexDir.delete();
         indexDir.mkdirs();
 
-        FSDirectory directory = FSDirectory.open( indexDir );
+        final Directory directory = updateRequest.getFSDirectoryFactory().open( indexDir
);
 
         BufferedInputStream is = null;
 

Added: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/FSDirectoryFactory.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/FSDirectoryFactory.java?rev=1461840&view=auto
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/FSDirectoryFactory.java
(added)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/FSDirectoryFactory.java
Wed Mar 27 20:23:15 2013
@@ -0,0 +1,49 @@
+package org.apache.maven.index.updater;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0    
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.lucene.store.FSDirectory;
+
+/**
+ * FSDirectoryFactory allows host application choose specific FSDirectory implementation
used during index update. This
+ * is useful in some environments where default Lucene heuristics results in suboptimal choice
of FSDirectory. For
+ * example, MMapDirectory used by default on 64 bit Linux JDK results in heavy operating
system swap with certain Linux
+ * configuration and host application can choose NIOFSDirectory to avoid the problem.
+ */
+public interface FSDirectoryFactory
+{
+    /**
+     * Default implementation that lets Lucene choose FSDirectory implementation.
+     */
+    public static final FSDirectoryFactory DEFAULT = new FSDirectoryFactory()
+    {
+        public FSDirectory open( File indexDir )
+            throws IOException
+        {
+            return FSDirectory.open( indexDir );
+        }
+    };
+
+    public FSDirectory open( File indexDir )
+        throws IOException;
+}

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/IndexUpdateRequest.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/IndexUpdateRequest.java?rev=1461840&r1=1461839&r2=1461840&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/IndexUpdateRequest.java
(original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/updater/IndexUpdateRequest.java
Wed Mar 27 20:23:15 2013
@@ -49,6 +49,8 @@ public class IndexUpdateRequest
 
     private boolean cacheOnly;
 
+    private FSDirectoryFactory directoryFactory;
+
     public IndexUpdateRequest( final IndexingContext context, final ResourceFetcher resourceFetcher
)
     {
         assert context != null : "Context to be updated cannot be null!";
@@ -128,4 +130,14 @@ public class IndexUpdateRequest
     {
         return cacheOnly;
     }
+
+    public void setLuceneDirectoryFactory( FSDirectoryFactory factory )
+    {
+        this.directoryFactory = factory;
+    }
+
+    public FSDirectoryFactory getFSDirectoryFactory()
+    {
+        return directoryFactory != null ? directoryFactory : FSDirectoryFactory.DEFAULT;
+    }
 }
\ No newline at end of file



Mime
View raw message