use of org.apache.zeppelin.client.ClientConfig in project zeppelin by apache.
the class ZeppelinClientExample2 method main.
public static void main(String[] args) throws Exception {
ClientConfig clientConfig = new ClientConfig("http://localhost:8080");
ZeppelinClient zClient = new ZeppelinClient(clientConfig);
String zeppelinVersion = zClient.getVersion();
System.out.println("Zeppelin version: " + zeppelinVersion);
// execute note 2A94M5J1Z paragraph by paragraph
try {
ParagraphResult paragraphResult = zClient.executeParagraph("2A94M5J1Z", "20150210-015259_1403135953");
System.out.println("Execute the 1st spark tutorial paragraph, paragraph result: " + paragraphResult);
paragraphResult = zClient.executeParagraph("2A94M5J1Z", "20150210-015302_1492795503");
System.out.println("Execute the 2nd spark tutorial paragraph, paragraph result: " + paragraphResult);
Map<String, String> parameters = new HashMap<>();
parameters.put("maxAge", "40");
paragraphResult = zClient.executeParagraph("2A94M5J1Z", "20150212-145404_867439529", parameters);
System.out.println("Execute the 3rd spark tutorial paragraph, paragraph result: " + paragraphResult);
parameters = new HashMap<>();
parameters.put("marital", "married");
paragraphResult = zClient.executeParagraph("2A94M5J1Z", "20150213-230422_1600658137", parameters);
System.out.println("Execute the 4th spark tutorial paragraph, paragraph result: " + paragraphResult);
} finally {
// you need to stop interpreter explicitly if you are running paragraph separately.
zClient.stopInterpreter("2A94M5J1Z", "spark");
}
// execute this whole note, this note will run under a didicated interpreter process which will be
// stopped after note execution.
Map<String, String> parameters = new HashMap<>();
parameters.put("maxAge", "40");
parameters.put("marital", "married");
NoteResult noteResult = zClient.executeNote("2A94M5J1Z", parameters);
System.out.println("Execute the spark tutorial note, note result: " + noteResult);
}
use of org.apache.zeppelin.client.ClientConfig in project zeppelin by apache.
the class FlinkAdvancedExample method main.
public static void main(String[] args) {
ZSession session = null;
try {
ClientConfig clientConfig = new ClientConfig("http://localhost:8080");
Map<String, String> intpProperties = new HashMap<>();
session = ZSession.builder().setClientConfig(clientConfig).setInterpreter("flink").setIntpProperties(intpProperties).build();
// if MessageHandler is specified, then websocket is enabled.
// you can get continuous output from Zeppelin via websocket.
session.start(new SimpleMessageHandler());
System.out.println("Flink Web UI: " + session.getWeburl());
String code = "benv.fromElements(1,2,3,4,5,6,7,8,9,10).map(e=> {Thread.sleep(1000); e}).print()";
System.out.println("Submit code: " + code);
// use submit to run flink code in non-blocking way.
ExecuteResult result = session.submit(code);
System.out.println("Job status: " + result.getStatus());
while (!result.getStatus().isCompleted()) {
result = session.queryStatement(result.getStatementId());
System.out.println("Job status: " + result.getStatus() + ", progress: " + result.getProgress());
Thread.sleep(1000);
}
System.out.println("Job status: " + result.getStatus() + ", data: " + result.getResults().get(0).getData());
System.out.println("-----------------------------------------------------------------------------");
System.out.println("Submit code: " + code);
result = session.submit("benv.fromElements(1,2,3,4,5,6,7,8,9,10).map(e=> {Thread.sleep(1000); e}).print()");
System.out.println("Job status: " + result.getStatus());
result = session.waitUntilFinished(result.getStatementId());
System.out.println("Job status: " + result.getStatus() + ", data: " + result.getResults().get(0).getData());
System.out.println("-----------------------------------------------------------------------------");
code = "for(i <- 1 to 10) {\n" + " Thread.sleep(1000)\n" + " println(i)\n" + "}";
System.out.println("Submit code: " + code);
result = session.execute(code);
System.out.println("Job status: " + result.getStatus() + ", data: " + result.getResults().get(0).getData());
System.out.println("-----------------------------------------------------------------------------");
String initCode = IOUtils.toString(FlinkAdvancedExample.class.getResource("/init_stream.scala"));
result = session.execute(initCode);
System.out.println("Job status: " + result.getStatus() + ", data: " + result.getResults().get(0).getData());
// run flink ssql
Map<String, String> localProperties = new HashMap<>();
localProperties.put("type", "update");
result = session.submit("ssql", localProperties, "select url, count(1) as pv from log group by url");
session.waitUntilFinished(result.getStatementId());
result = session.submit("ssql", localProperties, "select url, count(1) as pv from log group by url");
session.waitUntilRunning(result.getStatementId());
Thread.sleep(10 * 1000);
System.out.println("Try to cancel statement: " + result.getStatementId());
session.cancel(result.getStatementId());
session.waitUntilFinished(result.getStatementId());
System.out.println("Job status: " + result.getStatus());
} catch (Exception e) {
e.printStackTrace();
} finally {
if (session != null) {
try {
session.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
use of org.apache.zeppelin.client.ClientConfig in project zeppelin by apache.
the class ZeppelinClientWithAuthIntegrationTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_HELIUM_REGISTRY.getVarName(), "helium");
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_ALLOWED_ORIGINS.getVarName(), "*");
AbstractTestRestApi.startUpWithAuthenticationEnable(ZeppelinClientWithAuthIntegrationTest.class.getSimpleName());
notebook = TestUtils.getInstance(Notebook.class);
clientConfig = new ClientConfig("http://localhost:8080");
zeppelinClient = new ZeppelinClient(clientConfig);
}
Aggregations