当前位置: 首页>>代码示例>>Java>>正文


Java ZeppelinServer类代码示例

本文整理汇总了Java中org.apache.zeppelin.server.ZeppelinServer的典型用法代码示例。如果您正苦于以下问题:Java ZeppelinServer类的具体用法?Java ZeppelinServer怎么用?Java ZeppelinServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ZeppelinServer类属于org.apache.zeppelin.server包,在下文中一共展示了ZeppelinServer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: basicRDDTransformationAndActionTest

import org.apache.zeppelin.server.ZeppelinServer; //导入依赖的package包/类
@Test
public void basicRDDTransformationAndActionTest() throws IOException {
  // create new note
  Note note = ZeppelinServer.notebook.createNote();

  // run markdown paragraph, again
  Paragraph p = note.addParagraph();
  Map config = p.getConfig();
  config.put("enabled", true);
  p.setConfig(config);
  p.setText("%spark print(sc.parallelize(1 to 10).reduce(_ + _))");
  note.run(p.getId());
  waitForFinish(p);
  assertEquals(Status.FINISHED, p.getStatus());
  assertEquals("55", p.getResult().message());
  ZeppelinServer.notebook.removeNote(note.id());
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:18,代码来源:ZeppelinSparkClusterTest.java

示例2: pySparkTest

import org.apache.zeppelin.server.ZeppelinServer; //导入依赖的package包/类
@Test
public void pySparkTest() throws IOException {
  // create new note
  Note note = ZeppelinServer.notebook.createNote();
  int sparkVersion = getSparkVersionNumber(note);

  if (isPyspark() && sparkVersion >= 12) {   // pyspark supported from 1.2.1
    // run markdown paragraph, again
    Paragraph p = note.addParagraph();
    Map config = p.getConfig();
    config.put("enabled", true);
    p.setConfig(config);
    p.setText("%pyspark print(sc.parallelize(range(1, 11)).reduce(lambda a, b: a + b))");
    note.run(p.getId());
    waitForFinish(p);
    assertEquals(Status.FINISHED, p.getStatus());
    assertEquals("55\n", p.getResult().message());
  }
  ZeppelinServer.notebook.removeNote(note.id());
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:21,代码来源:ZeppelinSparkClusterTest.java

示例3: pySparkAutoConvertOptionTest

import org.apache.zeppelin.server.ZeppelinServer; //导入依赖的package包/类
@Test
public void pySparkAutoConvertOptionTest() throws IOException {
  // create new note
  Note note = ZeppelinServer.notebook.createNote();

  int sparkVersion = getSparkVersionNumber(note);

  if (isPyspark() && sparkVersion >= 14) {   // auto_convert enabled from spark 1.4
    // run markdown paragraph, again
    Paragraph p = note.addParagraph();
    Map config = p.getConfig();
    config.put("enabled", true);
    p.setConfig(config);
    p.setText("%pyspark\nfrom pyspark.sql.functions import *\n"
        + "print(sqlContext.range(0, 10).withColumn('uniform', rand(seed=10) * 3.14).count())");
    note.run(p.getId());
    waitForFinish(p);
    assertEquals(Status.FINISHED, p.getStatus());
    assertEquals("10\n", p.getResult().message());
  }
  ZeppelinServer.notebook.removeNote(note.id());
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:23,代码来源:ZeppelinSparkClusterTest.java

示例4: testInterpreterAutoBinding

import org.apache.zeppelin.server.ZeppelinServer; //导入依赖的package包/类
@Test
public void testInterpreterAutoBinding() throws IOException {
  // create note
  Note note = ZeppelinServer.notebook.createNote();

  // check interpreter is binded
  GetMethod get = httpGet("/notebook/interpreter/bind/"+note.id());
  assertThat(get, isAllowed());
  get.addRequestHeader("Origin", "http://localhost");
  Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(), new TypeToken<Map<String, Object>>(){}.getType());
  List<Map<String, String>> body = (List<Map<String, String>>) resp.get("body");
  assertTrue(0 < body.size());

  get.releaseConnection();
  //cleanup
  ZeppelinServer.notebook.removeNote(note.getId());
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:18,代码来源:ZeppelinRestApiTest.java

示例5: testRegressionZEPPELIN_527

import org.apache.zeppelin.server.ZeppelinServer; //导入依赖的package包/类
@Test
public void testRegressionZEPPELIN_527() throws IOException {
  Note note = ZeppelinServer.notebook.createNote();

  note.setName("note for run test");
  Paragraph paragraph = note.addParagraph();
  paragraph.setText("%spark\nval param = z.input(\"param\").toString\nprintln(param)");

  note.persist();

  GetMethod getNoteJobs = httpGet("/notebook/job/" + note.getId());
  assertThat("test notebook jobs run:", getNoteJobs, isAllowed());
  Map<String, Object> resp = gson.fromJson(getNoteJobs.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {
  }.getType());
  List<Map<String, String>> body = (List<Map<String, String>>) resp.get("body");
  assertFalse(body.get(0).containsKey("started"));
  assertFalse(body.get(0).containsKey("finished"));
  getNoteJobs.releaseConnection();

  ZeppelinServer.notebook.removeNote(note.getId());
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:22,代码来源:ZeppelinRestApiTest.java

示例6: testDeleteParagraph

import org.apache.zeppelin.server.ZeppelinServer; //导入依赖的package包/类
@Test
public void testDeleteParagraph() throws IOException {
  Note note = ZeppelinServer.notebook.createNote();

  Paragraph p = note.addParagraph();
  p.setTitle("title1");
  p.setText("text1");

  note.persist();

  DeleteMethod delete = httpDelete("/notebook/" + note.getId() + "/paragraph/" + p.getId());
  assertThat("Test delete method: ", delete, isAllowed());
  delete.releaseConnection();

  Note retrNote = ZeppelinServer.notebook.getNote(note.getId());
  Paragraph retrParagrah = retrNote.getParagraph(p.getId());
  assertNull("paragraph should be deleted", retrParagrah);

  ZeppelinServer.notebook.removeNote(note.getId());
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:21,代码来源:ZeppelinRestApiTest.java

示例7: scalaOutputTest

import org.apache.zeppelin.server.ZeppelinServer; //导入依赖的package包/类
@Test
public void scalaOutputTest() throws IOException {
    // create new note
    Note note = ZeppelinServer.notebook.createNote(anonymous);
    Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
    Map config = p.getConfig();
    config.put("enabled", true);
    p.setConfig(config);
    p.setText("%spark import java.util.Date\n" +
        "import java.net.URL\n" +
        "println(\"hello\")\n"
    );
    p.setAuthenticationInfo(anonymous);
    note.run(p.getId());
    waitForFinish(p);
    assertEquals(Status.FINISHED, p.getStatus());
    assertEquals("import java.util.Date\n" +
        "import java.net.URL\n" +
        "hello\n", p.getResult().message().get(0).getData());
    ZeppelinServer.notebook.removeNote(note.getId(), anonymous);
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:22,代码来源:ZeppelinSparkClusterTest.java

示例8: basicRDDTransformationAndActionTest

import org.apache.zeppelin.server.ZeppelinServer; //导入依赖的package包/类
@Test
public void basicRDDTransformationAndActionTest() throws IOException {
    // create new note
    Note note = ZeppelinServer.notebook.createNote(anonymous);

    // run markdown paragraph, again
    Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
    Map config = p.getConfig();
    config.put("enabled", true);
    p.setConfig(config);
    p.setText("%spark print(sc.parallelize(1 to 10).reduce(_ + _))");
    p.setAuthenticationInfo(anonymous);
    note.run(p.getId());
    waitForFinish(p);
    assertEquals(Status.FINISHED, p.getStatus());
    assertEquals("55", p.getResult().message().get(0).getData());
    ZeppelinServer.notebook.removeNote(note.getId(), anonymous);
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:19,代码来源:ZeppelinSparkClusterTest.java

示例9: testConfInterpreter

import org.apache.zeppelin.server.ZeppelinServer; //导入依赖的package包/类
@Test
public void testConfInterpreter() throws IOException {
    Note note = ZeppelinServer.notebook.createNote(AuthenticationInfo.ANONYMOUS);
    Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
    Map config = p.getConfig();
    config.put("enabled", true);
    p.setConfig(config);
    p.setText("%spark.conf spark.jars.packages\tcom.databricks:spark-csv_2.11:1.2.0");
    p.setAuthenticationInfo(anonymous);
    note.run(p.getId());
    waitForFinish(p);
    assertEquals(Status.FINISHED, p.getStatus());

    Paragraph p1 = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
    p1.setConfig(config);
    p1.setText("%spark\nimport com.databricks.spark.csv._");
    p1.setAuthenticationInfo(anonymous);
    note.run(p1.getId());

    waitForFinish(p1);
    assertEquals(Status.FINISHED, p1.getStatus());

    ZeppelinServer.notebook.removeNote(note.getId(), anonymous);

}
 
开发者ID:apache,项目名称:zeppelin,代码行数:26,代码来源:ZeppelinSparkClusterTest.java

示例10: setUp

import org.apache.zeppelin.server.ZeppelinServer; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
    HeliumTestRegistry registry = new HeliumTestRegistry("r1", "r1");
    ZeppelinServer.helium.clear();
    ZeppelinServer.helium.addRegistry(registry);

    registry.add(new HeliumPackage(
            HeliumType.APPLICATION,
            "name1",
            "desc1",
            "artifact1",
            "className1",
            new String[][]{},
            "",
            ""));

    registry.add(new HeliumPackage(
            HeliumType.APPLICATION,
            "name2",
            "desc2",
            "artifact2",
            "className2",
            new String[][]{},
            "",
            ""));
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:27,代码来源:HeliumRestApiTest.java

示例11: testGetAllEnabledPackageInfo

import org.apache.zeppelin.server.ZeppelinServer; //导入依赖的package包/类
@Test
public void testGetAllEnabledPackageInfo() throws IOException {
    // No enabled packages initially
    GetMethod get1 = httpGet("/helium/enabledPackage");
    assertThat(get1, isAllowed());
    Map<String, Object> resp1 = gson.fromJson(get1.getResponseBodyAsString(),
            new TypeToken<Map<String, Object>>() { }.getType());
    List<StringMap<Object>> body1 = (List<StringMap<Object>>) resp1.get("body");
    assertEquals(body1.size(), 0);

    // Enable "name1" package
    ZeppelinServer.helium.enable("name1","artifact1");

    GetMethod get2 = httpGet("/helium/enabledPackage");
    assertThat(get2, isAllowed());
    Map<String, Object> resp2 = gson.fromJson(get2.getResponseBodyAsString(),
            new TypeToken<Map<String, Object>>() { }.getType());
    List<StringMap<Object>> body2 = (List<StringMap<Object>>) resp2.get("body");

    assertEquals(body2.size(), 1);
    StringMap<Object> pkg = (StringMap<Object>) body2.get(0).get("pkg");
    assertEquals(pkg.get("name"), "name1");
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:24,代码来源:HeliumRestApiTest.java

示例12: testVisualizationPackageOrder

import org.apache.zeppelin.server.ZeppelinServer; //导入依赖的package包/类
@Test
public void testVisualizationPackageOrder() throws IOException {
    GetMethod get1 = httpGet("/helium/order/visualization");
    assertThat(get1, isAllowed());
    Map<String, Object> resp1 = gson.fromJson(get1.getResponseBodyAsString(),
            new TypeToken<Map<String, Object>>() { }.getType());
    List<Object> body1 = (List<Object>) resp1.get("body");
    assertEquals(body1.size(), 0);

    //We assume allPackages list has been refreshed before sorting
    ZeppelinServer.helium.getAllPackageInfo();

    String postRequestJson = "[name2, name1]";
    PostMethod post = httpPost("/helium/order/visualization", postRequestJson);
    assertThat(post, isAllowed());
    post.releaseConnection();

    GetMethod get2 = httpGet("/helium/order/visualization");
    assertThat(get2, isAllowed());
    Map<String, Object> resp2 = gson.fromJson(get2.getResponseBodyAsString(),
            new TypeToken<Map<String, Object>>() { }.getType());
    List<Object> body2 = (List<Object>) resp2.get("body");
    assertEquals(body2.size(), 2);
    assertEquals(body2.get(0), "name2");
    assertEquals(body2.get(1), "name1");
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:27,代码来源:HeliumRestApiTest.java

示例13: testGetNoteParagraphJobStatus

import org.apache.zeppelin.server.ZeppelinServer; //导入依赖的package包/类
@Test
public void testGetNoteParagraphJobStatus() throws IOException {
  Note note1 = ZeppelinServer.notebook.createNote(anonymous);
  note1.addNewParagraph(AuthenticationInfo.ANONYMOUS);

  String paragraphId = note1.getLastParagraph().getId();

  GetMethod get = httpGet("/notebook/job/" + note1.getId() + "/" + paragraphId);
  assertThat(get, isAllowed());
  Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {
  }.getType());
  Map<String, Set<String>> paragraphStatus = (Map<String, Set<String>>) resp.get("body");

  // Check id and status have proper value
  assertEquals(paragraphStatus.get("id"), paragraphId);
  assertEquals(paragraphStatus.get("status"), "READY");

  //cleanup
  ZeppelinServer.notebook.removeNote(note1.getId(), anonymous);

}
 
开发者ID:apache,项目名称:zeppelin,代码行数:22,代码来源:NotebookRestApiTest.java

示例14: testUpdateParagraphConfig

import org.apache.zeppelin.server.ZeppelinServer; //导入依赖的package包/类
@Test
public void testUpdateParagraphConfig() throws IOException {
  Note note = ZeppelinServer.notebook.createNote(anonymous);
  String noteId = note.getId();
  Paragraph p = note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
  assertNull(p.getConfig().get("colWidth"));
  String paragraphId = p.getId();
  String jsonRequest = "{\"colWidth\": 6.0}";

  PutMethod put = httpPut("/notebook/" + noteId + "/paragraph/" + paragraphId +"/config", jsonRequest);
  assertThat("test testUpdateParagraphConfig:", put, isAllowed());

  Map<String, Object> resp = gson.fromJson(put.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {
  }.getType());
  Map<String, Object> respBody = (Map<String, Object>) resp.get("body");
  Map<String, Object> config = (Map<String, Object>) respBody.get("config");
  put.releaseConnection();

  assertEquals(config.get("colWidth"), 6.0);
  note = ZeppelinServer.notebook.getNote(noteId);
  assertEquals(note.getParagraph(paragraphId).getConfig().get("colWidth"), 6.0);

  //cleanup
  ZeppelinServer.notebook.removeNote(noteId, anonymous);
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:26,代码来源:NotebookRestApiTest.java

示例15: testThatWriterCannotRemoveNote

import org.apache.zeppelin.server.ZeppelinServer; //导入依赖的package包/类
@Test
public void testThatWriterCannotRemoveNote() throws IOException {
  String noteId = createNoteForUser("test", "admin", "password1");
  
  //set permission
  String payload = "{ \"owners\": [\"admin\", \"user1\"], \"readers\": [\"user2\"], \"runners\": [\"user2\"], \"writers\": [\"user2\"] }";
  PutMethod put = httpPut("/notebook/" + noteId + "/permissions", payload , "admin", "password1");
  assertThat("test set note permission method:", put, isAllowed());
  put.releaseConnection();
  
  userTryRemoveNote(noteId, "user2", "password3", isForbidden());
  userTryRemoveNote(noteId, "user1", "password2", isAllowed());
  
  Note deletedNote = ZeppelinServer.notebook.getNote(noteId);
  assertNull("Deleted note should be null", deletedNote);
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:17,代码来源:NotebookSecurityRestApiTest.java


注:本文中的org.apache.zeppelin.server.ZeppelinServer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。