yx91490 commented on a change in pull request #3340: [ZEPPELIN-4068] Implement 
MongoNotebookRepo
URL: https://github.com/apache/zeppelin/pull/3340#discussion_r314344646
 
 

 ##########
 File path: 
zeppelin-plugins/notebookrepo/mongo/src/main/java/org/apache/zeppelin/notebook/repo/MongoNotebookRepo.java
 ##########
 @@ -0,0 +1,390 @@
+package org.apache.zeppelin.notebook.repo;
+
+import static com.mongodb.client.model.Filters.and;
+import static com.mongodb.client.model.Filters.eq;
+import com.google.common.collect.Lists;
+import org.apache.commons.lang.ArrayUtils;
+import org.bson.Document;
+import org.bson.conversions.Bson;
+import org.bson.types.ObjectId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import com.mongodb.MongoClient;
+import com.mongodb.MongoClientURI;
+import com.mongodb.client.AggregateIterable;
+import com.mongodb.client.FindIterable;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.UpdateOptions;
+import com.mongodb.client.model.Updates;
+import org.apache.zeppelin.conf.ZeppelinConfiguration;
+import org.apache.zeppelin.notebook.Note;
+import org.apache.zeppelin.notebook.NoteInfo;
+import org.apache.zeppelin.user.AuthenticationInfo;
+
+/**
+ * Backend for storing Notebook on MongoDB.
+ */
+public class MongoNotebookRepo implements NotebookRepo {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(MongoNotebookRepo.class);
+
+  private ZeppelinConfiguration conf;
+
+  private MongoClient client;
+
+  private MongoDatabase db;
+
+  private MongoCollection<Document> notes;
+
+  private MongoCollection<Document> folders;
+
+  private String folderName;
+
+  public MongoNotebookRepo() {
+  }
+
+  @Override
+  public void init(ZeppelinConfiguration zConf) throws IOException {
+    this.conf = zConf;
+    client = new MongoClient(new MongoClientURI(conf.getMongoUri()));
+    db = client.getDatabase(conf.getMongoDatabase());
+    notes = db.getCollection(conf.getMongoCollection());
+    folderName = conf.getMongoFolder();
+    folders = db.getCollection(folderName);
+
+    if (conf.getMongoAutoimport()) {
+      // import local notes into MongoDB
+      insertFileSystemNotes();
 
 Review comment:
   > mongodb
   
   I wait for your reply :)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to