com.twosigma.beakerx.message.Header.getSession()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中com.twosigma.beakerx.message.Header.getSession()方法的一些代码示例,展示了Header.getSession()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Header.getSession()方法的具体详情如下:
包路径:com.twosigma.beakerx.message.Header
类名称:Header
方法名:getSession

Header.getSession介绍

暂无

代码示例

代码示例来源:origin: twosigma/beakerx

protected Message createReplyMessage(Message message, Serializable responceData) {
 Message ret = null;
 if (message != null) {
  ret = new Message(new Header(COMM_MSG, message.getHeader().getSession()));
  Map<String, Serializable> commMap = message.getContent();
  HashMap<String, Serializable> map = new HashMap<>();
  map.put(COMM_ID, getString(commMap, COMM_ID));
  map.put(DATA, responceData);
  ret.setContent(map);
 }
 return ret;
}

代码示例来源:origin: twosigma/beakerx

private void handleMsg(Message message) {
 logger.debug("Processing CommInfoHandler");
 Message reply = new Message(new Header(COMM_INFO_REPLY, message.getHeader().getSession()));
 HashMap<String, Serializable> content = new HashMap<>();
 content.put(COMMS, new HashMap<String, Serializable>());
 String target = getMessageTarget(message);
 kernel.getCommHashSet().stream()
     .map(hash -> kernel.getComm(hash))
     .filter(comm -> target == null || target.isEmpty() || comm.getTargetName().equals(target))
     .forEach(comm -> {
      HashMap<String, Serializable> commRepDetails = new HashMap<>();
      commRepDetails.put(TARGET_NAME, comm.getTargetName());
      ((HashMap<String, Serializable>) content.get(COMMS)).put(comm.getCommId(), commRepDetails);
     });
 reply.setContent(content);
 reply.setParentHeader(message.getHeader());
 reply.setIdentities(message.getIdentities());
 send(reply);
}

代码示例来源:origin: twosigma/beakerx

private Message createMsg(Message message, int cursorPos, AutocompleteResult autocomplete) {
  Message reply = new Message(new Header(COMPLETE_REPLY, message.getHeader().getSession()));
  reply.setIdentities(message.getIdentities());
  reply.setParentHeader(message.getHeader());
  Map<String, Serializable> content = new HashMap<>();
  content.put(STATUS, "ok");
  content.put(MATCHES, autocomplete.getMatches().toArray());
  content.put(CURSOR_END, cursorPos);
  content.put(CURSOR_START, autocomplete.getStartIndex());

  reply.setContent(content);
  return reply;
 }
}

代码示例来源:origin: twosigma/beakerx

private void announceTheCode(Message message, String code) {
 Message reply = new Message(new Header(EXECUTE_INPUT, message.getHeader().getSession()));
 reply.setParentHeader(message.getHeader());
 reply.setIdentities(message.getIdentities());
 Map<String, Serializable> map1 = new HashMap<>(2);
 map1.put("execution_count", executionCount);
 map1.put("code", code);
 reply.setContent(map1);
 kernel.publish(singletonList(reply));
}

代码示例来源:origin: twosigma/beakerx

private TryResult initSparkContextInShell(KernelFunctionality kernel, Message parent) {
 String addSc = String.format(("import com.twosigma.beakerx.widget.SparkVariable\n" +
         "val %s = SparkVariable.getSparkSession()\n" +
         "val %s = %s.sparkContext\n" +
         "import org.apache.spark.SparkContext._\n" +
         "import %s.implicits._\n" +
         "import %s.sql\n" +
         "import org.apache.spark.sql.functions._\n"),
     SPARK_SESSION_NAME, SPARK_CONTEXT_NAME, SPARK_SESSION_NAME, SPARK_SESSION_NAME, SPARK_SESSION_NAME);
 SimpleEvaluationObject seo = createSimpleEvaluationObject(addSc, kernel, new Message(new Header(JupyterMessages.COMM_MSG, parent.getHeader().getSession())), 1);
 return kernel.executeCode(addSc, seo);
}

代码示例来源:origin: twosigma/beakerx

private Message createMsg(Message message, InspectResult inspectResult) {
    Message reply = new Message(new Header(INSPECT_REPLY, message.getHeader().getSession()));
    reply.setIdentities(message.getIdentities());
    reply.setParentHeader(message.getHeader());
    Map<String, Serializable> content = new HashMap<>();
    content.put(STATUS, "ok");
    content.put(DATA, inspectResult.getData());
    //content.put(METADATA, {});
    content.put(FOUND, inspectResult.getFound());

    reply.setContent(content);
    return reply;
  }
}

代码示例来源:origin: twosigma/beakerx

@Test
 public void serializeConfig_createConfigWithProperties() {
  //when
  Header header = MessageSerializer.parse(srcJson, Header.class);
  //then
  Assertions.assertThat(header.getVersion()).isEqualTo("5.0");
  Assertions.assertThat(header.getType()).isEqualTo("execute_request");
  Assertions.assertThat(header.getId()).isEqualTo("9CEE9EE3351643CD83A6C2A29401A942");
  Assertions.assertThat(header.getUsername()).isEqualTo("username");
  Assertions.assertThat(header.getSession()).isEqualTo("605DC3793F6F402698418908DBC7C572");
 }
}

代码示例来源:origin: twosigma/beakerx

private void handleMsg(Message message) {
  logger.debug("Processing is complete request");
  Message reply = new Message(new Header(IS_COMPLETE_REPLY, message.getHeader().getSession()));
  HashMap<String, Serializable> map = new HashMap<>();
  map.put("status", "complete");
  reply.setContent(map);
  reply.setParentHeader(message.getHeader());
  reply.setIdentities(message.getIdentities());
  send(reply);
 }
}

