You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by pr...@apache.org on 2018/03/15 03:16:20 UTC

zeppelin git commit: [ZEPPELIN-3321] isRevisionSupported not working for importing notebooks.

Repository: zeppelin
Updated Branches:
  refs/heads/master 8b2259cf5 -> 6001b98de


[ZEPPELIN-3321] isRevisionSupported not working for importing notebooks.

 when importing note of from one zeppelin instance that don't support revision to another zeppelin instance where revision is supported, the imported note still don't support revision.

[Bug Fix]

* [ZEPPELIN-3321](https://issues.apache.org/jira/browse/ZEPPELIN-3321)

* Does the licenses files need update? N/A
* Is there breaking changes for older versions? N/A
* Does this needs documentation? N/A

Author: Prabhjyot Singh <pr...@gmail.com>

Closes #2862 from prabhjyotsingh/ZEPPELIN-3321 and squashes the following commits:

eca6b59 [Prabhjyot Singh] add unit test for isRevisionSupported
552fdeb [Prabhjyot Singh] approach 2: set as isRevisionSupported zeppelin global config
18873d3 [Prabhjyot Singh] ZEPPELIN-3321: fix isRevisionSupported

Change-Id: I49ec3350303b39a41b769bc47941c3397160234c


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

Branch: refs/heads/master
Commit: 6001b98de620c13d57c88a0b4ae328bf19f338ea
Parents: 8b2259c
Author: Prabhjyot Singh <pr...@gmail.com>
Authored: Wed Mar 14 15:34:48 2018 +0530
Committer: Prabhjyot Singh <pr...@gmail.com>
Committed: Thu Mar 15 08:46:03 2018 +0530

----------------------------------------------------------------------
 .../apache/zeppelin/socket/NotebookServer.java  |  2 +-
 .../src/app/notebook/notebook-actionBar.html    |  2 +-
 .../src/components/navbar/navbar.controller.js  | 12 +++++++++
 .../java/org/apache/zeppelin/notebook/Note.java | 11 --------
 .../org/apache/zeppelin/notebook/Notebook.java  | 11 +++++++-
 .../apache/zeppelin/notebook/NotebookTest.java  | 27 ++++++++++++++++++++
 6 files changed, 51 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/6001b98d/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 4a17f5d..87c757c 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
@@ -1908,7 +1908,7 @@ public class NotebookServer extends WebSocketServlet
                     .getVarName());
           }
         });
-
+    configurations.put("isRevisionSupported", String.valueOf(notebook.isRevisionSupported()));
     conn.send(serializeMessage(
         new Message(OP.CONFIGURATIONS_INFO).put("configurations", configurations)));
   }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/6001b98d/zeppelin-web/src/app/notebook/notebook-actionBar.html
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/notebook-actionBar.html b/zeppelin-web/src/app/notebook/notebook-actionBar.html
index b4add93..7559a87 100644
--- a/zeppelin-web/src/app/notebook/notebook-actionBar.html
+++ b/zeppelin-web/src/app/notebook/notebook-actionBar.html
@@ -100,7 +100,7 @@ limitations under the License.
       </button>
     </span>
 
-    <span class="labelBtn btn-group" role="group" ng-if="note.config.isRevisionSupported">
+    <span class="labelBtn btn-group" role="group" ng-if="isRevisionSupported()" >
       <div class="btn-group" role="group">
         <button type="button"
                 class="btn btn-default btn-xs dropdown-toggle"

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/6001b98d/zeppelin-web/src/components/navbar/navbar.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/navbar/navbar.controller.js b/zeppelin-web/src/components/navbar/navbar.controller.js
index 9fb5db2..7665bf8 100644
--- a/zeppelin-web/src/components/navbar/navbar.controller.js
+++ b/zeppelin-web/src/components/navbar/navbar.controller.js
@@ -31,6 +31,7 @@ function NavCtrl($scope, $rootScope, $http, $routeParams, $location,
   vm.TRASH_FOLDER_ID = TRASH_FOLDER_ID;
   vm.isFilterNote = isFilterNote;
   vm.numberOfNotesDisplayed = 10;
+  let revisionSupported = false;
 
   $scope.query = {q: ''};
 
@@ -245,4 +246,15 @@ function NavCtrl($scope, $rootScope, $http, $routeParams, $location,
     }
     return 'top';
   };
