mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Move NotebookSocket.send() out of synchronized block
This commit is contained in:
parent
2842251b77
commit
c01246c246
1 changed files with 22 additions and 17 deletions
|
|
@ -483,40 +483,45 @@ public class NotebookServer extends WebSocketServlet
|
|||
}
|
||||
|
||||
private void broadcast(String noteId, Message m) {
|
||||
List<NotebookSocket> socketsToBroadcast;
|
||||
synchronized (noteSocketMap) {
|
||||
broadcastToWatchers(noteId, StringUtils.EMPTY, m);
|
||||
List<NotebookSocket> socketLists = noteSocketMap.get(noteId);
|
||||
if (socketLists == null || socketLists.size() == 0) {
|
||||
return;
|
||||
}
|
||||
LOG.debug("SEND >> " + m);
|
||||
for (NotebookSocket conn : socketLists) {
|
||||
try {
|
||||
conn.send(serializeMessage(m));
|
||||
} catch (IOException e) {
|
||||
LOG.error("socket error", e);
|
||||
}
|
||||
socketsToBroadcast = new ArrayList<>(socketLists);
|
||||
}
|
||||
LOG.debug("SEND >> " + m);
|
||||
for (NotebookSocket conn : socketsToBroadcast) {
|
||||
try {
|
||||
conn.send(serializeMessage(m));
|
||||
} catch (IOException e) {
|
||||
LOG.error("socket error", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void broadcastExcept(String noteId, Message m, NotebookSocket exclude) {
|
||||
List<NotebookSocket> socketsToBroadcast;
|
||||
synchronized (noteSocketMap) {
|
||||
broadcastToWatchers(noteId, StringUtils.EMPTY, m);
|
||||
List<NotebookSocket> socketLists = noteSocketMap.get(noteId);
|
||||
if (socketLists == null || socketLists.size() == 0) {
|
||||
return;
|
||||
}
|
||||
LOG.debug("SEND >> " + m);
|
||||
for (NotebookSocket conn : socketLists) {
|
||||
if (exclude.equals(conn)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
conn.send(serializeMessage(m));
|
||||
} catch (IOException e) {
|
||||
LOG.error("socket error", e);
|
||||
}
|
||||
socketsToBroadcast = new ArrayList<>(socketLists);
|
||||
}
|
||||
|
||||
LOG.debug("SEND >> " + m);
|
||||
for (NotebookSocket conn : socketsToBroadcast) {
|
||||
if (exclude.equals(conn)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
conn.send(serializeMessage(m));
|
||||
} catch (IOException e) {
|
||||
LOG.error("socket error", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue