You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zeppelin.apache.org by GitBox <gi...@apache.org> on 2021/10/26 11:12:46 UTC

[GitHub] [zeppelin] Reamer commented on a change in pull request #4252: [ZEPPELIN-5559] Add note cache

Reamer commented on a change in pull request #4252:
URL: https://github.com/apache/zeppelin/pull/4252#discussion_r736417406



##########
File path: zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
##########
@@ -391,13 +392,76 @@ public Note getNote(String noteId, boolean reload) throws IOException {
     return note;
   }
 
-  public void saveNote(Note note, AuthenticationInfo subject) throws IOException {
-    noteManager.saveNote(note, subject);
+  /**
+   * Save an existing note in an eviction aware fashion with only before save callback.
+   *
+   * @param nodeId noteId to run save operation on
+   * @param subject current subject
+   * @param beforeSave callback for applying an changes to the note before saving it to the notebook repo.
+   *
+   * @see #saveExistingNote(String, AuthenticationInfo, NoteSaveCallback, NoteSaveCallback)
+   */
+  public <T> T saveExistingNote(String noteId, AuthenticationInfo subject,
+      NoteBeforeSaveCallback<T> beforeSave) throws IOException {
+    return saveExistingNote(noteId, subject, beforeSave, null);
+  }
+
+  /**
+   * Save an existing note in an eviction aware fashion using callbacks around the save operations.
+   * When no note exists for given noteId, only beforeSave callback is processed.
+   *
+   * @param nodeId noteId to run save operation on
+   * @param subject current subject
+   * @param beforeSave callback for applying an changes to the note before saving it to the notebook repo.
+   * @param afterSave callback for applying an changes to the note after saving it to the notebook repo.
+   * @return the result of the beforeSave callback
+   */
+  public <T> T saveExistingNote(String noteId, AuthenticationInfo subject,
+      NoteBeforeSaveCallback<T> beforeSave, NoteAfterSaveCallback<T> afterSave) throws IOException {
+    final Note note = getNote(noteId, false);
+
+    if (note == null) { // callback contract: run beforeSave callback also when no note exists for given noteId

Review comment:
       To return a correct answer as in this [case](https://github.com/apache/zeppelin/pull/4252/files#diff-5fca6cde02fb95c432560e3adfb7a7a20822a03cfcfb301c5262622dd8ac10abL353).
   Or to return the right exception as in this [case](https://github.com/apache/zeppelin/pull/4252/files#diff-5fca6cde02fb95c432560e3adfb7a7a20822a03cfcfb301c5262622dd8ac10abL558).
   




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org