use of org.apache.zeppelin.notebook.repo.zeppelinhub.websocket.protocol.ZeppelinhubMessage in project zeppelin by apache.
the class ZeppelinhubClient method forwardToZeppelin.
@SuppressWarnings("unchecked")
private void forwardToZeppelin(Message.OP op, ZeppelinhubMessage hubMsg) {
Message zeppelinMsg = new Message(op);
if (!(hubMsg.data instanceof Map)) {
LOG.error("Data field of message from ZeppelinHub isn't in correct Map format");
return;
}
zeppelinMsg.data = (Map<String, Object>) hubMsg.data;
Client client = Client.getInstance();
if (client == null) {
LOG.warn("Base client isn't initialized, returning");
return;
}
client.relayToZeppelin(zeppelinMsg, hubMsg.meta.get("noteId"));
}
use of org.apache.zeppelin.notebook.repo.zeppelinhub.websocket.protocol.ZeppelinhubMessage in project zeppelin by apache.
the class ZeppelinClient method handleMsgFromZeppelin.
public void handleMsgFromZeppelin(String message, String noteId) {
Map<String, String> meta = new HashMap<>();
meta.put("token", zeppelinhubToken);
meta.put("noteId", noteId);
Message zeppelinMsg = deserialize(message);
if (zeppelinMsg == null) {
return;
}
ZeppelinhubMessage hubMsg = ZeppelinhubMessage.newMessage(zeppelinMsg, meta);
Client client = Client.getInstance();
if (client == null) {
LOG.warn("Client isn't initialized yet");
return;
}
client.relayToZeppelinHub(hubMsg.serialize());
}
use of org.apache.zeppelin.notebook.repo.zeppelinhub.websocket.protocol.ZeppelinhubMessage in project zeppelin by apache.
the class ZeppelinhubClient method handleMsgFromZeppelinHub.
public void handleMsgFromZeppelinHub(String message) {
ZeppelinhubMessage hubMsg = ZeppelinhubMessage.deserialize(message);
if (hubMsg.equals(ZeppelinhubMessage.EMPTY)) {
LOG.error("Cannot handle ZeppelinHub message is empty");
return;
}
String op = StringUtils.EMPTY;
if (hubMsg.op instanceof String) {
op = (String) hubMsg.op;
} else {
LOG.error("Message OP from ZeppelinHub isn't string {}", hubMsg.op);
return;
}
if (ZeppelinhubUtils.isZeppelinHubOp(op)) {
handleZeppelinHubOpMsg(ZeppelinhubUtils.toZeppelinHubOp(op), hubMsg, message);
} else if (ZeppelinhubUtils.isZeppelinOp(op)) {
forwardToZeppelin(ZeppelinhubUtils.toZeppelinOp(op), hubMsg);
}
}
Aggregations