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 2014/05/27 13:54:38 UTC

svn commit: r1597751 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/ oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/ oak-pojos...

Author: chetanm
Date: Tue May 27 11:54:38 2014
New Revision: 1597751

URL: http://svn.apache.org/r1597751
Log:
OAK-1676 - NodeStoreServices nondeterministic with customBlobStore

blobStores would now only be used when customBlobStore is set to true

Added:
    jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/ConfigInstaller.java
      - copied, changed from r1597748, jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/ConfigTracker.java
    jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/NodeStoreConfigTest.groovy
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
    jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/ConfigTracker.java
    jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.groovy

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=1597751&r1=1597750&r2=1597751&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 Tue May 27 11:54:38 2014
@@ -155,6 +155,7 @@ public class DocumentNodeStoreService {
     private static final long DEFAULT_MAX_REPLICATION_LAG = TimeUnit.HOURS.toSeconds(6);
     public static final String PROP_REPLICATION_LAG = "maxReplicationLagInSecs";
     private long maxReplicationLagInSecs = DEFAULT_MAX_REPLICATION_LAG;
+    private boolean customBlobStore;
 
     @Activate
     protected void activate(ComponentContext context, Map<String, ?> config) throws Exception {
@@ -164,9 +165,9 @@ public class DocumentNodeStoreService {
         executor.start(whiteboard);
         this.maxReplicationLagInSecs = PropertiesUtil.toLong(config.get(PROP_REPLICATION_LAG),
                 DEFAULT_MAX_REPLICATION_LAG);
+        this.customBlobStore = PropertiesUtil.toBoolean(prop(CUSTOM_BLOB_STORE), false);
 
-        if (blobStore == null &&
-                PropertiesUtil.toBoolean(prop(CUSTOM_BLOB_STORE), false)) {
+        if (blobStore == null && customBlobStore) {
             log.info("BlobStore use enabled. DocumentNodeStoreService would be initialized when "
                     + "BlobStore would be available");
         } else {
@@ -194,7 +195,7 @@ public class DocumentNodeStoreService {
                 offHeapCacheSize(offHeapCache * MB);
 
         //Set blobstore before setting the DB
-        if (blobStore != null) {
+        if (blobStore != null && customBlobStore) {
             mkBuilder.setBlobStore(blobStore);
         }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java?rev=1597751&r1=1597750&r2=1597751&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java Tue May 27 11:54:38 2014
@@ -101,6 +101,7 @@ public class SegmentNodeStoreService ext
     private Registration revisionGCRegistration;
     private Registration blobGCRegistration;
     private WhiteboardExecutor executor;
+    private boolean customBlobStore;
 
     @Override
     protected synchronized SegmentNodeStore getNodeStore() {
@@ -111,9 +112,9 @@ public class SegmentNodeStoreService ext
     @Activate
     private void activate(ComponentContext context) throws IOException {
         this.context = context;
+        this.customBlobStore = Boolean.parseBoolean(lookup(context, CUSTOM_BLOB_STORE));
 
-        if(blobStore == null &&
-                Boolean.parseBoolean(lookup(context, CUSTOM_BLOB_STORE))){
+        if(blobStore == null && customBlobStore){
             log.info("BlobStore use enabled. SegmentNodeStore would be initialized when BlobStore would be available");
         }else{
             registerNodeStore();
@@ -148,10 +149,18 @@ public class SegmentNodeStoreService ext
             size = System.getProperty(SIZE, "256");
         }
 
-        store = new FileStore(
-                blobStore,
-                new File(directory),
-                Integer.parseInt(size), "64".equals(mode));
+        boolean memoryMapping = "64".equals(mode);
+        if (customBlobStore) {
+            store = new FileStore(
+                    blobStore,
+                    new File(directory),
+                    Integer.parseInt(size), memoryMapping);
+        } else {
+            store = new FileStore(
+                    new File(directory),
+                    Integer.parseInt(size), memoryMapping);
+        }
+
 
         delegate = new SegmentNodeStore(store);
         observerTracker = new ObserverTracker(delegate);
@@ -174,13 +183,13 @@ public class SegmentNodeStoreService ext
         revisionGCRegistration = registerMBean(whiteboard, RevisionGCMBean.class, revisionGC,
                 RevisionGCMBean.TYPE, "Segment node store revision garbage collection");
 
-        if (blobStore instanceof GarbageCollectableBlobStore) {
+        if (store.getBlobStore() instanceof GarbageCollectableBlobStore) {
             BlobGarbageCollector gc = new BlobGarbageCollector() {
                 @Override
                 public void collectGarbage() throws Exception {
                     MarkSweepGarbageCollector gc = new MarkSweepGarbageCollector(
                             new SegmentBlobReferenceRetriever(store.getTracker()),
-                            (GarbageCollectableBlobStore) blobStore,
+                            (GarbageCollectableBlobStore) store.getBlobStore(),
                             executor);
                     gc.collectGarbage();
                 }

Copied: jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/ConfigInstaller.java (from r1597748, jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/ConfigTracker.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/ConfigInstaller.java?p2=jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/ConfigInstaller.java&p1=jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/ConfigTracker.java&r1=1597748&r2=1597751&rev=1597751&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/ConfigTracker.java (original)
+++ jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/ConfigInstaller.java Tue May 27 11:54:38 2014
@@ -19,127 +19,38 @@
 
 package org.apache.jackrabbit.oak.run.osgi;
 
-import java.io.File;
 import java.io.IOException;
 import java.util.Dictionary;
 import java.util.Hashtable;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import com.google.common.base.Charsets;
-import com.google.common.base.Splitter;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
-import com.google.common.io.Files;
 import org.apache.felix.utils.collections.DictionaryAsMap;
 import org.apache.felix.utils.properties.InterpolationHelper;
-import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- * Installs config obtained from JSON Config file or passed as part of
- * startup
- */
-class ConfigTracker extends ServiceTracker {
+public class ConfigInstaller {
     private static final String MARKER_NAME = "oak.configinstall.name";
     private final Logger log = LoggerFactory.getLogger(getClass());
-    private ConfigurationAdmin cm;
-    private final Map config;
+    private final ConfigurationAdmin cm;
     private final BundleContext bundleContext;
 
-    public ConfigTracker(Map config, BundleContext bundleContext) {
-        super(bundleContext, ConfigurationAdmin.class.getName(), null);
-        this.config = config;
+    public ConfigInstaller(ConfigurationAdmin cm, BundleContext bundleContext) {
+        this.cm = cm;
         this.bundleContext = bundleContext;
-        open();
     }
 
-    @Override
-    public Object addingService(ServiceReference reference) {
-        cm = (ConfigurationAdmin) super.addingService(reference);
-        try {
-            synchronizeConfigs();
-        } catch (Exception e) {
-            log.error("Error occurred while installing configs", e);
-            throw new RuntimeException(e);
-        }
-        return cm;
-    }
-
-    /**
-     * Synchronizes the configs. All config added by this class is also kept in sync with re runs
-     * i.e. if a config was added in first run and say later removed then that would also be removed
-     * from the ConfigurationAdmin
-     */
-    private void synchronizeConfigs() throws Exception {
-        Set<String> existingPids = determineExistingConfigs();
-        Set<String> processedPids = Sets.newHashSet();
-
-        Map<String, Map<String, Object>> configs = Maps.newHashMap();
-
-        Map<String, Map<String, Object>> configFromFile =
-                parseJSONConfig((String) config.get(OakOSGiRepositoryFactory.REPOSITORY_CONFIG_FILE));
-        configs.putAll(configFromFile);
-
-        @SuppressWarnings("unchecked")
-        Map<String, Map<String, Object>> runtimeConfig =
-                (Map<String, Map<String, Object>>) config.get(OakOSGiRepositoryFactory.REPOSITORY_CONFIG);
-        if (runtimeConfig != null) {
-            configs.putAll(runtimeConfig);
-        }
-
-        installConfigs(configs, processedPids);
-        Set<String> pidsToBeRemoved = Sets.difference(existingPids, processedPids);
-        removeConfigs(pidsToBeRemoved);
-    }
-
-    @SuppressWarnings("unchecked")
-    private Map<String, Map<String, Object>> parseJSONConfig(String jsonFilePath) throws IOException {
-        Map<String, Map<String, Object>> configs = Maps.newHashMap();
-        if (jsonFilePath == null) {
-            return configs;
-        }
-
-        List<String> files = Splitter.on(',').trimResults().omitEmptyStrings().splitToList(jsonFilePath);
-        for (String filePath : files) {
-            File jsonFile = new File(filePath);
-            if (!jsonFile.exists()) {
-                log.warn("No file found at path {}. Ignoring the file entry", jsonFile.getAbsolutePath());
-                continue;
-            }
-
-            String content = Files.toString(jsonFile, Charsets.UTF_8);
-            JSONObject json = (JSONObject) JSONValue.parse(content);
-            configs.putAll(json);
-        }
-
-        return configs;
-    }
-
-    private void removeConfigs(Set<String> pidsToBeRemoved) throws Exception {
-        for (String pidString : pidsToBeRemoved) {
-            String[] pid = parsePid(pidString);
-            Configuration config = getConfiguration(pidString, pid[0], pid[1]);
-            config.delete();
-        }
-
-        if (!pidsToBeRemoved.isEmpty()) {
-            log.info("Configuration belonging to following pids have been removed ", pidsToBeRemoved);
-        }
-    }
-
-    private void installConfigs(Map<String, Map<String, Object>> osgiConfig, Set<String> processedPids)
+    public Set<String> installConfigs(Map<String, Map<String, Object>> osgiConfig)
             throws Exception {
+        Set<String> processedPids = Sets.newHashSet();
         for (Map.Entry<String, Map<String, Object>> pidEntry : osgiConfig.entrySet()) {
             final String pidString = pidEntry.getKey();
 
@@ -173,21 +84,18 @@ class ConfigTracker extends ServiceTrack
                 processedPids.add(pidString);
             }
         }
+        return processedPids;
     }
 
-    private void performSubstitution(Hashtable<String, Object> current) {
-        Map<String, String> simpleConfig = Maps.newHashMap();
-
-        for (Map.Entry<String, Object> e : current.entrySet()) {
-            if (e.getValue() instanceof String) {
-                simpleConfig.put(e.getKey(), (String) e.getValue());
-            }
+    public void removeConfigs(Set<String> pidsToBeRemoved) throws Exception {
+        for (String pidString : pidsToBeRemoved) {
+            String[] pid = parsePid(pidString);
+            Configuration config = getConfiguration(pidString, pid[0], pid[1]);
+            config.delete();
         }
 
-        InterpolationHelper.performSubstitution(simpleConfig, bundleContext);
-
-        for (Map.Entry<String, String> e : simpleConfig.entrySet()) {
-            current.put(e.getKey(), e.getValue());
+        if (!pidsToBeRemoved.isEmpty()) {
+            log.info("Configuration belonging to following pids have been removed ", pidsToBeRemoved);
         }
     }
 
@@ -196,7 +104,7 @@ class ConfigTracker extends ServiceTrack
      *
      * @return set of pid strings
      */
-    private Set<String> determineExistingConfigs() throws IOException, InvalidSyntaxException {
+    public Set<String> determineExistingConfigs() throws IOException, InvalidSyntaxException {
         Set<String> pids = Sets.newHashSet();
         String filter = "(" + MARKER_NAME + "=" + "*" + ")";
         Configuration[] configurations = cm.listConfigurations(filter);
@@ -208,6 +116,22 @@ class ConfigTracker extends ServiceTrack
         return pids;
     }
 
+    private void performSubstitution(Hashtable<String, Object> current) {
+        Map<String, String> simpleConfig = Maps.newHashMap();
+
+        for (Map.Entry<String, Object> e : current.entrySet()) {
+            if (e.getValue() instanceof String) {
+                simpleConfig.put(e.getKey(), (String) e.getValue());
+            }
+        }
+
+        InterpolationHelper.performSubstitution(simpleConfig, bundleContext);
+
+        for (Map.Entry<String, String> e : simpleConfig.entrySet()) {
+            current.put(e.getKey(), e.getValue());
+        }
+    }
+
     private Configuration getConfiguration(String pidString, String pid, String factoryPid)
             throws Exception {
         Configuration oldConfiguration = findExistingConfiguration(pidString);

Modified: jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/ConfigTracker.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/ConfigTracker.java?rev=1597751&r1=1597750&r2=1597751&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/ConfigTracker.java (original)
+++ jackrabbit/oak/trunk/oak-pojosr/src/main/java/org/apache/jackrabbit/oak/run/osgi/ConfigTracker.java Tue May 27 11:54:38 2014
@@ -21,8 +21,6 @@ package org.apache.jackrabbit.oak.run.os
 
 import java.io.File;
 import java.io.IOException;
-import java.util.Dictionary;
-import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -32,15 +30,10 @@ import com.google.common.base.Splitter;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.google.common.io.Files;
-import org.apache.felix.utils.collections.DictionaryAsMap;
-import org.apache.felix.utils.properties.InterpolationHelper;
 import org.json.simple.JSONObject;
 import org.json.simple.JSONValue;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
@@ -51,9 +44,8 @@ import org.slf4j.LoggerFactory;
  * startup
  */
 class ConfigTracker extends ServiceTracker {
-    private static final String MARKER_NAME = "oak.configinstall.name";
+
     private final Logger log = LoggerFactory.getLogger(getClass());
-    private ConfigurationAdmin cm;
     private final Map config;
     private final BundleContext bundleContext;
 
@@ -66,9 +58,9 @@ class ConfigTracker extends ServiceTrack
 
     @Override
     public Object addingService(ServiceReference reference) {
-        cm = (ConfigurationAdmin) super.addingService(reference);
+        ConfigurationAdmin cm = (ConfigurationAdmin) super.addingService(reference);
         try {
-            synchronizeConfigs();
+            synchronizeConfigs(new ConfigInstaller(cm, bundleContext));
         } catch (Exception e) {
             log.error("Error occurred while installing configs", e);
             throw new RuntimeException(e);
@@ -81,9 +73,8 @@ class ConfigTracker extends ServiceTrack
      * i.e. if a config was added in first run and say later removed then that would also be removed
      * from the ConfigurationAdmin
      */
-    private void synchronizeConfigs() throws Exception {
-        Set<String> existingPids = determineExistingConfigs();
-        Set<String> processedPids = Sets.newHashSet();
+    private void synchronizeConfigs(ConfigInstaller configInstaller) throws Exception {
+        Set<String> existingPids = configInstaller.determineExistingConfigs();
 
         Map<String, Map<String, Object>> configs = Maps.newHashMap();
 
@@ -98,9 +89,9 @@ class ConfigTracker extends ServiceTrack
             configs.putAll(runtimeConfig);
         }
 
-        installConfigs(configs, processedPids);
+        Set<String> processedPids = configInstaller.installConfigs(configs);
         Set<String> pidsToBeRemoved = Sets.difference(existingPids, processedPids);
-        removeConfigs(pidsToBeRemoved);
+        configInstaller.removeConfigs(pidsToBeRemoved);
     }
 
     @SuppressWarnings("unchecked")
@@ -125,136 +116,4 @@ class ConfigTracker extends ServiceTrack
 
         return configs;
     }
-
-    private void removeConfigs(Set<String> pidsToBeRemoved) throws Exception {
-        for (String pidString : pidsToBeRemoved) {
-            String[] pid = parsePid(pidString);
-            Configuration config = getConfiguration(pidString, pid[0], pid[1]);
-            config.delete();
-        }
-
-        if (!pidsToBeRemoved.isEmpty()) {
-            log.info("Configuration belonging to following pids have been removed ", pidsToBeRemoved);
-        }
-    }
-
-    private void installConfigs(Map<String, Map<String, Object>> osgiConfig, Set<String> processedPids)
-            throws Exception {
-        for (Map.Entry<String, Map<String, Object>> pidEntry : osgiConfig.entrySet()) {
-            final String pidString = pidEntry.getKey();
-
-            final Hashtable<String, Object> current = new Hashtable<String, Object>();
-            current.putAll(pidEntry.getValue());
-            performSubstitution(current);
-
-            String[] pid = parsePid(pidString);
-            Configuration config = getConfiguration(pidString, pid[0], pid[1]);
-
-            @SuppressWarnings("unchecked") Dictionary<String, Object> props = config.getProperties();
-            Hashtable<String, Object> old = props != null ?
-                    new Hashtable<String, Object>(new DictionaryAsMap<String, Object>(props)) : null;
-            if (old != null) {
-                old.remove(MARKER_NAME);
-                old.remove(Constants.SERVICE_PID);
-                old.remove(ConfigurationAdmin.SERVICE_FACTORYPID);
-            }
-
-            if (!current.equals(old)) {
-                current.put(MARKER_NAME, pidString);
-                if (config.getBundleLocation() != null) {
-                    config.setBundleLocation(null);
-                }
-                if (old == null) {
-                    log.info("Creating configuration from {}", pidString);
-                } else {
-                    log.info("Updating configuration from {}", pidString);
-                }
-                config.update(current);
-                processedPids.add(pidString);
-            }
-        }
-    }
-
-    private void performSubstitution(Hashtable<String, Object> current) {
-        Map<String, String> simpleConfig = Maps.newHashMap();
-
-        for (Map.Entry<String, Object> e : current.entrySet()) {
-            if (e.getValue() instanceof String) {
-                simpleConfig.put(e.getKey(), (String) e.getValue());
-            }
-        }
-
-        InterpolationHelper.performSubstitution(simpleConfig, bundleContext);
-
-        for (Map.Entry<String, String> e : simpleConfig.entrySet()) {
-            current.put(e.getKey(), e.getValue());
-        }
-    }
-
-    /**
-     * Determines the existing configs which are installed by ConfigInstaller
-     *
-     * @return set of pid strings
-     */
-    private Set<String> determineExistingConfigs() throws IOException, InvalidSyntaxException {
-        Set<String> pids = Sets.newHashSet();
-        String filter = "(" + MARKER_NAME + "=" + "*" + ")";
-        Configuration[] configurations = cm.listConfigurations(filter);
-        if (configurations != null) {
-            for (Configuration cfg : configurations) {
-                pids.add((String) cfg.getProperties().get(MARKER_NAME));
-            }
-        }
-        return pids;
-    }
-
-    private Configuration getConfiguration(String pidString, String pid, String factoryPid)
-            throws Exception {
-        Configuration oldConfiguration = findExistingConfiguration(pidString);
-        if (oldConfiguration != null) {
-            return oldConfiguration;
-        } else {
-            Configuration newConfiguration;
-            if (factoryPid != null) {
-                newConfiguration = cm.createFactoryConfiguration(pid, null);
-            } else {
-                newConfiguration = cm.getConfiguration(pid, null);
-            }
-            return newConfiguration;
-        }
-    }
-
-    private Configuration findExistingConfiguration(String pidString) throws Exception {
-        String filter = "(" + MARKER_NAME + "=" + escapeFilterValue(pidString) + ")";
-        Configuration[] configurations = cm.listConfigurations(filter);
-        if (configurations != null && configurations.length > 0) {
-            return configurations[0];
-        } else {
-            return null;
-        }
-    }
-
-    private static String escapeFilterValue(String s) {
-        return s.replaceAll("[(]", "\\\\(").
-                replaceAll("[)]", "\\\\)").
-                replaceAll("[=]", "\\\\=").
-                replaceAll("[\\*]", "\\\\*");
-    }
-
-    private static String[] parsePid(String pid) {
-        int n = pid.indexOf('-');
-        if (n > 0) {
-            String factoryPid = pid.substring(n + 1);
-            pid = pid.substring(0, n);
-            return new String[]
-                    {
-                            pid, factoryPid
-                    };
-        } else {
-            return new String[]
-                    {
-                            pid, null
-                    };
-        }
-    }
 }

Modified: jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.groovy
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.groovy?rev=1597751&r1=1597750&r2=1597751&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.groovy (original)
+++ jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/AbstractRepositoryFactoryTest.groovy Tue May 27 11:54:38 2014
@@ -26,6 +26,7 @@ import org.apache.jackrabbit.api.Jackrab
 import org.junit.After
 import org.junit.Before
 import org.osgi.framework.ServiceReference
+import org.osgi.service.cm.ConfigurationAdmin
 
 import javax.jcr.Repository
 import javax.jcr.RepositoryException
@@ -82,6 +83,12 @@ abstract class AbstractRepositoryFactory
         return file
     }
 
+    protected void createConfig(Map config){
+        ConfigurationAdmin cm = getService(ConfigurationAdmin.class)
+        ConfigInstaller ci = new ConfigInstaller(cm, getRegistry().bundleContext)
+        ci.installConfigs(config)
+    }
+
     protected Session createAdminSession() throws RepositoryException {
         return getRepository().login(new SimpleCredentials("admin", "admin".toCharArray()));
     }

Added: jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/NodeStoreConfigTest.groovy
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/NodeStoreConfigTest.groovy?rev=1597751&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/NodeStoreConfigTest.groovy (added)
+++ jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/NodeStoreConfigTest.groovy Tue May 27 11:54:38 2014
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+package org.apache.jackrabbit.oak.run.osgi
+
+import de.kalpatec.pojosr.framework.launch.PojoServiceRegistry
+import org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStoreService
+import org.apache.jackrabbit.oak.plugins.segment.SegmentStore
+import org.apache.jackrabbit.oak.spi.blob.BlobStore
+import org.apache.jackrabbit.oak.spi.blob.MemoryBlobStore
+import org.apache.jackrabbit.oak.spi.state.NodeStore
+import org.junit.Test
+import org.osgi.util.tracker.ServiceTracker
+
+import java.util.concurrent.TimeUnit
+
+class NodeStoreConfigTest extends  AbstractRepositoryFactoryTest{
+    private PojoServiceRegistry registry
+    @Test
+    void testNodeStoreWithBlobStore_OAK_1676(){
+        registry = repositoryFactory.initializeServiceRegistry(config)
+        registry.registerService(BlobStore.class.name, new MemoryBlobStore(), null)
+
+        createConfig([
+                'org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStoreService' : [:]
+        ])
+
+        ServiceTracker st = new ServiceTracker(registry.bundleContext, NodeStore.class.name, null)
+        st.open()
+
+        SegmentNodeStoreService ns = st.waitForService(TimeUnit.SECONDS.toMillis(10)) as SegmentNodeStoreService
+        //NodeStore is of type SegmentNodeStoreService
+        SegmentStore segStore = ns.getSegmentStore()
+        assert segStore.blobStore == null , "BlobStore should not be picked up unless 'customBlobStore " +
+                "is set to true"
+    }
+
+    @Override
+    protected PojoServiceRegistry getRegistry() {
+        return registry
+    }
+}