代码示例来源:origin: twosigma/beakerx

@Test
public void handleMessage_firstSentMessageHasSessionId() throws Exception {
 //given
 String expectedSessionId = message.getHeader().getSession();
 //when
 commMsgHandler.handle(message);
 //then
 Assertions.assertThat(kernel.getPublishedMessages()).isNotEmpty();
 Message publishMessage = kernel.getPublishedMessages().get(0);
 Assertions.assertThat(publishMessage.getHeader().getSession()).isEqualTo(expectedSessionId);
}

代码示例来源:origin: twosigma/beakerx

@Test
public void handleMessage_sentMessageHasSessionId() throws Exception {
 //given
 String expectedSessionId = message.getHeader().getSession();
 //when
 commInfoHandler.handle(message);
 //then
 Assertions.assertThat(kernel.getSentMessages()).isNotEmpty();
 Message sendMessage = kernel.getSentMessages().get(0);
 Assertions.assertThat(sendMessage.getHeader().getSession()).isEqualTo(expectedSessionId);
}

代码示例来源:origin: twosigma/beakerx

@Test
public void handleMessage_secondSentMessageHasSessionId() throws Exception {
 //given
 String expectedSessionId = message.getHeader().getSession();
 //when
 commMsgHandler.handle(message);
 //then
 Assertions.assertThat(kernel.getPublishedMessages()).isNotEmpty();
 Message publishMessage = kernel.getPublishedMessages().get(1);
 Assertions.assertThat(publishMessage.getHeader().getSession()).isEqualTo(expectedSessionId);
}

代码示例来源:origin: twosigma/beakerx

@Test
public void handleMessage_sentMessageHasSessionId() throws Exception {
 //given
 String expectedSessionId = message.getHeader().getSession();
 //when
 commCloseHandler.handle(message);
 //then
 Assertions.assertThat(kernel.getSentMessages()).isNotEmpty();
 Message sendMessage = kernel.getSentMessages().get(0);
 Assertions.assertThat(sendMessage.getHeader().getSession()).isEqualTo(expectedSessionId);
}

代码示例来源:origin: twosigma/beakerx

private TryResult addImplicits(Message parent, String codeToExecute) {
 SimpleEvaluationObject seo = createSimpleEvaluationObject(
     codeToExecute,
     kernel,
     new Message(new Header(JupyterMessages.COMM_MSG, parent.getHeader().getSession())),
     1);
 return kernel.executeCode(codeToExecute, seo);
}

代码示例来源:origin: twosigma/beakerx

@Test
public void handleMessage_firstSentMessageHasSessionId() throws Exception {
 //given
 String expectedSessionId = message.getHeader().getSession();
 //when
 executeRequestHandler.handle(message);
 waitForIdleMessage(kernel);
 //then
 assertThat(kernel.getPublishedMessages()).isNotEmpty();
 Message publishMessage = kernel.getPublishedMessages().get(0);
 assertThat(publishMessage.getHeader().getSession()).isEqualTo(expectedSessionId);
}

代码示例来源:origin: twosigma/beakerx

@Test
public void handleMessage_secondSentMessageHasSessionId() throws Exception {
 //given
 String expectedSessionId = message.getHeader().getSession();
 //when
 executeRequestHandler.handle(message);
 waitForIdleMessage(kernel);
 //then
 assertThat(kernel.getPublishedMessages()).isNotEmpty();
 Message publishMessage = kernel.getPublishedMessages().get(1);
 assertThat(publishMessage.getHeader().getSession()).isEqualTo(expectedSessionId);
}

代码示例来源:origin: twosigma/beakerx

private void handleMsg(Message message) {
 logger.debug("Processing kernel info request");
 Message reply = new Message(new Header(KERNEL_INFO_REPLY, message.getHeader().getSession()));
 reply.setContent(content());
 reply.setParentHeader(message.getHeader());
 reply.setIdentities(message.getIdentities());
 send(reply);
}

代码示例来源:origin: twosigma/beakerx

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(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);
 }
}

代码示例来源:origin: twosigma/beakerx

private static Message initMessage(JupyterMessages type, Message message) {
 Message reply = new Message(new Header(type, message.getHeader().getSession()));
 reply.setParentHeader(message.getHeader());
 reply.setIdentities(message.getIdentities());
 return reply;
}

代码示例来源:origin: twosigma/beakerx

private void handleControlMsg() {
 Message message = readMessage(controlSocket);
 JupyterMessages type = message.getHeader().getTypeEnum();
 if (type.equals(SHUTDOWN_REQUEST)) {
  Message reply = new Message(new Header(SHUTDOWN_REPLY, message.getHeader().getSession()));
  reply.setParentHeader(message.getHeader());
  reply.setContent(message.getContent());
  sendMsg(controlSocket, Collections.singletonList(reply));
  shutdown();
 }
}

代码示例来源:origin: twosigma/beakerx

public static Message messageMessage(JupyterMessages type, Buffer buffer, Map<String, Serializable> content, Message parentMessage) {
 Message message = new Message(new Header(type, parentMessage.getHeader().getSession()));
 checkNotNull(parentMessage);
 message.setParentHeader(parentMessage.getHeader());
 message.setContent(content);
 message.setMetadata(buildMetadata());
 if (!buffer.isEmpty()) {
  message.setBuffers(buffer.getBuffers());
 }
 return message;
}

相关文章