zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjf...@apache.org
Subject [zeppelin] branch master updated: [ZEPPELIN-4514]. Job URL link is missing when refreshing note
Date Tue, 31 Dec 2019 01:31:12 GMT
This is an automated email from the ASF dual-hosted git repository.

zjffdu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/master by this push:
     new ea8557d  [ZEPPELIN-4514]. Job URL link is missing when refreshing note
ea8557d is described below

commit ea8557d13412ae1427055f470c0f8f98b41c5a99
Author: Jeff Zhang <zjffdu@apache.org>
AuthorDate: Fri Dec 27 21:59:12 2019 +0800

    [ZEPPELIN-4514]. Job URL link is missing when refreshing note
    
    ### What is this PR for?
    
    This PR use gson's ExclusionStrategy to change the serialization of Paragraph dynamically:
serialize runtimeInfos for frontend but not for note file.
    
    ### What type of PR is it?
    [ Improvement ]
    
    ### Todos
    * [ ] - Task
    
    ### What is the Jira issue?
    * https://issues.apache.org/jira/browse/ZEPPELIN-4514
    
    ### How should this be tested?
    * Verify it manually, run spark job at one note. Then open another tab to open the note
to verify that the job url link is still there.
    
    ### Screenshots (if appropriate)
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No
    
    Author: Jeff Zhang <zjffdu@apache.org>
    
    Closes #3578 from zjffdu/ZEPPELIN-4514 and squashes the following commits:
    
    6ad47ba4d [Jeff Zhang] [ZEPPELIN-4514]. Job URL link is missing when refreshing note
---
 .../org/apache/zeppelin/socket/NotebookServer.java |  3 +-
 .../java/org/apache/zeppelin/notebook/Note.java    | 17 +++++++++++
 .../org/apache/zeppelin/notebook/Paragraph.java    |  3 +-
 .../notebook/ParagraphWithRuntimeInfo.java         | 35 ----------------------
 4 files changed, 20 insertions(+), 38 deletions(-)

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 e5e2945..831c76e 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
@@ -70,7 +70,6 @@ import org.apache.zeppelin.notebook.Notebook;
 import org.apache.zeppelin.notebook.NotebookImportDeserializer;
 import org.apache.zeppelin.notebook.Paragraph;
 import org.apache.zeppelin.notebook.ParagraphJobListener;
-import org.apache.zeppelin.notebook.ParagraphWithRuntimeInfo;
 import org.apache.zeppelin.notebook.AuthorizationService;
 import org.apache.zeppelin.notebook.repo.NotebookRepoWithVersionControl.Revision;
 import org.apache.zeppelin.notebook.socket.Message;
@@ -551,7 +550,7 @@ public class NotebookServer extends WebSocketServlet
     if (note.isPersonalizedMode()) {
       broadcastParagraphs(p.getUserParagraphMap(), p);
     } else {
-      Message message = new Message(OP.PARAGRAPH).put("paragraph", new ParagraphWithRuntimeInfo(p));
+      Message message = new Message(OP.PARAGRAPH).put("paragraph", p);
       connectionManager.broadcast(note.getId(), message);
     }
   }
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 3ed6eb2..a9388a6 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
@@ -18,6 +18,8 @@
 package org.apache.zeppelin.notebook;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.gson.ExclusionStrategy;
+import com.google.gson.FieldAttributes;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import org.apache.commons.lang.StringUtils;
@@ -64,11 +66,26 @@ import java.util.Set;
  */
 public class Note implements JsonSerializable {
   private static final Logger logger = LoggerFactory.getLogger(Note.class);
+
+  // serialize Paragraph#runtimeInfos to frontend but not to note file
+  private static final ExclusionStrategy strategy = new ExclusionStrategy() {
+    @Override
+    public boolean shouldSkipField(FieldAttributes f) {
+      return f.getName().equals("runtimeInfos");
+    }
+
+    @Override
+    public boolean shouldSkipClass(Class<?> clazz) {
+      return false;
+    }
+  };
+
   private static Gson gson = new GsonBuilder()
       .setPrettyPrinting()
       .setDateFormat("yyyy-MM-dd HH:mm:ss.SSS")
       .registerTypeAdapter(Date.class, new NotebookImportDeserializer())
       .registerTypeAdapterFactory(Input.TypeAdapterFactory)
+      .setExclusionStrategies(strategy)
       .create();
 
   private List<Paragraph> paragraphs = new LinkedList<>();
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
index c16a9ec..a21fd33 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
@@ -105,7 +105,8 @@ public class Paragraph extends JobWithProgressPoller<InterpreterResult>
implemen
   // personalized
   private transient Map<String, Paragraph> userParagraphMap = new HashMap<>();
   private transient Map<String, String> localProperties = new HashMap<>();
-  private transient Map<String, ParagraphRuntimeInfo> runtimeInfos = new HashMap<>();
+  // serialize runtimeInfos to frontend but not to note file (via gson's ExclusionStrategy)
+  private Map<String, ParagraphRuntimeInfo> runtimeInfos = new HashMap<>();
 
   public static String  PARAGRAPH_CONFIG_RUNONSELECTIONCHANGE = "runOnSelectionChange";
   private static boolean PARAGRAPH_CONFIG_RUNONSELECTIONCHANGE_DEFAULT = true;
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/ParagraphWithRuntimeInfo.java
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/ParagraphWithRuntimeInfo.java
deleted file mode 100644
index 33dce22..0000000
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/ParagraphWithRuntimeInfo.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zeppelin.notebook;
-
-import java.util.Map;
-
-/**
- * This class is used for broadcast Paragrapah to frontend.
- * runtimeInfos will also been prapagated to frontend.
- */
-public class ParagraphWithRuntimeInfo extends Paragraph {
-
-  private Map<String, ParagraphRuntimeInfo> runtimeInfos;
-
-  public ParagraphWithRuntimeInfo(Paragraph p) {
-    super(p);
-    this.runtimeInfos = p.getRuntimeInfos();
-  }
-
-}


Mime
View raw message