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 ju...@apache.org on 2013/05/01 15:35:06 UTC
svn commit: r1477996 -
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
Author: jukka
Date: Wed May 1 13:35:05 2013
New Revision: 1477996
URL: http://svn.apache.org/r1477996
Log:
OAK-788: File backend for the SegmentMK
Add a basic OSGi configuration trigger.
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentNodeStoreService.java
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=1477996&r1=1477995&r2=1477996&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 Wed May 1 13:35:05 2013
@@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.oak.plugins.segment;
+import java.io.File;
import java.net.UnknownHostException;
import java.util.Collection;
import java.util.Dictionary;
@@ -40,6 +41,9 @@ public class SegmentNodeStoreService ext
@Property(description="The unique name of this instance")
public static final String NAME = "name";
+ @Property(description="TarMK directory (if unset, use MongoDB)")
+ public static final String DIRECTORY = "directory";
+
@Property(description="MongoDB host", value="localhost")
public static final String HOST = "host";
@@ -115,18 +119,28 @@ public class SegmentNodeStoreService ext
Dictionary<?, ?> properties = context.getProperties();
name = "" + properties.get(NAME);
- String host = String.valueOf(properties.get(HOST));
- int port = Integer.parseInt(String.valueOf(properties.get(PORT)));
- String db = String.valueOf(properties.get(DB));
- int cache = Integer.parseInt(String.valueOf(properties.get(CACHE)));
-
- mongo = new Mongo(host, port);
- store[0] = new MongoStore(mongo.getDB(db), cache * MB);
+ if (properties.get(DIRECTORY) != null) {
+ File directory = new File(properties.get(DIRECTORY).toString());
+ directory.mkdirs();
+
+ mongo = null;
+ store[0] = new FileStore(new File(directory, "data.tar").getPath());
+ } else {
+ String host = String.valueOf(properties.get(HOST));
+ int port = Integer.parseInt(String.valueOf(properties.get(PORT)));
+ String db = String.valueOf(properties.get(DB));
+ int cache = Integer.parseInt(String.valueOf(properties.get(CACHE)));
+
+ mongo = new Mongo(host, port);
+ store[0] = new MongoStore(mongo.getDB(db), cache * MB);
+ }
}
@Deactivate
public void deactivate() {
- mongo.close();
+ if (mongo != null) {
+ mongo.close();
+ }
}
}