zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject incubator-zeppelin git commit: [Zeppelin 537] Improve behavior of reloading notebooks from storage
Date Sun, 03 Jan 2016 15:52:45 GMT
Repository: incubator-zeppelin
Updated Branches:
  refs/heads/master a96a9b7ad -> f0383c699


[Zeppelin 537] Improve behavior of reloading notebooks from storage

### What is this PR for?
Improve behavior of reloading notebooks from storage

### What type of PR is it?
Improvement

### Is there a relevant Jira issue?
[ZEPPELIN-537](https://issues.apache.org/jira/browse/ZEPPELIN-537?jql=project%20%3D%20ZEPPELIN)

### How should this be tested?
1. Add new `notebookId/note.json` under `ZEPPELIN_HOME/notebook`
2. Click reload button next to 'Notebook'
3. Check if the new added note is loaded

### Screenshots (if appropriate)
![reload fig](https://cloud.githubusercontent.com/assets/8503346/12011889/283c8e9c-ac96-11e5-81f6-4cdb305020d3.gif)

### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: Mina Lee <minalee@nflabs.com>

Closes #573 from minahlee/ZEPPELIN-537 and squashes the following commits:

64e1a28 [Mina Lee] Rework sync with secondary storage when reload notebooks  - Address @khalidhuseynov
comment
5423e3c [Mina Lee] Revert "Sync with secondary storage when reload notebooks"
1f83f15 [Mina Lee] Modify test
b03cde2 [Mina Lee] Sync with secondary storage when reload notebooks
b26dabf [Mina Lee] Remove ZEPPELIN_NOTEBOOK_RELOAD_FROM_STORAGE env variable
3fc9ad0 [Mina Lee] Revert "ZEPPELIN-367 Sync with secondary storage when listing notebooks"
6a80304 [Mina Lee] Reload notebooks from repository with reload button click event


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

Branch: refs/heads/master
Commit: f0383c69958efc23f2cf1d8b8a964722024ad45e
Parents: a96a9b7
Author: Mina Lee <minalee@nflabs.com>
Authored: Mon Dec 28 21:00:49 2015 -0800
Committer: Lee moon soo <moon@apache.org>
Committed: Sun Jan 3 07:54:38 2016 -0800

----------------------------------------------------------------------
 docs/install/install.md                         |  6 ---
 .../apache/zeppelin/rest/NotebookRestApi.java   |  2 +-
 .../org/apache/zeppelin/socket/Message.java     |  1 +
 .../apache/zeppelin/socket/NotebookServer.java  | 19 +++++++-
 zeppelin-web/src/app/home/home.controller.js    | 11 +++++
 zeppelin-web/src/app/home/home.html             |  7 ++-
 .../websocketEvents/websocketMsg.service.js     |  5 ++
 .../zeppelin/conf/ZeppelinConfiguration.java    |  4 --
 .../org/apache/zeppelin/notebook/Notebook.java  | 18 ++++---
 .../notebook/repo/NotebookRepoSync.java         |  8 +--
 .../apache/zeppelin/notebook/NotebookTest.java  | 24 ++++-----
 .../notebook/repo/NotebookRepoSyncTest.java     | 51 ++++++++------------
 12 files changed, 83 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/f0383c69/docs/install/install.md
----------------------------------------------------------------------
diff --git a/docs/install/install.md b/docs/install/install.md
index 73dd7e0..493a96d 100644
--- a/docs/install/install.md
+++ b/docs/install/install.md
@@ -177,12 +177,6 @@ Configuration can be done by both environment variable(conf/zeppelin-env.sh)
and
     <td>Comma separated list of notebook storage</td>
   </tr>
   <tr>
-    <td>ZEPPELIN_NOTEBOOK_RELOAD_FROM_STORAGE</td>
-    <td>zeppelin.notebook.reloadAllNotesFromStorage</td>
-    <td>false</td>
-    <td>Notebook list and contents will be always loaded from repository if set true.
If set false, modified notebooks or new notebooks added on file system level won't be reflected
on Zeppelin till user restarts Zeppelin.</td>
-  </tr>
-  <tr>
     <td>ZEPPELIN_INTERPRETERS</td>
     <td>zeppelin.interpreters</td>
   <description></description>

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/f0383c69/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
----------------------------------------------------------------------
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
index aefa2c1..f696b46 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
@@ -131,7 +131,7 @@ public class NotebookRestApi {
   @GET
   @Path("/")
   public Response getNotebookList() throws IOException {
-    List<Map<String, String>> notesInfo = notebookServer.generateNotebooksInfo();
+    List<Map<String, String>> notesInfo = notebookServer.generateNotebooksInfo(false);
     return new JsonResponse<>(Status.OK, "", notesInfo ).build();
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/f0383c69/zeppelin-server/src/main/java/org/apache/zeppelin/socket/Message.java
----------------------------------------------------------------------
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/Message.java b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/Message.java
index dc657bd..7640b10 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/Message.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/Message.java
@@ -86,6 +86,7 @@ public class Message {
                      // @param completions list of string
 
     LIST_NOTES, // [c-s] ask list of note
+    RELOAD_NOTES_FROM_REPO, // [c-s] reload notes from repo
 
     NOTES_INFO, // [s-c] list of note infos
                 // @param notes serialized List<NoteInfo> object

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/f0383c69/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
----------------------------------------------------------------------
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
index 554f68c..a2fa16e 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java
@@ -101,6 +101,9 @@ public class NotebookServer extends WebSocketServlet implements
           case LIST_NOTES:
             broadcastNoteList();
             break;
+          case RELOAD_NOTES_FROM_REPO:
+            broadcastReloadedNoteList();
+            break;
           case GET_HOME_NOTE:
             sendHomeNote(conn, notebook);
             break;
@@ -291,7 +294,7 @@ public class NotebookServer extends WebSocketServlet implements
     }
   }
 
-  public List<Map<String, String>> generateNotebooksInfo (){
+  public List<Map<String, String>> generateNotebooksInfo(boolean needsReload)
{
     Notebook notebook = notebook();
 
     ZeppelinConfiguration conf = notebook.getConf();
@@ -299,6 +302,14 @@ public class NotebookServer extends WebSocketServlet implements
     boolean hideHomeScreenNotebookFromList = conf
             .getBoolean(ConfVars.ZEPPELIN_NOTEBOOK_HOMESCREEN_HIDE);
 
+    if (needsReload) {
+      try {
+        notebook.reloadAllNotes();
+      } catch (IOException e) {
+        LOG.error("Fail to reload notes from repository");
+      }
+    }
+
     List<Note> notes = notebook.getAllNotes();
     List<Map<String, String>> notesInfo = new LinkedList<>();
     for (Note note : notes) {
@@ -321,8 +332,12 @@ public class NotebookServer extends WebSocketServlet implements
   }
 
   public void broadcastNoteList() {
+    List<Map<String, String>> notesInfo = generateNotebooksInfo(false);
+    broadcastAll(new Message(OP.NOTES_INFO).put("notes", notesInfo));
+  }
 
-    List<Map<String, String>> notesInfo = generateNotebooksInfo();
+  public void broadcastReloadedNoteList() {
+    List<Map<String, String>> notesInfo = generateNotebooksInfo(true);
     broadcastAll(new Message(OP.NOTES_INFO).put("notes", notesInfo));
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/f0383c69/zeppelin-web/src/app/home/home.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/home/home.controller.js b/zeppelin-web/src/app/home/home.controller.js
index 64ff880..f1b2ab3 100644
--- a/zeppelin-web/src/app/home/home.controller.js
+++ b/zeppelin-web/src/app/home/home.controller.js
@@ -22,6 +22,8 @@ angular.module('zeppelinWebApp').controller('HomeCtrl', function($scope,
noteboo
 
   vm.notebookHome = false;
   vm.staticHome = false;
+
+  $scope.isReloading = false;
   
   var initHome = function() {
     websocketMsgSrv.getHomeNotebook();
@@ -46,4 +48,13 @@ angular.module('zeppelinWebApp').controller('HomeCtrl', function($scope,
noteboo
       vm.notebookHome = false;
     }
   });
+
+  $scope.$on('setNoteMenu', function(event, notes) {
+    $scope.isReloadingNotes = false;
+  });
+
+  $scope.reloadNotebookList = function() {
+    websocketMsgSrv.reloadAllNotesFromRepo();
+    $scope.isReloadingNotes = true;
+  };
 });

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/f0383c69/zeppelin-web/src/app/home/home.html
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/home/home.html b/zeppelin-web/src/app/home/home.html
index da7f6fb..62bc9e4 100644
--- a/zeppelin-web/src/app/home/home.html
+++ b/zeppelin-web/src/app/home/home.html
@@ -26,7 +26,12 @@ limitations under the License.
 
       <div class="row">
         <div class="col-md-4">
-          <h4>Notebook</h4>
+          <h4>Notebook 
+            <i ng-class="isReloadingNotes ? 'fa fa-refresh fa-spin' : 'fa fa-refresh'"
+              ng-style="!isReloadingNotes && {'cursor': 'pointer'}" style="font-size:
13px;"
+              ng-click="reloadNotebookList();">
+            </i>
+          </h4>
 
           <div>
             <h5><a href="" data-toggle="modal" data-target="#noteImportModal" style="text-decoration:
none;">

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/f0383c69/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js b/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js
index a10bc87..b8f2204 100644
--- a/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js
+++ b/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js
@@ -32,10 +32,15 @@ angular.module('zeppelinWebApp').service('websocketMsgSrv', function($rootScope,
     cloneNotebook: function(noteIdToClone, newNoteName ) {
       websocketEvents.sendNewEvent({op: 'CLONE_NOTE', data: {id: noteIdToClone, name: newNoteName}});
     },
+
     getNotebookList: function() {
       websocketEvents.sendNewEvent({op: 'LIST_NOTES'});
     },
 
+    reloadAllNotesFromRepo: function() {
+      websocketEvents.sendNewEvent({op: 'RELOAD_NOTES_FROM_REPO'});
+    },
+
     getNotebook: function(noteId) {
       websocketEvents.sendNewEvent({op: 'GET_NOTE', data: {id: noteId}});
     },

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/f0383c69/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
index ed3b8c0..8c41c95 100755
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java
@@ -424,10 +424,6 @@ public class ZeppelinConfiguration extends XMLConfiguration {
     ZEPPELIN_NOTEBOOK_S3_BUCKET("zeppelin.notebook.s3.bucket", "zeppelin"),
     ZEPPELIN_NOTEBOOK_S3_USER("zeppelin.notebook.s3.user", "user"),
     ZEPPELIN_NOTEBOOK_STORAGE("zeppelin.notebook.storage", VFSNotebookRepo.class.getName()),
-    // Notebook list and contents will be always loaded from repository if set true.
-    // If set false, modified notebooks or new notebooks added on file system level
-    // won't be reflected on Zeppelin till user restarts Zeppelin.
-    ZEPPELIN_NOTEBOOK_RELOAD_FROM_STORAGE("zeppelin.notebook.reloadAllNotesFromStorage",
false),
     ZEPPELIN_INTERPRETER_REMOTE_RUNNER("zeppelin.interpreter.remoterunner", "bin/interpreter.sh"),
     // Decide when new note is created, interpreter settings will be binded automatically
or not.
     ZEPPELIN_NOTEBOOK_AUTO_INTERPRETER_BINDING("zeppelin.notebook.autoInterpreterBinding",
true),

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/f0383c69/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
index 79d0a0d..6d08e7b 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
@@ -38,6 +38,7 @@ import org.apache.zeppelin.interpreter.InterpreterGroup;
 import org.apache.zeppelin.interpreter.InterpreterSetting;
 import org.apache.zeppelin.interpreter.remote.RemoteAngularObjectRegistry;
 import org.apache.zeppelin.notebook.repo.NotebookRepo;
+import org.apache.zeppelin.notebook.repo.NotebookRepoSync;
 import org.apache.zeppelin.scheduler.SchedulerFactory;
 import org.apache.zeppelin.search.SearchService;
 import org.quartz.CronScheduleBuilder;
@@ -330,10 +331,18 @@ public class Notebook {
    * @return
    * @throws IOException
    */
-  private void reloadAllNotes() throws IOException {
+  public void reloadAllNotes() throws IOException {
     synchronized (notes) {
       notes.clear();
     }
+
+    if (notebookRepo instanceof NotebookRepoSync) {
+      NotebookRepoSync mainRepo = (NotebookRepoSync) notebookRepo;
+      if (mainRepo.getRepoCount() > 1) {
+        mainRepo.sync();
+      }
+    }
+
     List<NoteInfo> noteInfos = notebookRepo.list();
     for (NoteInfo info : noteInfos) {
       loadNoteFromRepo(info.getId());
@@ -366,13 +375,6 @@ public class Notebook {
   }
 
   public List<Note> getAllNotes() {
-    if (conf.getBoolean(ConfVars.ZEPPELIN_NOTEBOOK_RELOAD_FROM_STORAGE)) {
-      try {
-        reloadAllNotes();
-      } catch (IOException e) {
-        logger.error("Cannot reload notes from storage", e);
-      }
-    }
     synchronized (notes) {
       List<Note> noteList = new ArrayList<Note>(notes.values());
       Collections.sort(noteList, new Comparator<Note>() {

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/f0383c69/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepoSync.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepoSync.java
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepoSync.java
index a5bf6b3..6f964f2 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepoSync.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/NotebookRepoSync.java
@@ -41,7 +41,6 @@ public class NotebookRepoSync implements NotebookRepo {
   private static final int maxRepoNum = 2;
   private static final String pushKey = "pushNoteIDs";
   private static final String pullKey = "pullNoteIDs";
-  private static ZeppelinConfiguration config;
 
   private List<NotebookRepo> repos = new ArrayList<NotebookRepo>();
 
@@ -51,8 +50,6 @@ public class NotebookRepoSync implements NotebookRepo {
    * @throws - Exception
    */
   public NotebookRepoSync(ZeppelinConfiguration conf) throws Exception {
-    config = conf;
-
     String allStorageClassNames = conf.getString(ConfVars.ZEPPELIN_NOTEBOOK_STORAGE).trim();
     if (allStorageClassNames.isEmpty()) {
       throw new IOException("Empty ZEPPELIN_NOTEBOOK_STORAGE conf parameter");
@@ -80,9 +77,6 @@ public class NotebookRepoSync implements NotebookRepo {
    */
   @Override
   public List<NoteInfo> list() throws IOException {
-    if (config.getBoolean(ConfVars.ZEPPELIN_NOTEBOOK_RELOAD_FROM_STORAGE) && getRepoCount()
> 1) {
-      sync(0, 1);
-    }
     return getRepo(0).list();
   }
 
@@ -182,7 +176,7 @@ public class NotebookRepoSync implements NotebookRepo {
     }
   }
 
-  int getRepoCount() {
+  public int getRepoCount() {
     return repos.size();
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/f0383c69/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
index a9cd30f..eedc066 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/NotebookTest.java
@@ -48,7 +48,6 @@ import org.apache.zeppelin.scheduler.Job.Status;
 import org.apache.zeppelin.scheduler.JobListener;
 import org.apache.zeppelin.scheduler.SchedulerFactory;
 import org.apache.zeppelin.search.SearchService;
-import org.apache.zeppelin.search.LuceneSearch;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -123,42 +122,39 @@ public class NotebookTest implements JobListenerFactory{
   }
 
   @Test
-  public void testGetAllNotes() throws IOException {
-    // get all notes after copy the {notebookId}/note.json into notebookDir
+  public void testReloadAllNotes() throws IOException {
     File srcDir = new File("src/test/resources/2A94M5J1Z");
     File destDir = new File(notebookDir.getAbsolutePath() + "/2A94M5J1Z");
 
+    // copy the notebook
     try {
       FileUtils.copyDirectory(srcDir, destDir);
     } catch (IOException e) {
       e.printStackTrace();
     }
 
-    Note copiedNote = notebookRepo.get("2A94M5J1Z");
-
-    // when ZEPPELIN_NOTEBOOK_GET_FROM_REPO set to be false
-    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_RELOAD_FROM_STORAGE.getVarName(), "false");
+    // doesn't have copied notebook in memory before reloading
     List<Note> notes = notebook.getAllNotes();
     assertEquals(notes.size(), 0);
 
-    // when ZEPPELIN_NOTEBOOK_GET_FROM_REPO set to be true
-    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_RELOAD_FROM_STORAGE.getVarName(), "true");
+    // load copied notebook on memory when reloadAllNotes() is called
+    Note copiedNote = notebookRepo.get("2A94M5J1Z");
+    notebook.reloadAllNotes();
     notes = notebook.getAllNotes();
     assertEquals(notes.size(), 1);
     assertEquals(notes.get(0).id(), copiedNote.id());
     assertEquals(notes.get(0).getName(), copiedNote.getName());
     assertEquals(notes.get(0).getParagraphs(), copiedNote.getParagraphs());
 
-    // get all notes after remove the {notebookId}/note.json from notebookDir
-    // when ZEPPELIN_NOTEBOOK_GET_FROM_REPO set to be false
-    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_RELOAD_FROM_STORAGE.getVarName(), "false");
     // delete the notebook
     FileUtils.deleteDirectory(destDir);
+
+    // keep notebook in memory before reloading
     notes = notebook.getAllNotes();
     assertEquals(notes.size(), 1);
 
-    // when ZEPPELIN_NOTEBOOK_GET_FROM_REPO set to be true
-    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_RELOAD_FROM_STORAGE.getVarName(), "true");
+    // delete notebook from notebook list when reloadAllNotes() is called
+    notebook.reloadAllNotes();
     notes = notebook.getAllNotes();
     assertEquals(notes.size(), 0);
   }

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/f0383c69/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/NotebookRepoSyncTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/NotebookRepoSyncTest.java
b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/NotebookRepoSyncTest.java
index 6d8c50d..4bcbccb 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/NotebookRepoSyncTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/repo/NotebookRepoSyncTest.java
@@ -184,41 +184,32 @@ public class NotebookRepoSyncTest implements JobListenerFactory {
     assertEquals(p1.getId(), notebookRepoSync.get(1,
         notebookRepoSync.list(1).get(0).getId()).getLastParagraph().getId());
   }
-  
+
   @Test
-  public void testSyncOnList() throws IOException {
-	
-	/* check that both storage repos are empty */
-	assertTrue(notebookRepoSync.getRepoCount() > 1);
-	assertEquals(0, notebookRepoSync.list(0).size());
-	assertEquals(0, notebookRepoSync.list(1).size());
-	    
-	File srcDir = new File("src/test/resources/2A94M5J1Z");
-	File destDir = new File(secNotebookDir + "/2A94M5J1Z");
-	
-	/* copy manually new notebook into secondary storage repo and check repos */
+  public void testSyncOnReloadedList() throws IOException {
+    /* check that both storage repos are empty */
+    assertTrue(notebookRepoSync.getRepoCount() > 1);
+    assertEquals(0, notebookRepoSync.list(0).size());
+    assertEquals(0, notebookRepoSync.list(1).size());
+
+    File srcDir = new File("src/test/resources/2A94M5J1Z");
+    File destDir = new File(secNotebookDir + "/2A94M5J1Z");
+
+    /* copy manually new notebook into secondary storage repo and check repos */
     try {
-        FileUtils.copyDirectory(srcDir, destDir);
-      } catch (IOException e) {
-        e.printStackTrace();
-      }
+      FileUtils.copyDirectory(srcDir, destDir);
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
     assertEquals(0, notebookRepoSync.list(0).size());
     assertEquals(1, notebookRepoSync.list(1).size());
-    
-    /* Although new notebook is added to secondary storage it's not displayed 
-     * on list() with ZEPPELIN_NOTEBOOK_RELOAD_FROM_STORAGE set to false
-     */
-    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_RELOAD_FROM_STORAGE.getVarName(), "false");
-    assertEquals(0, notebookRepoSync.list().size());
-    
-    /* notebook is synced after ZEPPELIN_NOTEBOOK_RELOAD_FROM_STORAGE variable is set to
true */
-    System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_RELOAD_FROM_STORAGE.getVarName(), "true");
-    assertEquals(1, notebookRepoSync.list().size());
-    
+
+    // After reloading notebooks repos should be synchronized
+    notebookSync.reloadAllNotes();
     assertEquals(1, notebookRepoSync.list(0).size());
-	assertEquals(1, notebookRepoSync.list(1).size());
+    assertEquals(1, notebookRepoSync.list(1).size());
   }
-  
+
   static void delete(File file){
     if(file.isFile()) file.delete();
       else if(file.isDirectory()){
@@ -230,8 +221,8 @@ public class NotebookRepoSyncTest implements JobListenerFactory {
         }
         file.delete();
       }
-    
   }
+
   @Override
   public JobListener getParagraphJobListener(Note note) {
     return new JobListener(){


Mime
View raw message