+
+  $scope.$on('configurationsInfo', function(scope, event) {
+    // Server send this parameter is String
+    if(event.configurations['isRevisionSupported']==='true') {
+      revisionSupported = true;
+    }
+  });
+
+  $rootScope.isRevisionSupported = function() {
+    return revisionSupported;
+  };
 }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/6001b98d/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
index f2d7763..85a5f1c 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
@@ -301,17 +301,6 @@ public class Note implements ParagraphJobListener, JsonSerializable {
     this.repo = repo;
   }
 
-  void setRevisionSupported(NotebookRepo repo) {
-    if (repo instanceof NotebookRepoSync) {
-      getConfig()
-          .put("isRevisionSupported", ((NotebookRepoSync) repo).isRevisionSupportedInDefaultRepo());
-    } else if (repo instanceof NotebookRepoWithVersionControl) {
-      getConfig().put("isRevisionSupported", true);
-    } else {
-      getConfig().put("isRevisionSupported", false);
-    }
-  }
-
   public Boolean isCronSupported(ZeppelinConfiguration config) {
     if (config.isZeppelinNotebookCronEnable()) {
       config.getZeppelinNotebookCronFolders();

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/6001b98d/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 7467e31..693375d 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
@@ -521,7 +521,6 @@ public class Notebook implements NoteEventListener {
 
     note.setJobListenerFactory(jobListenerFactory);
     note.setNotebookRepo(notebookRepo);
-    note.setRevisionSupported(notebookRepo);
     note.setCronSupported(getConf());
 
     Map<String, SnapshotAngularObject> angularObjectSnapshot = new HashMap<>();
@@ -1061,6 +1060,16 @@ public class Notebook implements NoteEventListener {
     }
   }
 
+  public Boolean isRevisionSupported() {
+    if (notebookRepo instanceof NotebookRepoSync) {
+      return ((NotebookRepoSync) notebookRepo).isRevisionSupportedInDefaultRepo();
+    } else if (notebookRepo instanceof NotebookRepoWithVersionControl) {
+      return true;
+    } else {
+      return false;
+    }
+  }
+
   @Override
   public void onParagraphRemove(Paragraph p) {
     for (NotebookEventListener listener : notebookEventListeners) {

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/6001b98d/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 490ac53..3b903e9 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
@@ -31,6 +31,8 @@ import org.apache.zeppelin.interpreter.InterpreterOption;
 import org.apache.zeppelin.interpreter.InterpreterResult;
 import org.apache.zeppelin.interpreter.InterpreterResultMessage;
 import org.apache.zeppelin.interpreter.InterpreterSetting;
+import org.apache.zeppelin.notebook.repo.FileSystemNotebookRepo;
+import org.apache.zeppelin.notebook.repo.GitHubNotebookRepo;
 import org.apache.zeppelin.interpreter.remote.RemoteInterpreter;
 import org.apache.zeppelin.notebook.repo.NotebookRepo;
 import org.apache.zeppelin.notebook.repo.VFSNotebookRepo;
@@ -111,6 +113,31 @@ public class NotebookTest extends AbstractInterpreterTest implements JobListener
   }
 
   @Test
+  public void testRevisionSupported() throws IOException, SchedulerException {
+    NotebookRepo notebookRepo;
+    Notebook notebook;
+
+    notebookRepo = new VFSNotebookRepo(conf);
+    notebook = new Notebook(conf, notebookRepo, schedulerFactory, interpreterFactory,
+        interpreterSettingManager, this, null,
+        notebookAuthorization, credentials);
+    assertFalse("Revision is not supported in VFSNotebookRepo", notebook.isRevisionSupported());
+
+    notebookRepo = new GitHubNotebookRepo(conf);
+    notebook = new Notebook(conf, notebookRepo, schedulerFactory, interpreterFactory,
+        interpreterSettingManager, this, null,
+        notebookAuthorization, credentials);
+    assertTrue("Revision is supported in GitHubNotebookRepo", notebook.isRevisionSupported());
+
+    notebookRepo = new FileSystemNotebookRepo(conf);
+    notebook = new Notebook(conf, notebookRepo, schedulerFactory, interpreterFactory,
+        interpreterSettingManager, this, null,
+        notebookAuthorization, credentials);
+    assertFalse("Revision is not supported in FileSystemNotebookRepo",
+        notebook.isRevisionSupported());
+  }
+
+  @Test
   public void testSelectingReplImplementation() throws IOException {
     Note note = notebook.createNote(anonymous);
     interpreterSettingManager.setInterpreterBinding(anonymous.getUser(), note.getId(), interpreterSettingManager.getInterpreterSettingIds());