This is an automated email from the ASF dual-hosted git repository.
liuxun 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 6a7b671 [ZEPPELIN-4210] NotebookAuthorization does not need to
synchronize cluster event
6a7b671 is described below
commit 6a7b6719fa6c7049e00dd9d5085172af20c94416
Author: Xun Liu <[email protected]>
AuthorDate: Tue Jul 2 10:10:52 2019 +0800
[ZEPPELIN-4210] NotebookAuthorization does not need to synchronize cluster
event
### What is this PR for?
Because NotebookAuthorization is used to give UpgradeNoteFileTool.
So NotebookAuthorization does not need to synchronize clusterEvent.
### What type of PR is it?
[Bug Fix]
### Todos
* [ ] - Task
### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-4210
### How should this be tested?
[CI Pass](https://travis-ci.org/liuxunorg/zeppelin/builds/553205871)
### Screenshots (if appropriate)
### Questions:
* Does the licenses files need update?
* Is there breaking changes for older versions?
* Does this needs documentation?
Author: Xun Liu <[email protected]>
Closes #3394 from liuxunorg/ZEPPELIN-4210 and squashes the following
commits:
f57c2c318 [Xun Liu] [ZEPPELIN-4210] NotebookAuthorization does not need to
synchronize cluster event
---
.../zeppelin/cluster/ClusterManagerServer.java | 1 -
.../apache/zeppelin/cluster/ClusterEventTest.java | 11 +++--
.../cluster/ClusterNoteAuthEventListenerTest.java | 50 ----------------------
.../zeppelin/notebook/NotebookAuthorization.java | 43 +------------------
4 files changed, 6 insertions(+), 99 deletions(-)
diff --git
a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/cluster/ClusterManagerServer.java
b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/cluster/ClusterManagerServer.java
index 530dff5..4cd370d 100644
---
a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/cluster/ClusterManagerServer.java
+++
b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/cluster/ClusterManagerServer.java
@@ -74,7 +74,6 @@ public class ClusterManagerServer extends ClusterManager {
public static String CLUSTER_INTP_EVENT_TOPIC = "CLUSTER_INTP_EVENT_TOPIC";
public static String CLUSTER_NOTE_EVENT_TOPIC = "CLUSTER_NOTE_EVENT_TOPIC";
public static String CLUSTER_AUTH_EVENT_TOPIC = "CLUSTER_AUTH_EVENT_TOPIC";
- public static String CLUSTER_NB_AUTH_EVENT_TOPIC =
"CLUSTER_NB_AUTH_EVENT_TOPIC";
public static String CLUSTER_INTP_SETTING_EVENT_TOPIC =
"CLUSTER_INTP_SETTING_EVENT_TOPIC";
private ClusterManagerServer() {
diff --git
a/zeppelin-server/src/test/java/org/apache/zeppelin/cluster/ClusterEventTest.java
b/zeppelin-server/src/test/java/org/apache/zeppelin/cluster/ClusterEventTest.java
index 7257245..265a61d 100644
---
a/zeppelin-server/src/test/java/org/apache/zeppelin/cluster/ClusterEventTest.java
+++
b/zeppelin-server/src/test/java/org/apache/zeppelin/cluster/ClusterEventTest.java
@@ -27,7 +27,6 @@ import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.thrift.TException;
-import org.apache.zeppelin.cluster.event.ClusterEventListener;
import org.apache.zeppelin.cluster.meta.ClusterMetaType;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.interpreter.InterpreterResult;
@@ -79,7 +78,6 @@ public class ClusterEventTest extends ZeppelinServerMock {
private static List<ClusterAuthEventListenerTest>
clusterAuthEventListenerTests = new ArrayList<>();
private static List<ClusterNoteEventListenerTest>
clusterNoteEventListenerTests = new ArrayList<>();
- private static List<ClusterNoteAuthEventListenerTest>
clusterNoteAuthEventListenerTests = new ArrayList<>();
private static List<ClusterIntpSettingEventListenerTest>
clusterIntpSettingEventListenerTests = new ArrayList<>();
private static List<ClusterManagerServer> clusterServers = new ArrayList<>();
@@ -103,6 +101,7 @@ public class ClusterEventTest extends ZeppelinServerMock {
ZeppelinServerMock.startUp(ClusterEventTest.class.getSimpleName(), zconf);
notebook = TestUtils.getInstance(Notebook.class);
authorizationService = new AuthorizationService(notebook, zconf);
+
schedulerService = new QuartzSchedulerService(zconf, notebook);
notebookServer = spy(NotebookServer.getInstance());
notebookService = new NotebookService(notebook, authorizationService,
zconf, schedulerService);
@@ -222,10 +221,6 @@ public class ClusterEventTest extends ZeppelinServerMock {
clusterNoteEventListenerTests.add(clusterNoteEventListenerTest);
clusterServer.addClusterEventListeners(ClusterManagerServer.CLUSTER_NOTE_EVENT_TOPIC,
clusterNoteEventListenerTest);
- ClusterNoteAuthEventListenerTest clusterNoteAuthEventListenerTest = new
ClusterNoteAuthEventListenerTest();
- clusterNoteAuthEventListenerTests.add(clusterNoteAuthEventListenerTest);
-
clusterServer.addClusterEventListeners(ClusterManagerServer.CLUSTER_NB_AUTH_EVENT_TOPIC,
clusterNoteAuthEventListenerTest);
-
ClusterIntpSettingEventListenerTest clusterIntpSettingEventListenerTest
= new ClusterIntpSettingEventListenerTest();
clusterIntpSettingEventListenerTests.add(clusterIntpSettingEventListenerTest);
clusterServer.addClusterEventListeners(ClusterManagerServer.CLUSTER_INTP_SETTING_EVENT_TOPIC,
clusterIntpSettingEventListenerTest);
@@ -278,6 +273,7 @@ public class ClusterEventTest extends ZeppelinServerMock {
assertNotNull(srvMeta);
assertEquals(true, (srvMeta instanceof HashMap));
HashMap hashMap = (HashMap) srvMeta;
+
assertEquals(hashMap.size(), 3);
LOGGER.info("getClusterServerMeta <<< ");
@@ -320,6 +316,8 @@ public class ClusterEventTest extends ZeppelinServerMock {
String clonedNoteId = null;
try {
note1 = TestUtils.getInstance(Notebook.class).createNote("note1",
anonymous);
+ Thread.sleep(1000);
+
PostMethod post = httpPost("/notebook/" + note1.getId(), "");
LOG.info("testCloneNote response\n" + post.getResponseBodyAsString());
assertThat(post, isAllowed());
@@ -327,6 +325,7 @@ public class ClusterEventTest extends ZeppelinServerMock {
new TypeToken<Map<String, Object>>() {}.getType());
clonedNoteId = (String) resp.get("body");
post.releaseConnection();
+ Thread.sleep(1000);
GetMethod get = httpGet("/notebook/" + clonedNoteId);
assertThat(get, isAllowed());
diff --git
a/zeppelin-server/src/test/java/org/apache/zeppelin/cluster/ClusterNoteAuthEventListenerTest.java
b/zeppelin-server/src/test/java/org/apache/zeppelin/cluster/ClusterNoteAuthEventListenerTest.java
deleted file mode 100644
index 56996bd..0000000
---
a/zeppelin-server/src/test/java/org/apache/zeppelin/cluster/ClusterNoteAuthEventListenerTest.java
+++ /dev/null
@@ -1,50 +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.cluster;
-
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
-import org.apache.zeppelin.cluster.event.ClusterEventListener;
-import org.apache.zeppelin.cluster.event.ClusterMessage;
-import org.apache.zeppelin.user.AuthenticationInfo;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Set;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-public class ClusterNoteAuthEventListenerTest implements ClusterEventListener {
- private static Logger LOGGER =
LoggerFactory.getLogger(ClusterNoteAuthEventListenerTest.class);
-
- public String receiveMsg = null;
-
- @Override
- public void onClusterEvent(String msg) {
- receiveMsg = msg;
- LOGGER.info("ClusterNoteAuthEventListenerTest#onClusterEvent : {}", msg);
- ClusterMessage message = ClusterMessage.deserializeMessage(msg);
- String noteId = message.get("noteId");
- String json = message.get("subject");
- AuthenticationInfo subject = AuthenticationInfo.fromJson(json);
-
- assertNotNull(noteId);
- assertNotNull(json);
- assertNotNull(subject);
- }
-}
diff --git
a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NotebookAuthorization.java
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NotebookAuthorization.java
index 8429e0c..d52dc77 100644
---
a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NotebookAuthorization.java
+++
b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/NotebookAuthorization.java
@@ -18,7 +18,6 @@
package org.apache.zeppelin.notebook;
import java.io.IOException;
-import java.lang.reflect.GenericSignatureFormatError;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -27,12 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import com.google.gson.Gson;
import org.apache.commons.lang.StringUtils;
-import org.apache.zeppelin.cluster.ClusterManagerServer;
-import org.apache.zeppelin.cluster.event.ClusterEvent;
-import org.apache.zeppelin.cluster.event.ClusterEventListener;
-import org.apache.zeppelin.cluster.event.ClusterMessage;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
import org.apache.zeppelin.scheduler.Job;
@@ -48,7 +42,7 @@ import com.google.common.collect.Sets;
/**
* Contains authorization information for notes
*/
-public class NotebookAuthorization implements NoteEventListener,
ClusterEventListener {
+public class NotebookAuthorization implements NoteEventListener {
private static final Logger LOG =
LoggerFactory.getLogger(NotebookAuthorization.class);
private static NotebookAuthorization instance = null;
/*
@@ -70,8 +64,6 @@ public class NotebookAuthorization implements
NoteEventListener, ClusterEventLis
if (instance == null) {
instance = new NotebookAuthorization();
conf = config;
- ClusterManagerServer.getInstance().addClusterEventListeners(
- ClusterManagerServer.CLUSTER_NB_AUTH_EVENT_TOPIC, instance);
try {
configStorage = ConfigStorage.getInstance(config);
loadFromFile();
@@ -388,11 +380,6 @@ public class NotebookAuthorization implements
NoteEventListener, ClusterEventLis
}
public void setNewNotePermissions(String noteId, AuthenticationInfo subject)
{
- inlineSetNewNotePermissions(noteId, subject);
- broadcastClusterEvent(ClusterEvent.SET_NEW_NOTE_PERMISSIONS, noteId,
subject);
- }
-
- public void inlineSetNewNotePermissions(String noteId, AuthenticationInfo
subject) {
if (!AuthenticationInfo.isAnonymous(subject)) {
if (isPublic()) {
// add current user to owners - can be public
@@ -400,7 +387,6 @@ public class NotebookAuthorization implements
NoteEventListener, ClusterEventLis
owners.add(subject.getUser());
setOwners(noteId, owners);
} else {
- Map<ClusterEvent, Set<String>> mapEntities = new HashMap<>();
// add current user to owners, readers, runners, writers - private note
Set<String> entities = getOwners(noteId);
entities.add(subject.getUser());
@@ -455,31 +441,4 @@ public class NotebookAuthorization implements
NoteEventListener, ClusterEventLis
public void onParagraphStatusChange(Paragraph p, Job.Status status) {
}
-
- @Override
- public void onClusterEvent(String msg) {
- if (LOG.isDebugEnabled()) {
- LOG.info("onClusterEvent : {}", msg);
- }
- ClusterMessage message = ClusterMessage.deserializeMessage(msg);
- String noteId = message.get("noteId");
- String json = message.get("subject");
- AuthenticationInfo subject = AuthenticationInfo.fromJson(json);
-
- inlineSetNewNotePermissions(noteId, subject);
- }
-
- // broadcast cluster event
- private void broadcastClusterEvent(ClusterEvent event, String noteId,
AuthenticationInfo subject) {
- if (!conf.isClusterMode()) {
- return;
- }
-
- ClusterMessage message = new ClusterMessage(event);
- message.put("noteId", noteId);
- message.put("subject", subject.toJson());
- String msg = ClusterMessage.serializeMessage(message);
- ClusterManagerServer.getInstance().broadcastClusterEvent(
- ClusterManagerServer.CLUSTER_AUTH_EVENT_TOPIC, msg);
- }
}