Search in sources :

Example 1 with Comm

use of com.twosigma.beakerx.kernel.comm.Comm in project beakerx by twosigma.

the class CommOpenHandler method handleMsg.

private void handleMsg(Message message) {
    logger.debug("Processing CommOpenHandler");
    Message reply = new Message();
    HashMap<String, Serializable> map = new HashMap<>(6);
    Map<String, Serializable> commMap = message.getContent();
    Comm newComm = null;
    if (isValidMessage(commMap)) {
        newComm = readComm(commMap);
        reply.setHeader(new Header(COMM_OPEN, message.getHeader().getSession()));
        map.put(COMM_ID, newComm.getCommId());
        map.put(TARGET_NAME, newComm.getTargetName());
        map.put(DATA, new HashMap<>());
        map.put(TARGET_MODULE, newComm.getTargetModule());
    } else {
        reply.setHeader(new Header(COMM_CLOSE, message.getHeader().getSession()));
        map.put(DATA, new HashMap<>());
    }
    if (newComm != null) {
        logger.debug("Comm opened, target name = " + newComm.getTargetName());
        for (Handler<Message> handler : getKernelControlChanelHandlers(newComm.getTargetName())) {
            newComm.addMsgCallbackList(handler);
        }
        kernel.addComm(newComm.getCommId(), newComm);
    }
    reply.setContent(map);
    reply.setParentHeader(message.getHeader());
    reply.setIdentities(message.getIdentities());
    send(reply);
}
Also used : Serializable(java.io.Serializable) Message(com.twosigma.beakerx.message.Message) Header(com.twosigma.beakerx.message.Header) HashMap(java.util.HashMap) Comm(com.twosigma.beakerx.kernel.comm.Comm)

Example 2 with Comm

use of com.twosigma.beakerx.kernel.comm.Comm in project beakerx by twosigma.

the class NamespaceClient method set.

public synchronized Object set(String name, Object value) throws IOException {
    Comm c = getAutotranslationComm();
    HashMap<String, Serializable> data = new HashMap<>();
    HashMap<String, Serializable> state = new HashMap<>();
    state.put("name", name);
    state.put("value", getJson(value));
    state.put("sync", true);
    data.put("state", state);
    data.put("buffer_paths", new HashMap<>());
    c.send(COMM_MSG, Comm.Buffer.EMPTY, new Comm.Data(data));
    return value;
}
Also used : Serializable(java.io.Serializable) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Comm(com.twosigma.beakerx.kernel.comm.Comm)

Example 3 with Comm

use of com.twosigma.beakerx.kernel.comm.Comm in project beakerx by twosigma.

the class NamespaceClient method runByTag.

public synchronized void runByTag(String tag) {
    Comm c = getTagRunComm();
    HashMap<String, Serializable> data = new HashMap<>();
    HashMap<String, Serializable> state = new HashMap<>();
    state.put("runByTag", tag);
    data.put("state", state);
    data.put("buffer_paths", new HashMap<>());
    c.send(COMM_MSG, Comm.Buffer.EMPTY, new Comm.Data(data));
}
Also used : Serializable(java.io.Serializable) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Comm(com.twosigma.beakerx.kernel.comm.Comm)

Example 4 with Comm

use of com.twosigma.beakerx.kernel.comm.Comm in project beakerx by twosigma.

the class NamespaceClient method getCodeCellsComm.

protected Comm getCodeCellsComm() {
    if (codeCellsComm == null) {
        codeCellsComm = new Comm(TargetNamesEnum.BEAKER_GETCODECELLS);
        codeCellsComm.open();
    }
    return codeCellsComm;
}
Also used : Comm(com.twosigma.beakerx.kernel.comm.Comm)

Example 5 with Comm

use of com.twosigma.beakerx.kernel.comm.Comm in project beakerx by twosigma.

the class NamespaceClient method getTagRunComm.

protected Comm getTagRunComm() {
    if (tagRunComm == null) {
        tagRunComm = new Comm(TargetNamesEnum.BEAKER_TAG_RUN);
        tagRunComm.open();
    }
    return tagRunComm;
}
Also used : Comm(com.twosigma.beakerx.kernel.comm.Comm)

Aggregations

Comm (com.twosigma.beakerx.kernel.comm.Comm)13 Serializable (java.io.Serializable)7 HashMap (java.util.HashMap)5 Message (com.twosigma.beakerx.message.Message)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 KernelTest (com.twosigma.beakerx.KernelTest)2 Header (com.twosigma.beakerx.message.Header)2 Map (java.util.Map)2 KernelHandler (com.twosigma.beakerx.handler.KernelHandler)1 KernelHandlerWrapper.wrapBusyIdle (com.twosigma.beakerx.handler.KernelHandlerWrapper.wrapBusyIdle)1 JupyterHandlerTest (com.twosigma.beakerx.jupyter.handler.JupyterHandlerTest)1 SimpleEvaluationObject (com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)1 KernelFunctionality (com.twosigma.beakerx.kernel.KernelFunctionality)1 COMMS (com.twosigma.beakerx.kernel.comm.Comm.COMMS)1 TARGET_NAME (com.twosigma.beakerx.kernel.comm.Comm.TARGET_NAME)1 COMM_INFO_REPLY (com.twosigma.beakerx.kernel.msg.JupyterMessages.COMM_INFO_REPLY)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Before (org.junit.Before)1 Test (org.junit.Test)1