forked from apache/zeppelin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ZEPPELIN-3778] Cluster synchronize notes & authorization
### What is this PR for? In cluster mode, The user creates, modifies, and deletes the note on any of the zeppelin servers. All need to be notified to all the zeppelin servers in the cluster to synchronize the update of Notebook. Failure to do so will result in the user not being able to continue while switching to another server. 1. Listen for note create/delete/update events 2. Listen for note Notebook Authorization events 3. Broadcast note update event ### What type of PR is it? [Feature] ### What is the Jira issue? * https://issues.apache.org/jira/browse/ZEPPELIN-3778 ### How should this be tested? * [CI Pass](https://travis-ci.org/liuxunorg/zeppelin/builds/546647637) ### Screenshots (if appropriate) ### Sync note event ![syncNote](https://user-images.githubusercontent.com/3677382/59598792-9a50fc80-912f-11e9-940c-c983dff1f373.gif) ### Sync note Authorization ![sync-auth](https://user-images.githubusercontent.com/3677382/59598816-a5a42800-912f-11e9-93fd-9fba426ea7d6.gif) ### Questions: * Does the licenses files need update? * Is there breaking changes for older versions? * Does this needs documentation? Author: Xun Liu <[email protected]> Closes apache#3387 from liuxunorg/ZEPPELIN-3778 and squashes the following commits: 437d108 [Xun Liu] Organize the code format 05b75ad [Xun Liu] [ZEPPELIN-3778] Cluster synchronize notes & authorization
- Loading branch information
Showing
14 changed files
with
1,450 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
zeppelin-interpreter/src/main/java/org/apache/zeppelin/cluster/event/ClusterMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* 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.cluster.event; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
import org.apache.zeppelin.display.Input; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class ClusterMessage { | ||
public ClusterEvent clusterEvent; | ||
private Map<String, String> data = new HashMap<>(); | ||
|
||
private static Gson gson = new GsonBuilder() | ||
.setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ") | ||
.setPrettyPrinting() | ||
.registerTypeAdapterFactory(Input.TypeAdapterFactory).create(); | ||
|
||
public ClusterMessage(ClusterEvent event) { | ||
this.clusterEvent = event; | ||
} | ||
|
||
public ClusterMessage put(String k, String v) { | ||
data.put(k, v); | ||
return this; | ||
} | ||
|
||
public String get(String k) { | ||
return data.get(k); | ||
} | ||
|
||
public Map<String, String> getData() { | ||
return data; | ||
} | ||
|
||
public static ClusterMessage deserializeMessage(String msg) { | ||
return gson.fromJson(msg, ClusterMessage.class); | ||
} | ||
|
||
public static String serializeMessage(ClusterMessage m) { | ||
return gson.toJson(m); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.