Return-Path: X-Original-To: apmail-zeppelin-commits-archive@minotaur.apache.org Delivered-To: apmail-zeppelin-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 575BF18712 for ; Thu, 3 Dec 2015 23:56:03 +0000 (UTC) Received: (qmail 98343 invoked by uid 500); 3 Dec 2015 23:56:03 -0000 Delivered-To: apmail-zeppelin-commits-archive@zeppelin.apache.org Received: (qmail 98300 invoked by uid 500); 3 Dec 2015 23:56:03 -0000 Mailing-List: contact commits-help@zeppelin.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zeppelin.incubator.apache.org Delivered-To: mailing list commits@zeppelin.incubator.apache.org Received: (qmail 98289 invoked by uid 99); 3 Dec 2015 23:56:03 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Dec 2015 23:56:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id C8AFD180B2D for ; Thu, 3 Dec 2015 23:56:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.247 X-Spam-Level: * X-Spam-Status: No, score=1.247 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.554, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id lb_0D9yEqZNX for ; Thu, 3 Dec 2015 23:55:55 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id 52BC147BCB for ; Thu, 3 Dec 2015 23:55:55 +0000 (UTC) Received: (qmail 98222 invoked by uid 99); 3 Dec 2015 23:55:54 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Dec 2015 23:55:54 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 82E04E6836; Thu, 3 Dec 2015 23:55:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bzz@apache.org To: commits@zeppelin.incubator.apache.org Message-Id: <8a29973a714e45e58ebbf0cc1381e3e1@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-zeppelin git commit: synchronization saving notebook. Date: Thu, 3 Dec 2015 23:55:54 +0000 (UTC) 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 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 Authored: Thu Dec 3 14:03:17 2015 +0900 Committer: Alexander Bezzubov 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; + } +}