mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
fix: Clear output in personalized paragraph
This commit is contained in:
parent
e5922b6bba
commit
b7387849fe
2 changed files with 50 additions and 7 deletions
|
|
@ -643,6 +643,22 @@ public class NotebookServer extends WebSocketServlet
|
|||
broadcast(noteId, new Message(OP.INTERPRETER_BINDINGS).put("interpreterBindings", settingList));
|
||||
}
|
||||
|
||||
public void unicastParagraph(Note note, Paragraph p, String user) {
|
||||
if (!note.isPersonalizedMode() || p == null || user == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!userConnectedSockets.containsKey(user)) {
|
||||
LOG.warn("Failed to send unicast. user {} that is not in connections map", user);
|
||||
return;
|
||||
}
|
||||
|
||||
for (NotebookSocket conn : userConnectedSockets.get(user)) {
|
||||
Message m = new Message(OP.PARAGRAPH).put("paragraph", p);
|
||||
unicast(m, conn);
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastParagraph(Note note, Paragraph p) {
|
||||
if (note.isPersonalizedMode()) {
|
||||
broadcastParagraphs(p.getUserParagraphMap(), p);
|
||||
|
|
@ -1300,9 +1316,15 @@ public class NotebookServer extends WebSocketServlet
|
|||
}
|
||||
|
||||
final Note note = notebook.getNote(noteId);
|
||||
note.clearParagraphOutput(paragraphId);
|
||||
Paragraph paragraph = note.getParagraph(paragraphId);
|
||||
broadcastParagraph(note, paragraph);
|
||||
if (note.isPersonalizedMode()) {
|
||||
String user = fromMessage.principal;
|
||||
Paragraph p = note.clearPersonalizedParagraphOutput(paragraphId, user);
|
||||
unicastParagraph(note, p, user);
|
||||
} else {
|
||||
note.clearParagraphOutput(paragraphId);
|
||||
Paragraph paragraph = note.getParagraph(paragraphId);
|
||||
broadcastParagraph(note, paragraph);
|
||||
}
|
||||
}
|
||||
|
||||
private void completion(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook,
|
||||
|
|
|
|||
|
|
@ -390,6 +390,26 @@ public class Note implements Serializable, ParagraphJobListener {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void clearParagraphOutputFields(Paragraph p) {
|
||||
p.setReturn(null, null);
|
||||
p.clearRuntimeInfo(null);
|
||||
}
|
||||
|
||||
public Paragraph clearPersonalizedParagraphOutput(String paragraphId, String user) {
|
||||
synchronized (paragraphs) {
|
||||
for (Paragraph p : paragraphs) {
|
||||
if (!p.getId().equals(paragraphId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
p = p.getUserParagraphMap().get(user);
|
||||
clearParagraphOutputFields(p);
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear paragraph output by id.
|
||||
*
|
||||
|
|
@ -399,11 +419,12 @@ public class Note implements Serializable, ParagraphJobListener {
|
|||
public Paragraph clearParagraphOutput(String paragraphId) {
|
||||
synchronized (paragraphs) {
|
||||
for (Paragraph p : paragraphs) {
|
||||
if (p.getId().equals(paragraphId)) {
|
||||
p.setReturn(null, null);
|
||||
p.clearRuntimeInfo(null);
|
||||
return p;
|
||||
if (!p.getId().equals(paragraphId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
clearParagraphOutputFields(p);
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue