jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chet...@apache.org
Subject svn commit: r1573450 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins: blob/BlobStoreConfiguration.java document/DocumentMK.java document/DocumentNodeStoreService.java
Date Mon, 03 Mar 2014 05:57:46 GMT
Author: chetanm
Date: Mon Mar  3 05:57:46 2014
New Revision: 1573450

URL: http://svn.apache.org/r1573450
Log:
OAK-1483 - Data Stores not initialized through the MongoDocumentStoreService

Applying patch from Amit Jain with some changes

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreConfiguration.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreConfiguration.java?rev=1573450&r1=1573449&r2=1573450&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreConfiguration.java
Mon Mar  3 05:57:46 2014
@@ -17,13 +17,13 @@
 package org.apache.jackrabbit.oak.plugins.blob;
 
 import java.io.IOException;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
 import javax.annotation.Nullable;
 
+import com.google.common.base.Strings;
 import org.osgi.framework.BundleContext;
 
 import com.google.common.base.Predicate;
@@ -60,15 +60,12 @@ public class BlobStoreConfiguration {
         Properties props = new Properties();
         try {
             props.load(this.getClass().getResourceAsStream("blobstore.properties"));
-        } catch (IOException e) {
+        } catch (IOException ignore) {
         }
 
         // populate keys from the default set
         Map<String, String> defaultMap = Maps.fromProperties(props);
-        Iterator<String> iter = defaultMap.keySet().iterator();
-        while (iter.hasNext()) {
-            propKeys.add(iter.next());
-        }
+        propKeys.addAll(defaultMap.keySet());
 
         // Remove empty default properties from the map
         getConfigMap().putAll(
@@ -141,10 +138,9 @@ public class BlobStoreConfiguration {
     public BlobStoreConfiguration loadFromContextOrMap(Map<String, ?> map, BundleContext
context) {
         loadFromMap(map);
 
-        Map<String, Object> contextMap = Maps.newHashMap();
         for (String key : getPropKeys()) {
             if (context.getProperty(key) != null) {
-                contextMap.put(key, context.getProperty(key));
+                configMap.put(key, context.getProperty(key));
             }
         }
         return this;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java?rev=1573450&r1=1573449&r2=1573450&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentMK.java
Mon Mar  3 05:57:46 2014
@@ -472,8 +472,13 @@ public class DocumentMK implements Micro
          */
         public Builder setMongoDB(DB db) {
             if (db != null) {
-                this.documentStore = new MongoDocumentStore(db, this);
-                this.blobStore = new MongoBlobStore(db);
+                if(this.documentStore == null){
+                    this.documentStore = new MongoDocumentStore(db, this);
+                }
+
+                if(this.blobStore == null){
+                    this.blobStore = new MongoBlobStore(db);
+                }
             }
             return this;
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java?rev=1573450&r1=1573449&r2=1573450&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
Mon Mar  3 05:57:46 2014
@@ -25,6 +25,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
+import javax.annotation.CheckForNull;
+
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.ConfigurationPolicy;
@@ -116,8 +118,7 @@ public class DocumentNodeStoreService {
         int offHeapCache = PropertiesUtil.toInteger(prop(config, PROP_OFF_HEAP_CACHE), DEFAULT_OFF_HEAP_CACHE);
         int cacheSize = PropertiesUtil.toInteger(prop(config, PROP_CACHE), DEFAULT_CACHE);
         boolean useMK = PropertiesUtil.toBoolean(config.get(PROP_USE_MK), false);
-        String blobStoreType = PropertiesUtil.toString(config.get(BlobStoreConfiguration.PROP_BLOB_STORE_PROVIDER),
-                BlobStoreConfiguration.DEFAULT_BLOB_STORE_PROVIDER);
+
 
         MongoClientOptions.Builder builder = MongoConnection.getDefaultBuilder();
         MongoClientURI mongoURI = new MongoClientURI(uri, builder);
@@ -136,22 +137,20 @@ public class DocumentNodeStoreService {
 
         // Check if any valid external BlobStore is defined.
         // If not then use the default which is MongoBlobStore
-        BlobStore blobStore = null;
-        if (Strings.isNullOrEmpty(blobStoreType)) {
-            blobStore = BlobStoreHelper.create(
-                    BlobStoreConfiguration.newInstance().
-                            loadFromContextOrMap(config, context))
-                    .orNull();
-        }
+        BlobStore blobStore = createBlobStore(config);
 
         DocumentMK.Builder mkBuilder = 
                 new DocumentMK.Builder().
                 memoryCacheSize(cacheSize * MB).
-                offHeapCacheSize(offHeapCache * MB).
-                setMongoDB(mongoDB);
+                offHeapCacheSize(offHeapCache * MB);
+
+        //Set blobstore before setting the DB
         if (blobStore != null) {
             mkBuilder.setBlobStore(blobStore);
         }
+
+        mkBuilder.setMongoDB(mongoDB);
+
         mk = mkBuilder.open();
 
         logger.info("Connected to database {}", mongoDB);
@@ -173,6 +172,23 @@ public class DocumentNodeStoreService {
         reg = context.registerService(NodeStore.class.getName(), store, new Properties());
     }
 
+    @CheckForNull
+    private BlobStore createBlobStore(Map<String, ?> config) throws Exception {
+        String blobStoreType = PropertiesUtil.toString(
+                prop(config, BlobStoreConfiguration.PROP_BLOB_STORE_PROVIDER),
+                BlobStoreConfiguration.DEFAULT_BLOB_STORE_PROVIDER);
+
+        BlobStore blobStore = null;
+        if (!Strings.isNullOrEmpty(blobStoreType)) {
+            blobStore = BlobStoreHelper.create(
+                    BlobStoreConfiguration.newInstance().
+                            loadFromContextOrMap(config, bundleContext))
+                    .orNull();
+            logger.info("BlobStore Configured {}", blobStore);
+        }
+        return blobStore;
+    }
+
     private Object prop(Map<String, ?> config, String propName){
         return prop(config, propName, PREFIX + propName);
     }



Mime
View raw message