本文整理了Java中com.twosigma.beakerx.message.Header.<init>()
方法的一些代码示例,展示了Header.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Header.<init>()
方法的具体详情如下:
包路径:com.twosigma.beakerx.message.Header
类名称:Header
方法名:<init>
暂无
代码示例来源:origin: twosigma/beakerx
public static Message msg(JupyterMessages type) {
return new Message(new Header(type, "session1"));
}
}
代码示例来源: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
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 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
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 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
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
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 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
public static Message getExecuteRequestMessage(String code) {
Header header = new Header(JupyterMessages.COMM_MSG,"session1");
Message message = new Message(header);
header.setTypeEnum(JupyterMessages.EXECUTE_REQUEST);
HashMap<String, Serializable> content = new HashMap<>();
content.put("code", code);
message.setContent(content);
return message;
}
代码示例来源: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 createMessage() {
Header header = new Header(JupyterMessages.COMM_MSG, "session1");
Message message = new Message(header);
message.getIdentities().add("identityStr".getBytes());
message.setParentHeader(header);
message.setMetadata(new LinkedHashMap<>());
message.setContent(new LinkedHashMap<>());
return message;
}
代码示例来源:origin: twosigma/beakerx
@Before
public void setUp() {
this.kernel = new KernelTest();
sparkSupportActionOptions = new EnableSparkSupportOptionsTest.EnableSparkSupportActionMock();
EnableSparkSupportOptions enableSparkSupportOptions = new EnableSparkSupportOptions(sparkSupportActionOptions);
sut = new RunOptionsCommand(enableSparkSupportOptions, "%%spark -v " + SPARK_VERSION, new Message(new Header(JupyterMessages.COMM_MSG, "id1")));
}
代码示例来源:origin: twosigma/beakerx
@Before
public void setUp() {
this.kernel = new KernelTest();
classpath = new LoadSparkFrom_SPARK_HOME_CommandTest.BeakerXClasspathMock();
sparkSupportActionOptions = new EnableSparkSupportOptionsTest.EnableSparkSupportActionMock();
sut = new LoadLatestVersionOfSparkIfIsNotOnClasspath(classpath, sparkSupportActionOptions, new Message(new Header(JupyterMessages.COMM_MSG, "id1")));
}
代码示例来源: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;
}
代码示例来源:origin: twosigma/beakerx
@Test
public void disableHiveSupportWhenRemoveFromAvailableProperties() {
//given
HiveSupport hive = new HiveSupport("Hive");
List<Button> removeButton = new ArrayList<>();
new SparkConfiguration(
ADVANCED_SETTINGS_WITH_HIVE_SUPPORT,
SPARK_VERSION,
hive,
add,
(nameWidget, valueWidget, remove) -> {
removeButton.add(remove);
return new PropertyItem(nameWidget, valueWidget, remove);
});
//when
removeButton.get(0).onClick(new HashMap(), new Message(new Header(JupyterMessages.COMM_MSG, "s1")));
//then
assertThat(hive.getValue()).isFalse();
}
代码示例来源:origin: twosigma/beakerx
@Test
public void unresolvedDependency() {
//given
String allCode = CLASSPATH_ADD_MVN + " com.google.code.XXXX gson 2.6.2";
MagicCommand command = new MagicCommand(new ClasspathAddMvnMagicCommand(configuration.mavenResolverParam(kernel), kernel), allCode);
Code code = Code.createCode(allCode, singletonList(command), NO_ERRORS, new Message(new Header(JupyterMessages.COMM_MSG, "session1")));
//when
code.execute(kernel, 1);
//then
List<Message> stderr = EvaluatorResultTestWatcher.getStderr(kernel.getPublishedMessages());
String text = (String) stderr.get(0).getContent().get("text");
assertThat(text).contains("Could not resolve dependencies for:");
assertThat(text).contains("com.google.code.XXXX : gson : 2.6.2");
}
代码示例来源:origin: twosigma/beakerx
@Test
public void wrongCommandFormat() {
//given
String allCode = CLASSPATH_ADD_MVN + " com.google.code.XXXX gson";
MagicCommand command = new MagicCommand(new ClasspathAddMvnMagicCommand(configuration.mavenResolverParam(kernel), kernel), allCode);
Code code = Code.createCode(allCode, singletonList(command), NO_ERRORS, new Message(new Header(JupyterMessages.COMM_MSG, "session1")));
//when
code.execute(kernel, 1);
//then
List<Message> stderr = EvaluatorResultTestWatcher.getStderr(kernel.getPublishedMessages());
String text = (String) stderr.get(0).getContent().get("text");
assertThat(text).contains(ADD_MVN_FORMAT_ERROR_MESSAGE + "\n");
}
代码示例来源:origin: twosigma/beakerx
public static Header initHeader(JupyterMessages jupyterMessages) {
Header header = new Header(jupyterMessages, "sessionId" + jupyterMessages.getName());
header.setId("messageId");
header.setUsername("username");
header.setVersion("5.0");
return header;
}
内容来源于网络,如有侵权,请联系作者删除!