Search in sources :

Example 11 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class Comm method messageMessage.

public static Message messageMessage(JupyterMessages type, Buffer buffer, Map<String, Serializable> content, Message parentMessage) {
    Message message = new Message();
    message.setHeader(new Header(type, parentMessage != null ? parentMessage.getHeader().getSession() : null));
    if (parentMessage != null) {
        message.setParentHeader(parentMessage.getHeader());
    }
    message.setContent(content);
    message.setMetadata(buildMetadata());
    if (!buffer.isEmpty()) {
        message.setBuffers(buffer.getBuffers());
    }
    return message;
}
Also used : Message(com.twosigma.beakerx.message.Message) Header(com.twosigma.beakerx.message.Header)

Example 12 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class Comm method sendUpdate.

public void sendUpdate(final String propertyName, final Object value) {
    Message message = createUpdateMessage(propertyName, value);
    kernel.publish(singletonList(message));
}
Also used : Message(com.twosigma.beakerx.message.Message)

Example 13 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class Comm method close.

public void close() {
    Message parentMessage = getParentMessage();
    if (this.getCloseCallbackList() != null && !this.getCloseCallbackList().isEmpty()) {
        for (Handler<Message> handler : getCloseCallbackList()) {
            handler.handle(parentMessage);
        }
    }
    Message message = new Message();
    message.setHeader(new Header(COMM_CLOSE, parentMessage != null ? parentMessage.getHeader().getSession() : null));
    if (parentMessage != null) {
        message.setParentHeader(parentMessage.getHeader());
    }
    HashMap<String, Serializable> map = new HashMap<>();
    map.put(COMM_ID, getCommId());
    map.put(DATA, new HashMap<>());
    map.put(METADATA, new HashMap<>());
    message.setContent(map);
    message.setMetadata(buildMetadata());
    kernel.removeComm(getCommId());
    kernel.publish(singletonList(message));
}
Also used : Serializable(java.io.Serializable) Message(com.twosigma.beakerx.message.Message) Header(com.twosigma.beakerx.message.Header) HashMap(java.util.HashMap)

Example 14 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class CommCloseHandler method handleMsg.

private void handleMsg(Message message) {
    logger.debug("Processing CommCloseHandler");
    Map<String, Serializable> commMap = message.getContent();
    String targetName = (kernel.getComm(getString(commMap, COMM_ID)) != null) ? kernel.getComm(getString(commMap, COMM_ID)).getTargetName() : "";
    kernel.removeComm(getString(commMap, COMM_ID));
    Message reply = new Message();
    reply.setHeader(new Header(COMM_CLOSE, message.getHeader().getSession()));
    HashMap<String, Serializable> map = new HashMap<>();
    map.put(DATA, new HashMap<>());
    reply.setContent(map);
    reply.setParentHeader(message.getHeader());
    reply.setIdentities(message.getIdentities());
    send(reply);
    logger.debug("Comm closed, target name = " + targetName);
}
Also used : Serializable(java.io.Serializable) Message(com.twosigma.beakerx.message.Message) Header(com.twosigma.beakerx.message.Header) HashMap(java.util.HashMap)

Example 15 with Message

use of com.twosigma.beakerx.message.Message in project beakerx by twosigma.

the class ExecuteRequestHandler method announceTheCode.

private void announceTheCode(Message message, String code) {
    Message reply = new Message();
    reply.setParentHeader(message.getHeader());
    reply.setIdentities(message.getIdentities());
    reply.setHeader(new Header(EXECUTE_INPUT, message.getHeader().getSession()));
    Map<String, Serializable> map1 = new HashMap<>(2);
    map1.put("execution_count", executionCount);
    map1.put("code", code);
    reply.setContent(map1);
    kernel.publish(singletonList(reply));
}
Also used : Serializable(java.io.Serializable) Message(com.twosigma.beakerx.message.Message) Header(com.twosigma.beakerx.message.Header) HashMap(java.util.HashMap)

Aggregations

Message (com.twosigma.beakerx.message.Message)270 Test (org.junit.Test)170 KernelTest (com.twosigma.beakerx.KernelTest)121 EvaluatorResultTestWatcher.waitForIdleMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForIdleMessage)64 EvaluatorTest (com.twosigma.beakerx.evaluator.EvaluatorTest)57 Code (com.twosigma.beakerx.kernel.Code)55 Serializable (java.io.Serializable)36 MessageFactoryTest.getExecuteRequestMessage (com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage)35 EvaluatorResultTestWatcher.waitForErrorMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForErrorMessage)28 MessageTest (com.twosigma.beakerx.message.MessageTest)27 Map (java.util.Map)26 HashMap (java.util.HashMap)24 Header (com.twosigma.beakerx.message.Header)23 MessageAssertions.verifyExecuteReplyMessage (com.twosigma.MessageAssertions.verifyExecuteReplyMessage)19 EvaluatorResultTestWatcher.waitForSentMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForSentMessage)19 PlainCode (com.twosigma.beakerx.kernel.PlainCode)14 KernelExecutionTest (com.twosigma.beakerx.KernelExecutionTest)13 EvaluatorResultTestWatcher.waitForUpdateMessage (com.twosigma.beakerx.evaluator.EvaluatorResultTestWatcher.waitForUpdateMessage)13 LinkedHashMap (java.util.LinkedHashMap)12 SimpleEvaluationObject (com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)11