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 2022/07/03 15:18:44 UTC

[GitHub] [zeppelin] jongyoul commented on a diff in pull request #4382: [ZEPPELIN-5754] Init Notes in background

jongyoul commented on code in PR #4382:
URL: https://github.com/apache/zeppelin/pull/4382#discussion_r912501438


##########
zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java:
##########
@@ -109,6 +119,60 @@ public void recoveryIfNecessary() {
     }
   }
 
+  /**
+   * Subsystems can add a consumer, which is executed during initialization.
+   * Initialization is performed in parallel and with multiple threads.
+   *
+   * The consumer must be thread safe.
+   *
+   * @param initConsumer Consumer, which is passed the NoteId.
+   */
+  public void addInitConsumer(Consumer<String> initConsumer) {
+    this.initConsumers.add(initConsumer);
+  }
+
+  /**
+   * Asynchronous and parallel initialization of notes (during startup)
+   */
+  public void initNotebook() {
+    initExecutor = new ThreadPoolExecutor(0, Runtime.getRuntime().availableProcessors(), 1, TimeUnit.MINUTES,

Review Comment:
   nit. Why don't you initialize it on the constructor or a static variable? If we call `initNotebook` multiple times by mistake, it can leak memory because `ThreaPoolExecutor` won't be shut down clearly.



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