Author: chetanm
Date: Thu Sep 15 07:17:10 2016
New Revision: 1760848

URL: http://svn.apache.org/viewvc?rev=1760848&view=rev
Log:
OAK-4412 - Lucene hybrid index

Benchmark - Handle case where exception gets thrown as Lucene related services 
gets closed before shutdown in afterSuite call

Modified:
    
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/HybridIndexTest.java

Modified: 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/HybridIndexTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/HybridIndexTest.java?rev=1760848&r1=1760847&r2=1760848&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/HybridIndexTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/HybridIndexTest.java
 Thu Sep 15 07:17:10 2016
@@ -87,7 +87,7 @@ public class HybridIndexTest extends Abs
     private int asyncInterval = Integer.getInteger("asyncInterval", 5);
     private int queueSize = Integer.getInteger("queueSize", 1000);
     private boolean hybridIndexEnabled = 
Boolean.getBoolean("hybridIndexEnabled");
-    private boolean metricStatsEnabled = 
Boolean.getBoolean("metricStatsEnabled");
+    private boolean metricStatsEnabled = 
Boolean.parseBoolean(System.getProperty("metricStatsEnabled", "true"));
     private File indexCopierDir;
     private IndexCopier copier;
     private NRTIndexFactory nrtIndexFactory;
@@ -166,6 +166,10 @@ public class HybridIndexTest extends Abs
     @Override
     protected void afterSuite() throws Exception {
         if (hybridIndexEnabled){
+            //TODO This to avoid issue with Indexing still running post 
afterSuite call
+            //TO handle this properly we would need a callback after 
repository shutdown
+            //and before NodeStore teardown
+            getAsyncIndexUpdate().close();
             queue.close();
             nrtIndexFactory.close();
             dumpStats();
@@ -180,6 +184,9 @@ public class HybridIndexTest extends Abs
     }
 
     private void dumpStats() {
+        if (!metricStatsEnabled) {
+            return;
+        }
         ConsoleReporter.forRegistry(metricStatsProvider.getRegistry())
                 .outputTo(System.out)
                 .filter(new MetricFilter() {
@@ -247,13 +254,16 @@ public class HybridIndexTest extends Abs
     }
 
     private void runAsyncIndex() {
-        Runnable async = WhiteboardUtils.getService(whiteboard, 
Runnable.class, new Predicate<Runnable>() {
-            @Override
-            public boolean apply(@Nullable Runnable input) {
-                return input instanceof AsyncIndexUpdate;
-            }
-        });
-        checkNotNull(async).run();
+        checkNotNull(getAsyncIndexUpdate()).run();
+    }
+
+    private AsyncIndexUpdate getAsyncIndexUpdate() {
+        return (AsyncIndexUpdate)WhiteboardUtils.getService(whiteboard, 
Runnable.class, new Predicate<Runnable>() {
+                @Override
+                public boolean apply(@Nullable Runnable input) {
+                    return input instanceof AsyncIndexUpdate;
+                }
+            });
     }
 
     private static File createTemporaryFolderIn(File parentFolder) throws 
IOException {


Reply via email to