You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ch...@apache.org on 2015/08/07 13:00:38 UTC

svn commit: r1694654 - /jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/OakOSGiRepositoryFactory.java

Author: chetanm
Date: Fri Aug  7 11:00:38 2015
New Revision: 1694654

URL: http://svn.apache.org/r1694654
Log:
OAK-3195 - Allow finer control for timeout handling in case of repository startup

Modified:
    jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/OakOSGiRepositoryFactory.java

Modified: jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/OakOSGiRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/OakOSGiRepositoryFactory.java?rev=1694654&r1=1694653&r2=1694654&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/OakOSGiRepositoryFactory.java (original)
+++ jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/OakOSGiRepositoryFactory.java Fri Aug  7 11:00:38 2015
@@ -44,6 +44,7 @@ import org.apache.felix.connect.launch.P
 import org.apache.felix.connect.launch.PojoServiceRegistryFactory;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.jackrabbit.api.JackrabbitRepository;
+import org.apache.jackrabbit.oak.commons.PropertiesUtil;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -77,6 +78,12 @@ import static com.google.common.base.Pre
  *
  *      <dt>org.apache.jackrabbit.oak.repository.bundleFilter</dt>
  *      <dd>Used to specify the bundle filter string which is passed to ClasspathScanner</dd>
+ *
+ *      <dt>org.apache.jackrabbit.oak.repository.startupTimeout</dt>
+ *      <dd>Timeout in seconds for the repository startup should wait. Defaults to 10 minutes</dd>
+ *
+ *      <dt>org.apache.jackrabbit.oak.repository.shutDownOnTimeout</dt>
+ *      <dd>Boolean flag to determine if the OSGi container should be shutdown upon timeout. Defaults to false</dd>
  *  </dl>
  */
 public class OakOSGiRepositoryFactory implements RepositoryFactory {
@@ -93,7 +100,7 @@ public class OakOSGiRepositoryFactory im
      * Timeout in seconds for the repository startup should wait
      */
     public static final String REPOSITORY_STARTUP_TIMEOUT
-            = "org.apache.jackrabbit.oak.repository.startupTimeOut";
+            = "org.apache.jackrabbit.oak.repository.startupTimeout";
 
     /**
      * Config key which refers to the map of config where key in that map refers to OSGi
@@ -110,6 +117,9 @@ public class OakOSGiRepositoryFactory im
     public static final String REPOSITORY_BUNDLE_FILTER
             = "org.apache.jackrabbit.oak.repository.bundleFilter";
 
+    public static final String REPOSITORY_SHUTDOWN_ON_TIMEOUT =
+            "org.apache.jackrabbit.oak.repository.shutDownOnTimeout";
+
     /**
      * Default timeout for repository creation
      */
@@ -168,7 +178,12 @@ public class OakOSGiRepositoryFactory im
             throw new RepositoryException(e);
         } catch (TimeoutException e) {
             try {
-                shutdown(registry);
+                if (PropertiesUtil.toBoolean(config.get(REPOSITORY_SHUTDOWN_ON_TIMEOUT), true)) {
+                    shutdown(registry);
+                    log.info("OSGi container shutdown after waiting for repository initialization for {} sec",timeout);
+                }else {
+                    log.warn("[{}] found to be false. Container is not stopped", REPOSITORY_SHUTDOWN_ON_TIMEOUT);
+                }
             } catch (BundleException be) {
                 log.warn("Error occurred while shutting down the service registry (due to " +
                         "startup timeout) backing the Repository ", be);