zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject incubator-zeppelin git commit: synchronization saving notebook.
Date Thu, 03 Dec 2015 23:55:54 GMT
Repository: incubator-zeppelin
Updated Branches:
  refs/heads/master 9a8779bdd -> 4538524e9


synchronization saving notebook.

The issue related to https://issues.apache.org/jira/browse/ZEPPELIN-473.
Saving notebook operation has called save method in the VFSNotebookRepo class in the end,
It can be synchronized.

Author: astroshim <hsshim@nflabs.com>

Closes #489 from astroshim/ZEPPELIN-473 and squashes the following commits:

6dc3bc6 [astroshim] remove TODO.
2032d1a [astroshim] for rebuilding.
98c7e7e [astroshim] add apache license comment.
84fb90a [astroshim] to pass CI.
bc97bf3 [astroshim] add testcase.
8c0fac8 [astroshim] synchronization saving notebook.


Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/4538524e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/4538524e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/4538524e

Branch: refs/heads/master
Commit: 4538524e9d850c1ad36e7488ee339732192ad9a9
Parents: 9a8779b
Author: astroshim <hsshim@nflabs.com>
Authored: Thu Dec 3 14:03:17 2015 +0900
Committer: Alexander Bezzubov <bzz@apache.org>
Committed: Fri Dec 4 08:55:38 2015 +0900

----------------------------------------------------------------------
 .../zeppelin/notebook/repo/VFSNotebookRepo.java |   2 +-
 .../notebook/repo/VFSNotebookRepoTest.java      | 121 +++++++++++++++++++
 2 files changed, 122 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/4538524e/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java
index 58f36f2..8363bc7 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepo.java
@@ -197,7 +197,7 @@ public class VFSNotebookRepo implements NotebookRepo {
   }
 
   @Override
-  public void save(Note note) throws IOException {
+  public synchronized void save(Note note) throws IOException {
     GsonBuilder gsonBuilder = new GsonBuilder();
     gsonBuilder.setPrettyPrinting();
     Gson gson = gsonBuilder.create();

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/4538524e/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepoTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepoTest.java
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepoTest.java
new file mode 100644
index 0000000..e747078
--- /dev/null
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/VFSNotebookRepoTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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.zeppelin.notebook.repo;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.zeppelin.conf.ZeppelinConfiguration;
+import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
+import org.apache.zeppelin.interpreter.InterpreterFactory;
+import org.apache.zeppelin.interpreter.InterpreterOption;
+import org.apache.zeppelin.notebook.JobListenerFactory;
+import org.apache.zeppelin.notebook.Note;
+import org.apache.zeppelin.notebook.Notebook;
+import org.apache.zeppelin.notebook.NotebookTest;
+import org.apache.zeppelin.notebook.Paragraph;
+import org.apache.zeppelin.scheduler.JobListener;
+import org.apache.zeppelin.scheduler.SchedulerFactory;
+import org.apache.zeppelin.scheduler.Job.Status;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class VFSNotebookRepoTest implements JobListenerFactory{
+  private static final Logger logger = LoggerFactory.getLogger(NotebookTest.class);
+
+  private ZeppelinConfiguration conf;
+  private SchedulerFactory schedulerFactory;
+  private Notebook notebook;
+  private NotebookRepo notebookRepo;
+  private InterpreterFactory factory;
+
+  @Before
+  public void setUp() throws Exception {    
+    conf = ZeppelinConfiguration.create();
+
+    this.schedulerFactory = new SchedulerFactory();
+    factory = new InterpreterFactory(conf, new InterpreterOption(false), null);
+
+    notebookRepo = new VFSNotebookRepo(conf);
+    notebook = new Notebook(conf, notebookRepo, schedulerFactory, factory, this);
+  }
+
+  @After
+  public void tearDown() throws Exception {
+  }
+  
+  @Test
+  public void testSaveNotebook() throws IOException, InterruptedException {
+    Note note = notebook.createNote();
+    note.getNoteReplLoader().setInterpreters(factory.getDefaultInterpreterSettingList());
+
+    Paragraph p1 = note.addParagraph();
+    Map config = p1.getConfig();
+    config.put("enabled", true);
+    p1.setConfig(config);
+    p1.setText("%md hello world");
+    
+    note.run(p1.getId());
+    int timeout = 1;
+    while (!p1.isTerminated()) {
+      Thread.sleep(1000);
+      if (timeout++ > 10) {
+        break;
+      }
+    }
+    int i = 0;
+    int TEST_COUNT = 10;
+    while (i++ < TEST_COUNT) {
+      p1.setText("%md hello zeppelin");
+      new Thread(new NotebookWriter(note)).start();
+      p1.setText("%md hello world");
+      new Thread(new NotebookWriter(note)).start();
+    }
+  
+    note.setName("SaveTest");
+    notebookRepo.save(note);
+    assertEquals(note.getName(), "SaveTest");
+  }
+  
+  class NotebookWriter implements Runnable {
+    Note note;
+    public NotebookWriter(Note note) {
+      this.note = note;
+    }
+    
+    @Override
+    public void run() {
+      try {
+        notebookRepo.save(note);
+      } catch (IOException e) {
+        e.printStackTrace();
+      }
+    }
+  }
+
+  @Override
+  public JobListener getParagraphJobListener(Note note) {
+    return null;
+  }
+}


Mime
View raw message