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



##########
File path: 
zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NoteManager.java
##########
@@ -561,69 +569,79 @@ public String toString() {
    * This class has 2 usage scenarios:
    * 1. metadata of note (only noteId and note name is loaded via reading the 
file name)
    * 2. the note object (note content is loaded from NotebookRepo)
-   *
+   * <br>
    * It will load note from NotebookRepo lazily until method getNote is called.
+   * A NoteCache ensures to free up resources, because its size is limited.
    */
   public static class NoteNode {
 
     private Folder parent;
-    private Note note;
+    private NoteInfo noteinfo;
     private NotebookRepo notebookRepo;
+    private NoteCache noteCache;
 
-    public NoteNode(Note note, Folder parent, NotebookRepo notebookRepo) {
-      this.note = note;
+    public NoteNode(NoteInfo noteinfo, Folder parent, NotebookRepo 
notebookRepo, NoteCache noteCache) {
+      this.noteinfo = noteinfo;
       this.parent = parent;
       this.notebookRepo = notebookRepo;
-    }
-
-    public synchronized Note getNote() throws IOException {
-        return getNote(false);
+      this.noteCache = noteCache;
     }
 
     /**
-     * This method will load note from NotebookRepo. If you just want to get 
noteId, noteName or
+     * This method will process note in a eviction aware manner by loading it 
from NotebookRepo.
+     *
+     * If you just want to get noteId, noteName or
      * notePath, you can call method getNoteId, getNoteName & getNotePath
-     * @return
+     *
+     * @param reload force a reload from {@link NotebookRepo}
+     * @param noteProcessor callback
+     * @return result of the noteProcessor
      * @throws IOException
      */
-    public synchronized Note getNote(boolean reload) throws IOException {
-      if (!note.isLoaded() || reload) {
-        note = notebookRepo.get(note.getId(), note.getPath(), 
AuthenticationInfo.ANONYMOUS);
-        if (parent.toString().equals("/")) {
-          note.setPath("/" + note.getName());
-        } else {
-          note.setPath(parent.toString() + "/" + note.getName());
+    public <T> T loadAndProcessNote(boolean reload, NoteProcessor<T> 
noteProcessor)
+        throws IOException {
+        // load note

Review comment:
       minor indention issue 




-- 
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-unsubscr...@zeppelin.apache.org

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


Reply via email to