jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1547341 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk: MongoMK.java MongoNodeStore.java blob/MongoBlobStore.java util/MongoConnection.java
Date Tue, 03 Dec 2013 10:55:11 GMT
Author: thomasm
Date: Tue Dec  3 10:55:10 2013
New Revision: 1547341

URL: http://svn.apache.org/r1547341
Log:
OAK-98 Code conventions, use new (non-deprecated) API

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/blob/MongoBlobStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/util/MongoConnection.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java?rev=1547341&r1=1547340&r2=1547341&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoMK.java
Tue Dec  3 10:55:10 2013
@@ -63,7 +63,8 @@ public class MongoMK implements MicroKer
     /**
      * Enable the LIRS cache.
      */
-    static final boolean LIRS_CACHE = Boolean.parseBoolean(System.getProperty("oak.mongoMK.lirsCache",
"false"));
+    static final boolean LIRS_CACHE = Boolean.parseBoolean(
+            System.getProperty("oak.mongoMK.lirsCache", "false"));
 
     /**
      * Enable fast diff operations.

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java?rev=1547341&r1=1547340&r2=1547341&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoNodeStore.java
Tue Dec  3 10:55:10 2013
@@ -79,6 +79,11 @@ import org.slf4j.LoggerFactory;
  */
 public final class MongoNodeStore
         implements NodeStore, RevisionContext, Observable {
+    
+    /**
+     * The maximum number of document to update at once in a multi update.
+     */
+    static final int BACKGROUND_MULTI_UPDATE_LIMIT = 10000;
 
     private static final Logger LOG = LoggerFactory.getLogger(MongoNodeStore.class);
 
@@ -106,11 +111,6 @@ public final class MongoNodeStore
     private static final int REMEMBER_REVISION_ORDER_MILLIS = 60 * 60 * 1000;
 
     /**
-     * The maximum number of document to update at once in a multi update.
-     */
-    static final int BACKGROUND_MULTI_UPDATE_LIMIT = 10000;
-
-    /**
      * The MongoDB store (might be used by multiple MongoMKs).
      */
     protected final DocumentStore store;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/blob/MongoBlobStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/blob/MongoBlobStore.java?rev=1547341&r1=1547340&r2=1547341&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/blob/MongoBlobStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/blob/MongoBlobStore.java
Tue Dec  3 10:55:10 2013
@@ -27,6 +27,7 @@ import com.mongodb.BasicDBObject;
 import com.mongodb.DB;
 import com.mongodb.DBCollection;
 import com.mongodb.DBObject;
+import com.mongodb.MongoException;
 import com.mongodb.QueryBuilder;
 import com.mongodb.WriteResult;
 
@@ -68,7 +69,11 @@ public class MongoBlobStore extends Abst
         mongoBlob.setLastMod(System.currentTimeMillis());
         // TODO check the return value
         // TODO verify insert is fast if the entry already exists
-        getBlobCollection().insert(mongoBlob);
+        try {
+            getBlobCollection().insert(mongoBlob);
+        } catch (MongoException.DuplicateKey e) {
+            // the same block was already stored before: ignore
+        } 
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/util/MongoConnection.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/util/MongoConnection.java?rev=1547341&r1=1547340&r2=1547341&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/util/MongoConnection.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/util/MongoConnection.java
Tue Dec  3 10:55:10 2013
@@ -17,8 +17,8 @@
 package org.apache.jackrabbit.oak.plugins.mongomk.util;
 
 import com.mongodb.DB;
-import com.mongodb.Mongo;
-import com.mongodb.MongoOptions;
+import com.mongodb.MongoClient;
+import com.mongodb.MongoClientOptions;
 import com.mongodb.ServerAddress;
 
 /**
@@ -27,7 +27,7 @@ import com.mongodb.ServerAddress;
 public class MongoConnection {
 
     private final DB db;
-    private final Mongo mongo;
+    private final MongoClient mongo;
 
     /**
      * Constructs a new {@code MongoConnection}.
@@ -38,9 +38,10 @@ public class MongoConnection {
      * @throws Exception If an error occurred while trying to connect.
      */
     public MongoConnection(String host, int port, String database) throws Exception {
-        MongoOptions options = new MongoOptions();
-        options.setThreadsAllowedToBlockForConnectionMultiplier(100);
-        mongo = new Mongo(new ServerAddress(host, port), options);
+        MongoClientOptions options = new MongoClientOptions.Builder().
+                threadsAllowedToBlockForConnectionMultiplier(100).build();
+        ServerAddress serverAddress = new ServerAddress(host, port);
+        mongo = new MongoClient(serverAddress, options);
         db = mongo.getDB(database);
     }
 



Mime
View raw message