[ 
https://issues.apache.org/jira/browse/OAK-7947?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16750890#comment-16750890
 ] 

Thomas Mueller commented on OAK-7947:
-------------------------------------

The following addition doesn't download the indexes (only updates the stats for 
the indexes that are already downloaded, that is, only for those that are shown 
in the JMX bean table).

Maybe we could have some "middle ground", that is, by default download the 
indexes during the index upgrade cycle, but only those that aren't deprecated. 
That way, index update only doesn't cause large deprecated indexes to be 
downloaded. For non-deprecated indexes, I think it's actually good to download 
them quite early on, and the index update mechanism sounds like a good 
mechanism for that.

{noformat}
--- 
src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexMBeanImpl.java
      (revision 1851902)
+++ 
src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexMBeanImpl.java
      (working copy)
@@ -93,6 +93,8 @@
 
 public class LuceneIndexMBeanImpl extends AnnotatedStandardMBean implements 
LuceneIndexMBean {
 
+    private static final boolean LOAD_INDEX_FOR_STATS = 
Boolean.parseBoolean(System.getProperty("oak.lucene.LoadIndexForStats", 
"false"));
+
     private final Logger log = LoggerFactory.getLogger(getClass());
     private final IndexTracker indexTracker;
     private final NodeStore nodeStore;
@@ -381,11 +383,21 @@
 
     @Override
     public String getSize(String indexPath) throws IOException {
+        if (!LOAD_INDEX_FOR_STATS) {
+            if (!indexTracker.getIndexNodePaths().contains(indexPath)) {
+                return "-1";
+            }
+        }
         return String.valueOf(getIndexStats(indexPath).indexSize);
     }
 
     @Override
     public String getDocCount(String indexPath) throws IOException {
+        if (!LOAD_INDEX_FOR_STATS) {
+            if (!indexTracker.getIndexNodePaths().contains(indexPath)) {
+                return "-1";
+            }
+        }
         return String.valueOf(getIndexStats(indexPath).numDocs);
     }
{noformat}

> Lazy loading of Lucene index files startup
> ------------------------------------------
>
>                 Key: OAK-7947
>                 URL: https://issues.apache.org/jira/browse/OAK-7947
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: lucene, query
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>            Priority: Major
>         Attachments: OAK-7947.patch, OAK-7947_v2.patch, OAK-7947_v3.patch, 
> OAK-7947_v4.patch, OAK-7947_v5.patch, lucene-index-open-access.zip
>
>
> Right now, all Lucene index binaries are loaded on startup (I think when the 
> first query is run, to do cost calculation). This is a performance problem if 
> the index files are large, and need to be downloaded from the data store.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to