You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by jo...@apache.org on 2018/08/26 04:44:01 UTC
[18/49] zeppelin git commit: [ZEPPELIN-3740] Adopt
`google-java-format` and `fmt-maven-plugin`
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServerTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServerTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServerTest.java
index 9719717..fa16ace 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServerTest.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterServerTest.java
@@ -17,6 +17,16 @@
package org.apache.zeppelin.interpreter.remote;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.thrift.TException;
import org.apache.zeppelin.interpreter.Interpreter;
import org.apache.zeppelin.interpreter.InterpreterContext;
@@ -27,23 +37,17 @@ import org.apache.zeppelin.interpreter.thrift.RemoteInterpreterContext;
import org.apache.zeppelin.interpreter.thrift.RemoteInterpreterResult;
import org.junit.Test;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-
public class RemoteInterpreterServerTest {
@Test
public void testStartStop() throws InterruptedException, IOException, TException {
- RemoteInterpreterServer server = new RemoteInterpreterServer("localhost",
- RemoteInterpreterUtils.findRandomAvailablePortOnAllLocalInterfaces(), ":", "groupId", true);
+ RemoteInterpreterServer server =
+ new RemoteInterpreterServer(
+ "localhost",
+ RemoteInterpreterUtils.findRandomAvailablePortOnAllLocalInterfaces(),
+ ":",
+ "groupId",
+ true);
startRemoteInterpreterServer(server, 10 * 1000);
stopRemoteInterpreterServer(server, 10 * 10000);
@@ -51,8 +55,13 @@ public class RemoteInterpreterServerTest {
@Test
public void testStartStopWithQueuedEvents() throws InterruptedException, IOException, TException {
- RemoteInterpreterServer server = new RemoteInterpreterServer("localhost",
- RemoteInterpreterUtils.findRandomAvailablePortOnAllLocalInterfaces(), ":", "groupId", true);
+ RemoteInterpreterServer server =
+ new RemoteInterpreterServer(
+ "localhost",
+ RemoteInterpreterUtils.findRandomAvailablePortOnAllLocalInterfaces(),
+ ":",
+ "groupId",
+ true);
server.intpEventClient = mock(RemoteInterpreterEventClient.class);
startRemoteInterpreterServer(server, 10 * 1000);
@@ -72,8 +81,9 @@ public class RemoteInterpreterServerTest {
Thread.sleep(200);
}
assertEquals(true, server.isRunning());
- assertEquals(true, RemoteInterpreterUtils.checkIfRemoteEndpointAccessible("localhost",
- server.getPort()));
+ assertEquals(
+ true,
+ RemoteInterpreterUtils.checkIfRemoteEndpointAccessible("localhost", server.getPort()));
}
private void stopRemoteInterpreterServer(RemoteInterpreterServer server, int timeout)
@@ -88,14 +98,20 @@ public class RemoteInterpreterServerTest {
Thread.sleep(200);
}
assertEquals(false, server.isRunning());
- assertEquals(false, RemoteInterpreterUtils.checkIfRemoteEndpointAccessible("localhost",
- server.getPort()));
+ assertEquals(
+ false,
+ RemoteInterpreterUtils.checkIfRemoteEndpointAccessible("localhost", server.getPort()));
}
@Test
public void testInterpreter() throws IOException, TException, InterruptedException {
- final RemoteInterpreterServer server = new RemoteInterpreterServer("localhost",
- RemoteInterpreterUtils.findRandomAvailablePortOnAllLocalInterfaces(), ":", "groupId", true);
+ final RemoteInterpreterServer server =
+ new RemoteInterpreterServer(
+ "localhost",
+ RemoteInterpreterUtils.findRandomAvailablePortOnAllLocalInterfaces(),
+ ":",
+ "groupId",
+ true);
server.intpEventClient = mock(RemoteInterpreterEventClient.class);
Map<String, String> intpProperties = new HashMap<>();
@@ -103,24 +119,25 @@ public class RemoteInterpreterServerTest {
intpProperties.put("zeppelin.interpreter.localRepo", "/tmp");
// create Test1Interpreter in session_1
- server.createInterpreter("group_1", "session_1", Test1Interpreter.class.getName(),
- intpProperties, "user_1");
- Test1Interpreter interpreter1 = (Test1Interpreter)
- ((LazyOpenInterpreter) server.getInterpreterGroup().get("session_1").get(0))
- .getInnerInterpreter();
+ server.createInterpreter(
+ "group_1", "session_1", Test1Interpreter.class.getName(), intpProperties, "user_1");
+ Test1Interpreter interpreter1 =
+ (Test1Interpreter)
+ ((LazyOpenInterpreter) server.getInterpreterGroup().get("session_1").get(0))
+ .getInnerInterpreter();
assertEquals(1, server.getInterpreterGroup().getSessionNum());
assertEquals(1, server.getInterpreterGroup().get("session_1").size());
assertEquals(2, interpreter1.getProperties().size());
assertEquals("value_1", interpreter1.getProperty("property_1"));
// create Test2Interpreter in session_1
- server.createInterpreter("group_1", "session_1", Test1Interpreter.class.getName(),
- intpProperties, "user_1");
+ server.createInterpreter(
+ "group_1", "session_1", Test1Interpreter.class.getName(), intpProperties, "user_1");
assertEquals(2, server.getInterpreterGroup().get("session_1").size());
// create Test1Interpreter in session_2
- server.createInterpreter("group_1", "session_2", Test1Interpreter.class.getName(),
- intpProperties, "user_1");
+ server.createInterpreter(
+ "group_1", "session_2", Test1Interpreter.class.getName(), intpProperties, "user_1");
assertEquals(2, server.getInterpreterGroup().getSessionNum());
assertEquals(2, server.getInterpreterGroup().get("session_1").size());
assertEquals(1, server.getInterpreterGroup().get("session_2").size());
@@ -132,23 +149,26 @@ public class RemoteInterpreterServerTest {
intpContext.setNoteGui("{}");
// single output of SUCCESS
- RemoteInterpreterResult result = server.interpret("session_1", Test1Interpreter.class.getName(),
- "SINGLE_OUTPUT_SUCCESS", intpContext);
+ RemoteInterpreterResult result =
+ server.interpret(
+ "session_1", Test1Interpreter.class.getName(), "SINGLE_OUTPUT_SUCCESS", intpContext);
assertEquals("SUCCESS", result.code);
assertEquals(1, result.getMsg().size());
assertEquals("SINGLE_OUTPUT_SUCCESS", result.getMsg().get(0).getData());
// combo output of SUCCESS
- result = server.interpret("session_1", Test1Interpreter.class.getName(), "COMBO_OUTPUT_SUCCESS",
- intpContext);
+ result =
+ server.interpret(
+ "session_1", Test1Interpreter.class.getName(), "COMBO_OUTPUT_SUCCESS", intpContext);
assertEquals("SUCCESS", result.code);
assertEquals(2, result.getMsg().size());
assertEquals("INTERPRETER_OUT", result.getMsg().get(0).getData());
assertEquals("SINGLE_OUTPUT_SUCCESS", result.getMsg().get(1).getData());
// single output of ERROR
- result = server.interpret("session_1", Test1Interpreter.class.getName(), "SINGLE_OUTPUT_ERROR",
- intpContext);
+ result =
+ server.interpret(
+ "session_1", Test1Interpreter.class.getName(), "SINGLE_OUTPUT_ERROR", intpContext);
assertEquals("ERROR", result.code);
assertEquals(1, result.getMsg().size());
assertEquals("SINGLE_OUTPUT_ERROR", result.getMsg().get(0).getData());
@@ -158,16 +178,17 @@ public class RemoteInterpreterServerTest {
assertEquals("NATIVE", formType);
// cancel
- Thread sleepThread = new Thread() {
- @Override
- public void run() {
- try {
- server.interpret("session_1", Test1Interpreter.class.getName(), "SLEEP", intpContext);
- } catch (TException e) {
- e.printStackTrace();
- }
- }
- };
+ Thread sleepThread =
+ new Thread() {
+ @Override
+ public void run() {
+ try {
+ server.interpret("session_1", Test1Interpreter.class.getName(), "SLEEP", intpContext);
+ } catch (TException e) {
+ e.printStackTrace();
+ }
+ }
+ };
sleepThread.start();
Thread.sleep(1000);
@@ -176,8 +197,8 @@ public class RemoteInterpreterServerTest {
assertTrue(interpreter1.cancelled.get());
// getProgress
- assertEquals(10, server.getProgress("session_1", Test1Interpreter.class.getName(),
- intpContext));
+ assertEquals(
+ 10, server.getProgress("session_1", Test1Interpreter.class.getName(), intpContext));
// close
server.close("session_1", Test1Interpreter.class.getName());
@@ -194,9 +215,7 @@ public class RemoteInterpreterServerTest {
}
@Override
- public void open() {
-
- }
+ public void open() {}
@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
@@ -241,20 +260,16 @@ public class RemoteInterpreterServerTest {
public void close() {
closed.set(true);
}
-
}
public static class Test2Interpreter extends Interpreter {
-
public Test2Interpreter(Properties properties) {
super(properties);
}
@Override
- public void open() {
-
- }
+ public void open() {}
@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
@@ -262,9 +277,7 @@ public class RemoteInterpreterServerTest {
}
@Override
- public void cancel(InterpreterContext context) throws InterpreterException {
-
- }
+ public void cancel(InterpreterContext context) throws InterpreterException {}
@Override
public FormType getFormType() throws InterpreterException {
@@ -277,9 +290,6 @@ public class RemoteInterpreterServerTest {
}
@Override
- public void close() {
-
- }
-
+ public void close() {}
}
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterUtilsTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterUtilsTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterUtilsTest.java
index 68981da..577dd92 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterUtilsTest.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterUtilsTest.java
@@ -17,32 +17,31 @@
package org.apache.zeppelin.interpreter.remote;
-import org.junit.Test;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
-
-import static org.junit.Assert.assertTrue;
+import org.junit.Test;
public class RemoteInterpreterUtilsTest {
@Test
public void testCreateTServerSocket() throws IOException {
- assertTrue(RemoteInterpreterUtils.createTServerSocket(":")
- .getServerSocket().getLocalPort() > 0);
+ assertTrue(
+ RemoteInterpreterUtils.createTServerSocket(":").getServerSocket().getLocalPort() > 0);
String portRange = ":30000";
- assertTrue(RemoteInterpreterUtils.createTServerSocket(portRange)
- .getServerSocket().getLocalPort() <= 30000);
+ assertTrue(
+ RemoteInterpreterUtils.createTServerSocket(portRange).getServerSocket().getLocalPort()
+ <= 30000);
portRange = "30000:";
- assertTrue(RemoteInterpreterUtils.createTServerSocket(portRange)
- .getServerSocket().getLocalPort() >= 30000);
+ assertTrue(
+ RemoteInterpreterUtils.createTServerSocket(portRange).getServerSocket().getLocalPort()
+ >= 30000);
portRange = "30000:40000";
- int port = RemoteInterpreterUtils.createTServerSocket(portRange)
- .getServerSocket().getLocalPort();
+ int port =
+ RemoteInterpreterUtils.createTServerSocket(portRange).getServerSocket().getLocalPort();
assertTrue(port >= 30000 && port <= 40000);
}
-
-
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/LocalResourcePoolTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/LocalResourcePoolTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/LocalResourcePoolTest.java
index 8b42dc8..afdcfc6 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/LocalResourcePoolTest.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/LocalResourcePoolTest.java
@@ -16,16 +16,14 @@
*/
package org.apache.zeppelin.resource;
-import org.junit.Test;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-/**
- * Unittest for LocalResourcePool
- */
+import org.junit.Test;
+
+/** Unittest for LocalResourcePool */
public class LocalResourcePoolTest {
@Test
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/ResourceSetTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/ResourceSetTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/ResourceSetTest.java
index cc1cad1..23267f1 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/ResourceSetTest.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/ResourceSetTest.java
@@ -16,13 +16,11 @@
*/
package org.apache.zeppelin.resource;
-import org.junit.Test;
-
import static org.junit.Assert.assertEquals;
-/**
- * Unit test for ResourceSet
- */
+import org.junit.Test;
+
+/** Unit test for ResourceSet */
public class ResourceSetTest {
@Test
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/ResourceTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/ResourceTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/ResourceTest.java
index fb8b271..5d06c4e 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/ResourceTest.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/resource/ResourceTest.java
@@ -16,16 +16,13 @@
*/
package org.apache.zeppelin.resource;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.nio.ByteBuffer;
+import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Test for Resource
- */
+/** Test for Resource */
public class ResourceTest {
@Test
public void testSerializeDeserialize() throws IOException, ClassNotFoundException {
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/FIFOSchedulerTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/FIFOSchedulerTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/FIFOSchedulerTest.java
index 807b5ee..15bf7a5 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/FIFOSchedulerTest.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/FIFOSchedulerTest.java
@@ -30,9 +30,7 @@ public class FIFOSchedulerTest extends TestCase {
}
@Override
- public void tearDown() {
-
- }
+ public void tearDown() {}
public void testRun() throws InterruptedException {
Scheduler s = schedulerSvc.createOrGetFIFOScheduler("test");
@@ -51,14 +49,12 @@ public class FIFOSchedulerTest extends TestCase {
assertEquals(1, s.getJobsRunning().size());
assertEquals(1, s.getJobsWaiting().size());
-
Thread.sleep(500);
assertEquals(Status.FINISHED, job1.getStatus());
assertEquals(Status.RUNNING, job2.getStatus());
assertTrue((500 < (Long) job1.getReturn()));
assertEquals(1, s.getJobsRunning().size());
assertEquals(0, s.getJobsWaiting().size());
-
}
public void testAbort() throws InterruptedException {
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/JobTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/JobTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/JobTest.java
index 73d45e9..96aeb79 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/JobTest.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/JobTest.java
@@ -17,6 +17,13 @@
package org.apache.zeppelin.scheduler;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.spy;
+
import org.apache.zeppelin.interpreter.Interpreter;
import org.apache.zeppelin.interpreter.InterpreterContext;
import org.apache.zeppelin.interpreter.InterpreterException;
@@ -29,13 +36,6 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.spy;
-
@RunWith(MockitoJUnitRunner.class)
public class JobTest {
@@ -48,12 +48,7 @@ public class JobTest {
public void setUp() throws Exception {
InterpretJob interpretJob =
new InterpretJob(
- "jobid",
- "jobName",
- mockJobListener,
- mockInterpreter,
- "script",
- mockInterpreterContext);
+ "jobid", "jobName", mockJobListener, mockInterpreter, "script", mockInterpreterContext);
spyInterpretJob = spy(interpretJob);
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/ParallelSchedulerTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/ParallelSchedulerTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/ParallelSchedulerTest.java
index 2495142..edac0a6 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/ParallelSchedulerTest.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/ParallelSchedulerTest.java
@@ -17,7 +17,6 @@
package org.apache.zeppelin.scheduler;
-
import junit.framework.TestCase;
import org.apache.zeppelin.scheduler.Job.Status;
@@ -31,9 +30,7 @@ public class ParallelSchedulerTest extends TestCase {
}
@Override
- public void tearDown() {
-
- }
+ public void tearDown() {}
public void testRun() throws InterruptedException {
Scheduler s = schedulerSvc.createOrGetParallelScheduler("test", 2);
@@ -62,7 +59,5 @@ public class ParallelSchedulerTest extends TestCase {
assertEquals(Status.RUNNING, job3.getStatus());
assertEquals(1, s.getJobsRunning().size());
assertEquals(0, s.getJobsWaiting().size());
-
}
-
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/SleepingJob.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/SleepingJob.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/SleepingJob.java
index fb788ef..dc112f1 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/SleepingJob.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/scheduler/SleepingJob.java
@@ -17,15 +17,12 @@
package org.apache.zeppelin.scheduler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.HashMap;
import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-/**
- *
- */
+/** */
public class SleepingJob extends Job {
private int time;
@@ -36,7 +33,6 @@ public class SleepingJob extends Job {
static Logger LOGGER = LoggerFactory.getLogger(SleepingJob.class);
private Object results;
-
public SleepingJob(String jobName, JobListener listener, int time) {
super(jobName, listener);
this.time = time;
@@ -94,6 +90,4 @@ public class SleepingJob extends Job {
i.put("LoopCount", Integer.toString(count));
return i;
}
-
-
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/tabledata/InterpreterResultTableDataTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/tabledata/InterpreterResultTableDataTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/tabledata/InterpreterResultTableDataTest.java
index 0618d3b..100e90e 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/tabledata/InterpreterResultTableDataTest.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/tabledata/InterpreterResultTableDataTest.java
@@ -16,21 +16,20 @@
*/
package org.apache.zeppelin.tabledata;
+import static junit.framework.TestCase.assertFalse;
+import static org.junit.Assert.assertEquals;
+
+import java.util.Iterator;
import org.apache.zeppelin.interpreter.InterpreterResult;
import org.apache.zeppelin.interpreter.InterpreterResultMessage;
import org.junit.Test;
-import java.util.Iterator;
-
-import static junit.framework.TestCase.assertFalse;
-import static org.junit.Assert.assertEquals;
-
public class InterpreterResultTableDataTest {
@Test
public void test() {
- InterpreterResultMessage msg = new InterpreterResultMessage(
- InterpreterResult.Type.TABLE,
- "key\tvalue\nsun\t100\nmoon\t200\n");
+ InterpreterResultMessage msg =
+ new InterpreterResultMessage(
+ InterpreterResult.Type.TABLE, "key\tvalue\nsun\t100\nmoon\t200\n");
InterpreterResultTableData table = new InterpreterResultTableData(msg);
ColumnDef[] cols = table.columns();
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/tabledata/TableDataProxyTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/tabledata/TableDataProxyTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/tabledata/TableDataProxyTest.java
index a4a8ffe..03d1ae1 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/tabledata/TableDataProxyTest.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/tabledata/TableDataProxyTest.java
@@ -16,17 +16,16 @@
*/
package org.apache.zeppelin.tabledata;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import java.util.Iterator;
import org.apache.zeppelin.interpreter.InterpreterResult;
import org.apache.zeppelin.interpreter.InterpreterResultMessage;
import org.apache.zeppelin.resource.LocalResourcePool;
import org.junit.Before;
import org.junit.Test;
-import java.util.Iterator;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
public class TableDataProxyTest {
private LocalResourcePool pool;
@@ -37,9 +36,9 @@ public class TableDataProxyTest {
@Test
public void testProxyTable() {
- InterpreterResultMessage msg = new InterpreterResultMessage(
- InterpreterResult.Type.TABLE,
- "key\tvalue\nsun\t100\nmoon\t200\n");
+ InterpreterResultMessage msg =
+ new InterpreterResultMessage(
+ InterpreterResult.Type.TABLE, "key\tvalue\nsun\t100\nmoon\t200\n");
InterpreterResultTableData table = new InterpreterResultTableData(msg);
pool.put("table", table);
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/user/AuthenticationInfoTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/user/AuthenticationInfoTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/user/AuthenticationInfoTest.java
index b757033..9262319 100644
--- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/user/AuthenticationInfoTest.java
+++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/user/AuthenticationInfoTest.java
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
-
import org.junit.Test;
public class AuthenticationInfoTest {
@@ -30,13 +29,10 @@ public class AuthenticationInfoTest {
public void testRoles() {
final String roles = "[\"role1\", \"role2\", \"role with space\"]";
- final AuthenticationInfo authenticationInfo = new AuthenticationInfo("foo",
- roles, "bar");
+ final AuthenticationInfo authenticationInfo = new AuthenticationInfo("foo", roles, "bar");
assertEquals(
new ArrayList<>(Arrays.asList("role1", "role2", "role with space")),
authenticationInfo.getRoles());
-
}
-
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/JupyterUtil.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/JupyterUtil.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/JupyterUtil.java
index 5cdbbbb..541e1be 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/JupyterUtil.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/JupyterUtil.java
@@ -16,6 +16,10 @@
*/
package org.apache.zeppelin.jupyter;
+import com.google.common.base.Joiner;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.typeadapters.RuntimeTypeAdapterFactory;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
@@ -24,20 +28,13 @@ import java.io.Reader;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-
-import com.google.common.base.Joiner;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.typeadapters.RuntimeTypeAdapterFactory;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
-
import org.apache.zeppelin.jupyter.nbformat.Cell;
import org.apache.zeppelin.jupyter.nbformat.CodeCell;
import org.apache.zeppelin.jupyter.nbformat.DisplayData;
@@ -56,9 +53,7 @@ import org.apache.zeppelin.jupyter.zformat.TypeData;
import org.apache.zeppelin.markdown.MarkdownParser;
import org.apache.zeppelin.markdown.PegdownParser;
-/**
- *
- */
+/** */
public class JupyterUtil {
private final RuntimeTypeAdapterFactory<Cell> cellTypeFactory;
@@ -67,13 +62,18 @@ public class JupyterUtil {
private final MarkdownParser markdownProcessor;
public JupyterUtil() {
- this.cellTypeFactory = RuntimeTypeAdapterFactory.of(Cell.class, "cell_type")
- .registerSubtype(MarkdownCell.class, "markdown").registerSubtype(CodeCell.class, "code")
- .registerSubtype(RawCell.class, "raw").registerSubtype(HeadingCell.class, "heading");
- this.outputTypeFactory = RuntimeTypeAdapterFactory.of(Output.class, "output_type")
- .registerSubtype(ExecuteResult.class, "execute_result")
- .registerSubtype(DisplayData.class, "display_data").registerSubtype(Stream.class, "stream")
- .registerSubtype(Error.class, "error");
+ this.cellTypeFactory =
+ RuntimeTypeAdapterFactory.of(Cell.class, "cell_type")
+ .registerSubtype(MarkdownCell.class, "markdown")
+ .registerSubtype(CodeCell.class, "code")
+ .registerSubtype(RawCell.class, "raw")
+ .registerSubtype(HeadingCell.class, "heading");
+ this.outputTypeFactory =
+ RuntimeTypeAdapterFactory.of(Output.class, "output_type")
+ .registerSubtype(ExecuteResult.class, "execute_result")
+ .registerSubtype(DisplayData.class, "display_data")
+ .registerSubtype(Stream.class, "stream")
+ .registerSubtype(Error.class, "error");
this.markdownProcessor = new PegdownParser();
}
@@ -89,8 +89,8 @@ public class JupyterUtil {
return getNote(in, new GsonBuilder(), codeReplaced, markdownReplaced);
}
- public Note getNote(Reader in, GsonBuilder gsonBuilder, String codeReplaced,
- String markdownReplaced) {
+ public Note getNote(
+ Reader in, GsonBuilder gsonBuilder, String codeReplaced, String markdownReplaced) {
return getNote(getNbformat(in, gsonBuilder), codeReplaced, markdownReplaced);
}
@@ -102,7 +102,7 @@ public class JupyterUtil {
name = "Note converted from Jupyter";
}
note.setName(name);
-
+
String lineSeparator = System.lineSeparator();
Paragraph paragraph;
List<Paragraph> paragraphs = new ArrayList<>();
@@ -160,11 +160,11 @@ public class JupyterUtil {
return note;
}
-
-
private Gson getGson(GsonBuilder gsonBuilder) {
- return gsonBuilder.registerTypeAdapterFactory(cellTypeFactory)
- .registerTypeAdapterFactory(outputTypeFactory).create();
+ return gsonBuilder
+ .registerTypeAdapterFactory(cellTypeFactory)
+ .registerTypeAdapterFactory(outputTypeFactory)
+ .create();
}
public static void main(String[] args) throws ParseException, IOException {
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Author.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Author.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Author.java
index c3e23e5..7a6c474 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Author.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Author.java
@@ -18,12 +18,9 @@ package org.apache.zeppelin.jupyter.nbformat;
import com.google.gson.annotations.SerializedName;
-/**
- *
- */
+/** */
public class Author {
@SerializedName("name")
private String name;
-
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Cell.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Cell.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Cell.java
index f593da5..874518a 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Cell.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Cell.java
@@ -17,11 +17,8 @@
package org.apache.zeppelin.jupyter.nbformat;
import com.google.gson.annotations.SerializedName;
-import java.util.List;
-/**
- *
- */
+/** */
public abstract class Cell {
@SerializedName("cell_type")
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/CellMetadata.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/CellMetadata.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/CellMetadata.java
index a35a262..2580e6d 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/CellMetadata.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/CellMetadata.java
@@ -19,9 +19,7 @@ package org.apache.zeppelin.jupyter.nbformat;
import com.google.gson.annotations.SerializedName;
import java.util.List;
-/**
- *
- */
+/** */
public class CellMetadata {
@SerializedName("name")
@@ -29,5 +27,4 @@ public class CellMetadata {
@SerializedName("tags")
private List<String> tags;
-
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/CodeCell.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/CodeCell.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/CodeCell.java
index 973448c..db7826c 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/CodeCell.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/CodeCell.java
@@ -19,9 +19,7 @@ package org.apache.zeppelin.jupyter.nbformat;
import com.google.gson.annotations.SerializedName;
import java.util.List;
-/**
- *
- */
+/** */
public class CodeCell extends Cell {
@SerializedName("outputs")
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/DisplayData.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/DisplayData.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/DisplayData.java
index 6566e1d..50e980e 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/DisplayData.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/DisplayData.java
@@ -16,19 +16,12 @@
*/
package org.apache.zeppelin.jupyter.nbformat;
-import com.google.common.base.Joiner;
-import com.google.common.collect.Lists;
import com.google.gson.annotations.SerializedName;
-import org.apache.zeppelin.jupyter.types.JupyterOutputType;
+import java.util.Map;
import org.apache.zeppelin.jupyter.types.ZeppelinOutputType;
import org.apache.zeppelin.jupyter.zformat.TypeData;
-import java.util.List;
-import java.util.Map;
-
-/**
- *
- */
+/** */
public class DisplayData extends Output {
@SerializedName("data")
@@ -50,17 +43,21 @@ public class DisplayData extends Output {
private static class ZeppelinResultGenerator {
public static String toBase64ImageHtmlElement(String image) {
- return "<div style='width:auto;height:auto'><img src=data:image/png;base64," + image
- + " style='width=auto;height:auto'/></div>";
+ return "<div style='width:auto;height:auto'><img src=data:image/png;base64,"
+ + image
+ + " style='width=auto;height:auto'/></div>";
}
+
public static String toLatex(String latexCode) {
String latexContents = latexCode;
- return "<div>" +
- "<div class='class=\"alert alert-warning\"'>" +
- "<strong>Warning!</strong> Currently, Latex is not supported." +
- "</div>" +
- "<div>" + latexContents + "</div>" +
- "</div>";
+ return "<div>"
+ + "<div class='class=\"alert alert-warning\"'>"
+ + "<strong>Warning!</strong> Currently, Latex is not supported."
+ + "</div>"
+ + "<div>"
+ + latexContents
+ + "</div>"
+ + "</div>";
}
}
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Error.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Error.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Error.java
index 679f4cc..a87e971 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Error.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Error.java
@@ -18,15 +18,12 @@ package org.apache.zeppelin.jupyter.nbformat;
import com.google.common.base.Joiner;
import com.google.gson.annotations.SerializedName;
-import org.apache.zeppelin.jupyter.types.ZeppelinOutputType;
-import org.apache.zeppelin.jupyter.zformat.TypeData;
-
import java.util.Arrays;
import java.util.List;
+import org.apache.zeppelin.jupyter.types.ZeppelinOutputType;
+import org.apache.zeppelin.jupyter.zformat.TypeData;
-/**
- *
- */
+/** */
public class Error extends Output {
@SerializedName("ename")
private String ename;
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/ExecuteResult.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/ExecuteResult.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/ExecuteResult.java
index 9e8fe05..2262501 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/ExecuteResult.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/ExecuteResult.java
@@ -17,15 +17,11 @@
package org.apache.zeppelin.jupyter.nbformat;
import com.google.gson.annotations.SerializedName;
-import org.apache.zeppelin.jupyter.types.JupyterOutputType;
+import java.util.Map;
import org.apache.zeppelin.jupyter.types.ZeppelinOutputType;
import org.apache.zeppelin.jupyter.zformat.TypeData;
-import java.util.Map;
-
-/**
- *
- */
+/** */
public class ExecuteResult extends Output {
@SerializedName("execution_count")
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/HeadingCell.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/HeadingCell.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/HeadingCell.java
index 7007088..3fe9506 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/HeadingCell.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/HeadingCell.java
@@ -18,9 +18,7 @@ package org.apache.zeppelin.jupyter.nbformat;
import com.google.gson.annotations.SerializedName;
-/**
- *
- */
+/** */
public class HeadingCell extends Cell {
@SerializedName("level")
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Kernelspec.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Kernelspec.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Kernelspec.java
index 6232416..49fe2b1 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Kernelspec.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Kernelspec.java
@@ -18,9 +18,7 @@ package org.apache.zeppelin.jupyter.nbformat;
import com.google.gson.annotations.SerializedName;
-/**
- *
- */
+/** */
public class Kernelspec {
@SerializedName("name")
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/LanguageInfo.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/LanguageInfo.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/LanguageInfo.java
index cc74089..461e063 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/LanguageInfo.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/LanguageInfo.java
@@ -18,9 +18,7 @@ package org.apache.zeppelin.jupyter.nbformat;
import com.google.gson.annotations.SerializedName;
-/**
- *
- */
+/** */
public class LanguageInfo {
@SerializedName("name")
@@ -37,5 +35,4 @@ public class LanguageInfo {
@SerializedName("pygments_lexer")
private String pygmentsLexer;
-
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/MarkdownCell.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/MarkdownCell.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/MarkdownCell.java
index a1b220b..e403978 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/MarkdownCell.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/MarkdownCell.java
@@ -16,9 +16,5 @@
*/
package org.apache.zeppelin.jupyter.nbformat;
-/**
- *
- */
-public class MarkdownCell extends Cell {
-
-}
+/** */
+public class MarkdownCell extends Cell {}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Metadata.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Metadata.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Metadata.java
index f2da8e4..b35540a 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Metadata.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Metadata.java
@@ -19,9 +19,7 @@ package org.apache.zeppelin.jupyter.nbformat;
import com.google.gson.annotations.SerializedName;
import java.util.List;
-/**
- *
- */
+/** */
public class Metadata {
@SerializedName("kernelspec")
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Nbformat.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Nbformat.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Nbformat.java
index 9ca4146..535afd2 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Nbformat.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Nbformat.java
@@ -19,9 +19,7 @@ package org.apache.zeppelin.jupyter.nbformat;
import com.google.gson.annotations.SerializedName;
import java.util.List;
-/**
- *
- */
+/** */
public class Nbformat {
@SerializedName("metadata")
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Output.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Output.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Output.java
index a37272a..6fd8c4f 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Output.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Output.java
@@ -18,17 +18,14 @@ package org.apache.zeppelin.jupyter.nbformat;
import com.google.common.base.Joiner;
import com.google.gson.annotations.SerializedName;
-import org.apache.zeppelin.jupyter.types.JupyterOutputType;
-import org.apache.zeppelin.jupyter.types.ZeppelinOutputType;
-import org.apache.zeppelin.jupyter.zformat.TypeData;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.apache.zeppelin.jupyter.types.JupyterOutputType;
+import org.apache.zeppelin.jupyter.types.ZeppelinOutputType;
+import org.apache.zeppelin.jupyter.zformat.TypeData;
-/**
- *
- */
+/** */
public abstract class Output {
@SerializedName("output_type")
@@ -71,7 +68,6 @@ public abstract class Output {
return jupyterOutputType;
}
-
protected TypeData getZeppelinResult(Map<String, Object> data, JupyterOutputType type) {
TypeData result = null;
Object outputsObject = data.get(type.toString());
@@ -86,20 +82,18 @@ public abstract class Output {
if (type == JupyterOutputType.IMAGE_PNG) {
String base64CodeRaw = outputData;
String base64Code = base64CodeRaw.replace("\n", "");
- result = new TypeData(
+ result =
+ new TypeData(
type.getZeppelinType().toString(),
- ZeppelinResultGenerator.toBase64ImageHtmlElement(base64Code)
- );
+ ZeppelinResultGenerator.toBase64ImageHtmlElement(base64Code));
} else if (type == JupyterOutputType.LATEX) {
- result = new TypeData(
- type.getZeppelinType().toString(),
- ZeppelinResultGenerator.toLatex(outputData)
- );
+ result =
+ new TypeData(
+ type.getZeppelinType().toString(), ZeppelinResultGenerator.toLatex(outputData));
} else if (type == JupyterOutputType.APPLICATION_JAVASCRIPT) {
- result = new TypeData(
- type.getZeppelinType().toString(),
- ZeppelinResultGenerator.toJavascript(outputData)
- );
+ result =
+ new TypeData(
+ type.getZeppelinType().toString(), ZeppelinResultGenerator.toJavascript(outputData));
} else {
result = new TypeData(type.getZeppelinType().toString(), outputData);
}
@@ -107,19 +101,21 @@ public abstract class Output {
}
public abstract ZeppelinOutputType getTypeOfZeppelin();
+
public abstract TypeData toZeppelinResult();
private static class ZeppelinResultGenerator {
public static String toBase64ImageHtmlElement(String image) {
- return "<div style='width:auto;height:auto'><img src=data:image/png;base64," + image
- + " style='width=auto;height:auto'/></div>";
+ return "<div style='width:auto;height:auto'><img src=data:image/png;base64,"
+ + image
+ + " style='width=auto;height:auto'/></div>";
}
+
public static String toLatex(String latexCode) {
String latexContents = latexCode;
- return "<div>" +
- "<div>" + latexContents + "</div>" +
- "</div>";
+ return "<div>" + "<div>" + latexContents + "</div>" + "</div>";
}
+
public static String toJavascript(String javascriptCode) {
return "<script type='application/javascript'>" + javascriptCode + "</script>";
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/RawCell.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/RawCell.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/RawCell.java
index c5054b8..23577c3 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/RawCell.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/RawCell.java
@@ -16,9 +16,5 @@
*/
package org.apache.zeppelin.jupyter.nbformat;
-/**
- *
- */
-public class RawCell extends Cell {
-
-}
+/** */
+public class RawCell extends Cell {}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/RawCellMetadata.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/RawCellMetadata.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/RawCellMetadata.java
index 1b667d7..dc8bb30 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/RawCellMetadata.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/RawCellMetadata.java
@@ -18,9 +18,7 @@ package org.apache.zeppelin.jupyter.nbformat;
import com.google.gson.annotations.SerializedName;
-/**
- *
- */
+/** */
public class RawCellMetadata extends CellMetadata {
@SerializedName("format")
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Stream.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Stream.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Stream.java
index fa0e246..ab4fd33 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Stream.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/nbformat/Stream.java
@@ -18,16 +18,12 @@ package org.apache.zeppelin.jupyter.nbformat;
import com.google.common.base.Joiner;
import com.google.gson.annotations.SerializedName;
-import org.apache.zeppelin.jupyter.types.ZeppelinOutputType;
-import org.apache.zeppelin.jupyter.zformat.TypeData;
-
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
+import org.apache.zeppelin.jupyter.types.ZeppelinOutputType;
+import org.apache.zeppelin.jupyter.zformat.TypeData;
-/**
- *
- */
+/** */
public class Stream extends Output {
@SerializedName("name")
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/types/JupyterOutputType.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/types/JupyterOutputType.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/types/JupyterOutputType.java
index 383ba11..17c9072 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/types/JupyterOutputType.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/types/JupyterOutputType.java
@@ -16,19 +16,17 @@
*/
package org.apache.zeppelin.jupyter.types;
-/**
- * Jupyter Output Types.
- */
+/** Jupyter Output Types. */
public enum JupyterOutputType {
TEXT_PLAIN("text/plain"),
IMAGE_PNG("image/png"),
LATEX("text/latex"),
SVG_XML("image/svg+xml"),
TEXT_HTML("text/html"),
- APPLICATION_JAVASCRIPT("application/javascript")
- ;
+ APPLICATION_JAVASCRIPT("application/javascript");
private final String type;
+
private JupyterOutputType(final String type) {
this.type = type;
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/types/ZeppelinOutputType.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/types/ZeppelinOutputType.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/types/ZeppelinOutputType.java
index cf1a5e0..e84c330 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/types/ZeppelinOutputType.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/types/ZeppelinOutputType.java
@@ -16,16 +16,14 @@
*/
package org.apache.zeppelin.jupyter.types;
-/**
- * Zeppelin Output Types.
- */
+/** Zeppelin Output Types. */
public enum ZeppelinOutputType {
TEXT("TEXT"),
HTML("HTML"),
- TABLE("TABLE")
- ;
+ TABLE("TABLE");
private final String type;
+
private ZeppelinOutputType(final String type) {
this.type = type;
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/Note.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/Note.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/Note.java
index 78922b5..f5ced4f 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/Note.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/Note.java
@@ -19,9 +19,7 @@ package org.apache.zeppelin.jupyter.zformat;
import com.google.gson.annotations.SerializedName;
import java.util.List;
-/**
- *
- */
+/** */
public class Note {
@SerializedName("name")
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/Paragraph.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/Paragraph.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/Paragraph.java
index a93adae..1b649b2 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/Paragraph.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/Paragraph.java
@@ -22,9 +22,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-/**
- *
- */
+/** */
public class Paragraph {
public static final String FINISHED = "FINISHED";
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/Result.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/Result.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/Result.java
index a00cdd3..da00c6a 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/Result.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/Result.java
@@ -19,9 +19,7 @@ package org.apache.zeppelin.jupyter.zformat;
import com.google.gson.annotations.SerializedName;
import java.util.List;
-/**
- *
- */
+/** */
public class Result {
public static final String SUCCESS = "SUCCESS";
public static final String ERROR = "ERROR";
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/TypeData.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/TypeData.java b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/TypeData.java
index 4aaa642..2ebfca7 100644
--- a/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/TypeData.java
+++ b/zeppelin-jupyter/src/main/java/org/apache/zeppelin/jupyter/zformat/TypeData.java
@@ -18,9 +18,7 @@ package org.apache.zeppelin.jupyter.zformat;
import com.google.gson.annotations.SerializedName;
-/**
- *
- */
+/** */
public class TypeData {
public static final String TABLE = "TABLE";
public static final String HTML = "HTML";
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-jupyter/src/test/java/org/apache/zeppelin/jupyter/nbformat/JupyterUtilTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-jupyter/src/test/java/org/apache/zeppelin/jupyter/nbformat/JupyterUtilTest.java b/zeppelin-jupyter/src/test/java/org/apache/zeppelin/jupyter/nbformat/JupyterUtilTest.java
index 4688a72..cd88763 100644
--- a/zeppelin-jupyter/src/test/java/org/apache/zeppelin/jupyter/nbformat/JupyterUtilTest.java
+++ b/zeppelin-jupyter/src/test/java/org/apache/zeppelin/jupyter/nbformat/JupyterUtilTest.java
@@ -18,21 +18,18 @@ package org.apache.zeppelin.jupyter.nbformat;
import static org.junit.Assert.assertTrue;
+import com.google.gson.Gson;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Map;
-
-import com.google.gson.Gson;
import org.apache.zeppelin.jupyter.JupyterUtil;
import org.apache.zeppelin.jupyter.zformat.Note;
import org.apache.zeppelin.jupyter.zformat.Paragraph;
import org.apache.zeppelin.jupyter.zformat.TypeData;
import org.junit.Test;
-/**
- *
- */
+/** */
public class JupyterUtilTest {
@Test
@@ -72,13 +69,17 @@ public class JupyterUtilTest {
Paragraph markdownParagraph = n.getParagraphs().get(6);
- assertTrue(markdownParagraph.getText().equals("%md\n" +
- "<div class=\"alert\" style=\"border: 1px solid #aaa; background: radial-gradient(ellipse at center, #ffffff 50%, #eee 100%);\">\n" +
- "<div class=\"row\">\n" +
- " <div class=\"col-sm-1\"><img src=\"https://knowledgeanyhow.org/static/images/favicon_32x32.png\" style=\"margin-top: -6px\"/></div>\n" +
- " <div class=\"col-sm-11\">This notebook was created using <a href=\"https://knowledgeanyhow.org\">IBM Knowledge Anyhow Workbench</a>. To learn more, visit us at <a href=\"https://knowledgeanyhow.org\">https://knowledgeanyhow.org</a>.</div>\n" +
- " </div>\n" +
- "</div>"));
+ assertTrue(
+ markdownParagraph
+ .getText()
+ .equals(
+ "%md\n"
+ + "<div class=\"alert\" style=\"border: 1px solid #aaa; background: radial-gradient(ellipse at center, #ffffff 50%, #eee 100%);\">\n"
+ + "<div class=\"row\">\n"
+ + " <div class=\"col-sm-1\"><img src=\"https://knowledgeanyhow.org/static/images/favicon_32x32.png\" style=\"margin-top: -6px\"/></div>\n"
+ + " <div class=\"col-sm-11\">This notebook was created using <a href=\"https://knowledgeanyhow.org\">IBM Knowledge Anyhow Workbench</a>. To learn more, visit us at <a href=\"https://knowledgeanyhow.org\">https://knowledgeanyhow.org</a>.</div>\n"
+ + " </div>\n"
+ + "</div>"));
assertTrue(markdownParagraph.getStatus().equals("FINISHED"));
Map<String, Object> markdownConfig = markdownParagraph.getConfig();
@@ -86,14 +87,19 @@ public class JupyterUtilTest {
assertTrue(((boolean) markdownConfig.get("editorHide")) == true);
assertTrue(markdownParagraph.getResults().getCode().equals("SUCCESS"));
List<TypeData> results = markdownParagraph.getResults().getMsg();
- assertTrue(results.get(0).getData().equals("<div class=\"markdown-body\">\n" +
- "<div class=\"alert\" style=\"border: 1px solid #aaa; background: radial-gradient(ellipse at center, #ffffff 50%, #eee 100%);\">\n" +
- "<div class=\"row\">\n" +
- " <div class=\"col-sm-1\"><img src=\"https://knowledgeanyhow.org/static/images/favicon_32x32.png\" style=\"margin-top: -6px\"/></div>\n" +
- " <div class=\"col-sm-11\">This notebook was created using <a href=\"https://knowledgeanyhow.org\">IBM Knowledge Anyhow Workbench</a>. To learn more, visit us at <a href=\"https://knowledgeanyhow.org\">https://knowledgeanyhow.org</a>.</div>\n" +
- " </div>\n" +
- "</div>\n" +
- "</div>"));
+ assertTrue(
+ results
+ .get(0)
+ .getData()
+ .equals(
+ "<div class=\"markdown-body\">\n"
+ + "<div class=\"alert\" style=\"border: 1px solid #aaa; background: radial-gradient(ellipse at center, #ffffff 50%, #eee 100%);\">\n"
+ + "<div class=\"row\">\n"
+ + " <div class=\"col-sm-1\"><img src=\"https://knowledgeanyhow.org/static/images/favicon_32x32.png\" style=\"margin-top: -6px\"/></div>\n"
+ + " <div class=\"col-sm-11\">This notebook was created using <a href=\"https://knowledgeanyhow.org\">IBM Knowledge Anyhow Workbench</a>. To learn more, visit us at <a href=\"https://knowledgeanyhow.org\">https://knowledgeanyhow.org</a>.</div>\n"
+ + " </div>\n"
+ + "</div>\n"
+ + "</div>"));
assertTrue(results.get(0).getType().equals("HTML"));
}
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-plugins/launcher/spark/src/main/java/org/apache/zeppelin/interpreter/launcher/SparkInterpreterLauncher.java
----------------------------------------------------------------------
diff --git a/zeppelin-plugins/launcher/spark/src/main/java/org/apache/zeppelin/interpreter/launcher/SparkInterpreterLauncher.java b/zeppelin-plugins/launcher/spark/src/main/java/org/apache/zeppelin/interpreter/launcher/SparkInterpreterLauncher.java
index bcf319a..b8a1b8a 100644
--- a/zeppelin-plugins/launcher/spark/src/main/java/org/apache/zeppelin/interpreter/launcher/SparkInterpreterLauncher.java
+++ b/zeppelin-plugins/launcher/spark/src/main/java/org/apache/zeppelin/interpreter/launcher/SparkInterpreterLauncher.java
@@ -17,10 +17,14 @@
package org.apache.zeppelin.interpreter.launcher;
+import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
import java.util.stream.StreamSupport;
import org.apache.commons.lang3.StringUtils;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
@@ -29,14 +33,7 @@ import org.apache.zeppelin.interpreter.remote.RemoteInterpreterUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * Spark specific launcher.
- */
+/** Spark specific launcher. */
public class SparkInterpreterLauncher extends StandardInterpreterLauncher {
private static final Logger LOGGER = LoggerFactory.getLogger(SparkInterpreterLauncher.class);
@@ -72,8 +69,12 @@ public class SparkInterpreterLauncher extends StandardInterpreterLauncher {
}
if (isYarnMode() && getDeployMode().equals("cluster")) {
if (sparkProperties.containsKey("spark.files")) {
- sparkProperties.put("spark.files", sparkProperties.getProperty("spark.files") + "," +
- zConf.getConfDir() + "/log4j_yarn_cluster.properties");
+ sparkProperties.put(
+ "spark.files",
+ sparkProperties.getProperty("spark.files")
+ + ","
+ + zConf.getConfDir()
+ + "/log4j_yarn_cluster.properties");
} else {
sparkProperties.put("spark.files", zConf.getConfDir() + "/log4j_yarn_cluster.properties");
}
@@ -82,8 +83,8 @@ public class SparkInterpreterLauncher extends StandardInterpreterLauncher {
sparkConfBuilder.append(" --conf " + name + "=" + sparkProperties.getProperty(name));
}
String useProxyUserEnv = System.getenv("ZEPPELIN_IMPERSONATE_SPARK_PROXY_USER");
- if (context.getOption().isUserImpersonate() && (StringUtils.isBlank(useProxyUserEnv) ||
- !useProxyUserEnv.equals("false"))) {
+ if (context.getOption().isUserImpersonate()
+ && (StringUtils.isBlank(useProxyUserEnv) || !useProxyUserEnv.equals("false"))) {
sparkConfBuilder.append(" --proxy-user " + context.getUserName());
}
Path localRepoPath =
@@ -103,7 +104,6 @@ public class SparkInterpreterLauncher extends StandardInterpreterLauncher {
} catch (IOException e) {
LOGGER.error("Cannot make a list of additional jars from localRepo: {}", localRepoPath, e);
}
-
}
env.put("ZEPPELIN_SPARK_CONF", sparkConfBuilder.toString());
@@ -113,7 +113,7 @@ public class SparkInterpreterLauncher extends StandardInterpreterLauncher {
// 2. zeppelin-env.sh
// It is encouraged to set env in interpreter setting, but just for backward compatability,
// we also fallback to zeppelin-env.sh if it is not specified in interpreter setting.
- for (String envName : new String[]{"SPARK_HOME", "SPARK_CONF_DIR", "HADOOP_CONF_DIR"}) {
+ for (String envName : new String[] {"SPARK_HOME", "SPARK_CONF_DIR", "HADOOP_CONF_DIR"}) {
String envValue = getEnv(envName);
if (envValue != null) {
env.put(envName, envValue);
@@ -127,23 +127,19 @@ public class SparkInterpreterLauncher extends StandardInterpreterLauncher {
if (!StringUtils.isBlank(keytab) && !StringUtils.isBlank(principal)) {
env.put("ZEPPELIN_SERVER_KERBEROS_KEYTAB", keytab);
env.put("ZEPPELIN_SERVER_KERBEROS_PRINCIPAL", principal);
- LOGGER.info("Run Spark under secure mode with keytab: " + keytab +
- ", principal: " + principal);
+ LOGGER.info(
+ "Run Spark under secure mode with keytab: " + keytab + ", principal: " + principal);
} else {
LOGGER.info("Run Spark under non-secure mode as no keytab and principal is specified");
}
LOGGER.debug("buildEnvFromProperties: " + env);
return env;
-
}
-
/**
* get environmental variable in the following order
*
- * 1. interpreter setting
- * 2. zeppelin-env.sh
- *
+ * <p>1. interpreter setting 2. zeppelin-env.sh
*/
private String getEnv(String envName) {
String env = properties.getProperty(envName);
@@ -163,8 +159,8 @@ public class SparkInterpreterLauncher extends StandardInterpreterLauncher {
}
}
- private void mergeSparkProperty(Properties sparkProperties, String propertyName,
- String propertyValue) {
+ private void mergeSparkProperty(
+ Properties sparkProperties, String propertyName, String propertyValue) {
if (sparkProperties.containsKey(propertyName)) {
String oldPropertyValue = sparkProperties.getProperty(propertyName);
sparkProperties.setProperty(propertyName, oldPropertyValue + "," + propertyValue);
@@ -178,31 +174,31 @@ public class SparkInterpreterLauncher extends StandardInterpreterLauncher {
File sparkRBasePath = null;
if (sparkHome == null) {
if (!getSparkMaster(properties).startsWith("local")) {
- throw new RuntimeException("SPARK_HOME is not specified in interpreter-setting" +
- " for non-local mode, if you specify it in zeppelin-env.sh, please move that into " +
- " interpreter setting");
+ throw new RuntimeException(
+ "SPARK_HOME is not specified in interpreter-setting"
+ + " for non-local mode, if you specify it in zeppelin-env.sh, please move that into "
+ + " interpreter setting");
}
String zeppelinHome = zConf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_HOME);
- sparkRBasePath = new File(zeppelinHome,
- "interpreter" + File.separator + "spark" + File.separator + "R");
+ sparkRBasePath =
+ new File(zeppelinHome, "interpreter" + File.separator + "spark" + File.separator + "R");
} else {
sparkRBasePath = new File(sparkHome, "R" + File.separator + "lib");
}
File sparkRPath = new File(sparkRBasePath, "sparkr.zip");
if (sparkRPath.exists() && sparkRPath.isFile()) {
- mergeSparkProperty(sparkProperties, "spark.yarn.dist.archives",
- sparkRPath.getAbsolutePath() + "#sparkr");
+ mergeSparkProperty(
+ sparkProperties, "spark.yarn.dist.archives", sparkRPath.getAbsolutePath() + "#sparkr");
} else {
LOGGER.warn("sparkr.zip is not found, SparkR may not work.");
}
}
/**
- * Order to look for spark master
- * 1. master in interpreter setting
- * 2. spark.master interpreter setting
- * 3. use local[*]
+ * Order to look for spark master 1. master in interpreter setting 2. spark.master interpreter
+ * setting 3. use local[*]
+ *
* @param properties
* @return
*/
@@ -228,8 +224,8 @@ public class SparkInterpreterLauncher extends StandardInterpreterLauncher {
} else {
String deployMode = properties.getProperty("spark.submit.deployMode");
if (deployMode == null) {
- throw new RuntimeException("master is set as yarn, but spark.submit.deployMode " +
- "is not specified");
+ throw new RuntimeException(
+ "master is set as yarn, but spark.submit.deployMode " + "is not specified");
}
if (!deployMode.equals("client") && !deployMode.equals("cluster")) {
throw new RuntimeException("Invalid value for spark.submit.deployMode: " + deployMode);
@@ -251,5 +247,4 @@ public class SparkInterpreterLauncher extends StandardInterpreterLauncher {
return "'" + value + "'";
}
}
-
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-plugins/launcher/spark/src/test/java/org/apache/zeppelin/interpreter/launcher/SparkInterpreterLauncherTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-plugins/launcher/spark/src/test/java/org/apache/zeppelin/interpreter/launcher/SparkInterpreterLauncherTest.java b/zeppelin-plugins/launcher/spark/src/test/java/org/apache/zeppelin/interpreter/launcher/SparkInterpreterLauncherTest.java
index d7dcd0a..18e77ae 100644
--- a/zeppelin-plugins/launcher/spark/src/test/java/org/apache/zeppelin/interpreter/launcher/SparkInterpreterLauncherTest.java
+++ b/zeppelin-plugins/launcher/spark/src/test/java/org/apache/zeppelin/interpreter/launcher/SparkInterpreterLauncherTest.java
@@ -17,9 +17,14 @@
package org.apache.zeppelin.interpreter.launcher;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Properties;
import org.apache.commons.io.FileUtils;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.interpreter.InterpreterOption;
@@ -27,12 +32,6 @@ import org.apache.zeppelin.interpreter.remote.RemoteInterpreterManagedProcess;
import org.junit.Before;
import org.junit.Test;
-import java.io.IOException;
-import java.util.Properties;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
public class SparkInterpreterLauncherTest {
@Before
public void setUp() {
@@ -51,9 +50,20 @@ public class SparkInterpreterLauncherTest {
ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT.getVarName(), "10000");
InterpreterOption option = new InterpreterOption();
option.setUserImpersonate(true);
- InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, "user1", "intpGroupId", "groupId", "groupName", "name", 0, "host");
+ InterpreterLaunchContext context =
+ new InterpreterLaunchContext(
+ properties,
+ option,
+ null,
+ "user1",
+ "intpGroupId",
+ "groupId",
+ "groupName",
+ "name",
+ 0,
+ "host");
InterpreterClient client = launcher.launch(context);
- assertTrue( client instanceof RemoteInterpreterManagedProcess);
+ assertTrue(client instanceof RemoteInterpreterManagedProcess);
RemoteInterpreterManagedProcess interpreterProcess = (RemoteInterpreterManagedProcess) client;
assertEquals("name", interpreterProcess.getInterpreterSettingName());
assertEquals(".//interpreter/groupName", interpreterProcess.getInterpreterDir());
@@ -76,9 +86,20 @@ public class SparkInterpreterLauncherTest {
properties.setProperty("spark.jars", "jar_1");
InterpreterOption option = new InterpreterOption();
- InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, "user1", "intpGroupId", "groupId", "spark", "spark", 0, "host");
+ InterpreterLaunchContext context =
+ new InterpreterLaunchContext(
+ properties,
+ option,
+ null,
+ "user1",
+ "intpGroupId",
+ "groupId",
+ "spark",
+ "spark",
+ 0,
+ "host");
InterpreterClient client = launcher.launch(context);
- assertTrue( client instanceof RemoteInterpreterManagedProcess);
+ assertTrue(client instanceof RemoteInterpreterManagedProcess);
RemoteInterpreterManagedProcess interpreterProcess = (RemoteInterpreterManagedProcess) client;
assertEquals("spark", interpreterProcess.getInterpreterSettingName());
assertTrue(interpreterProcess.getInterpreterDir().endsWith("/interpreter/spark"));
@@ -86,7 +107,9 @@ public class SparkInterpreterLauncherTest {
assertEquals(zConf.getInterpreterRemoteRunnerPath(), interpreterProcess.getInterpreterRunner());
assertTrue(interpreterProcess.getEnv().size() >= 2);
assertEquals("/user/spark", interpreterProcess.getEnv().get("SPARK_HOME"));
- assertEquals(" --master local[*] --conf spark.files='file_1' --conf spark.jars='jar_1'", interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF"));
+ assertEquals(
+ " --master local[*] --conf spark.files='file_1' --conf spark.jars='jar_1'",
+ interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF"));
}
@Test
@@ -101,9 +124,20 @@ public class SparkInterpreterLauncherTest {
properties.setProperty("spark.jars", "jar_1");
InterpreterOption option = new InterpreterOption();
- InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, "user1", "intpGroupId", "groupId", "spark", "spark", 0, "host");
+ InterpreterLaunchContext context =
+ new InterpreterLaunchContext(
+ properties,
+ option,
+ null,
+ "user1",
+ "intpGroupId",
+ "groupId",
+ "spark",
+ "spark",
+ 0,
+ "host");
InterpreterClient client = launcher.launch(context);
- assertTrue( client instanceof RemoteInterpreterManagedProcess);
+ assertTrue(client instanceof RemoteInterpreterManagedProcess);
RemoteInterpreterManagedProcess interpreterProcess = (RemoteInterpreterManagedProcess) client;
assertEquals("spark", interpreterProcess.getInterpreterSettingName());
assertTrue(interpreterProcess.getInterpreterDir().endsWith("/interpreter/spark"));
@@ -111,7 +145,9 @@ public class SparkInterpreterLauncherTest {
assertEquals(zConf.getInterpreterRemoteRunnerPath(), interpreterProcess.getInterpreterRunner());
assertTrue(interpreterProcess.getEnv().size() >= 2);
assertEquals("/user/spark", interpreterProcess.getEnv().get("SPARK_HOME"));
- assertEquals(" --master yarn-client --conf spark.files='file_1' --conf spark.jars='jar_1' --conf spark.yarn.isPython=true", interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF"));
+ assertEquals(
+ " --master yarn-client --conf spark.files='file_1' --conf spark.jars='jar_1' --conf spark.yarn.isPython=true",
+ interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF"));
}
@Test
@@ -127,9 +163,20 @@ public class SparkInterpreterLauncherTest {
properties.setProperty("spark.jars", "jar_1");
InterpreterOption option = new InterpreterOption();
- InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, "user1", "intpGroupId", "groupId", "spark", "spark", 0, "host");
+ InterpreterLaunchContext context =
+ new InterpreterLaunchContext(
+ properties,
+ option,
+ null,
+ "user1",
+ "intpGroupId",
+ "groupId",
+ "spark",
+ "spark",
+ 0,
+ "host");
InterpreterClient client = launcher.launch(context);
- assertTrue( client instanceof RemoteInterpreterManagedProcess);
+ assertTrue(client instanceof RemoteInterpreterManagedProcess);
RemoteInterpreterManagedProcess interpreterProcess = (RemoteInterpreterManagedProcess) client;
assertEquals("spark", interpreterProcess.getInterpreterSettingName());
assertTrue(interpreterProcess.getInterpreterDir().endsWith("/interpreter/spark"));
@@ -137,7 +184,9 @@ public class SparkInterpreterLauncherTest {
assertEquals(zConf.getInterpreterRemoteRunnerPath(), interpreterProcess.getInterpreterRunner());
assertTrue(interpreterProcess.getEnv().size() >= 2);
assertEquals("/user/spark", interpreterProcess.getEnv().get("SPARK_HOME"));
- assertEquals(" --master yarn --conf spark.files='file_1' --conf spark.jars='jar_1' --conf spark.submit.deployMode='client' --conf spark.yarn.isPython=true", interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF"));
+ assertEquals(
+ " --master yarn --conf spark.files='file_1' --conf spark.jars='jar_1' --conf spark.submit.deployMode='client' --conf spark.yarn.isPython=true",
+ interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF"));
}
@Test
@@ -152,9 +201,20 @@ public class SparkInterpreterLauncherTest {
properties.setProperty("spark.jars", "jar_1");
InterpreterOption option = new InterpreterOption();
- InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, "user1", "intpGroupId", "groupId", "spark", "spark", 0, "host");
+ InterpreterLaunchContext context =
+ new InterpreterLaunchContext(
+ properties,
+ option,
+ null,
+ "user1",
+ "intpGroupId",
+ "groupId",
+ "spark",
+ "spark",
+ 0,
+ "host");
InterpreterClient client = launcher.launch(context);
- assertTrue( client instanceof RemoteInterpreterManagedProcess);
+ assertTrue(client instanceof RemoteInterpreterManagedProcess);
RemoteInterpreterManagedProcess interpreterProcess = (RemoteInterpreterManagedProcess) client;
assertEquals("spark", interpreterProcess.getInterpreterSettingName());
assertTrue(interpreterProcess.getInterpreterDir().endsWith("/interpreter/spark"));
@@ -163,7 +223,9 @@ public class SparkInterpreterLauncherTest {
assertTrue(interpreterProcess.getEnv().size() >= 3);
assertEquals("/user/spark", interpreterProcess.getEnv().get("SPARK_HOME"));
assertEquals("true", interpreterProcess.getEnv().get("ZEPPELIN_SPARK_YARN_CLUSTER"));
- assertEquals(" --master yarn-cluster --conf spark.files='file_1',.//conf/log4j_yarn_cluster.properties --conf spark.jars='jar_1' --conf spark.yarn.isPython=true --conf spark.yarn.submit.waitAppCompletion=false", interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF"));
+ assertEquals(
+ " --master yarn-cluster --conf spark.files='file_1',.//conf/log4j_yarn_cluster.properties --conf spark.jars='jar_1' --conf spark.yarn.isPython=true --conf spark.yarn.submit.waitAppCompletion=false",
+ interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF"));
}
@Test
@@ -180,14 +242,26 @@ public class SparkInterpreterLauncherTest {
InterpreterOption option = new InterpreterOption();
option.setUserImpersonate(true);
- InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, "user1", "intpGroupId", "groupId", "spark", "spark", 0, "host");
- Path localRepoPath = Paths.get(zConf.getInterpreterLocalRepoPath(), context.getInterpreterSettingId());
+ InterpreterLaunchContext context =
+ new InterpreterLaunchContext(
+ properties,
+ option,
+ null,
+ "user1",
+ "intpGroupId",
+ "groupId",
+ "spark",
+ "spark",
+ 0,
+ "host");
+ Path localRepoPath =
+ Paths.get(zConf.getInterpreterLocalRepoPath(), context.getInterpreterSettingId());
FileUtils.deleteDirectory(localRepoPath.toFile());
Files.createDirectories(localRepoPath);
Files.createFile(Paths.get(localRepoPath.toAbsolutePath().toString(), "test.jar"));
InterpreterClient client = launcher.launch(context);
- assertTrue( client instanceof RemoteInterpreterManagedProcess);
+ assertTrue(client instanceof RemoteInterpreterManagedProcess);
RemoteInterpreterManagedProcess interpreterProcess = (RemoteInterpreterManagedProcess) client;
assertEquals("spark", interpreterProcess.getInterpreterSettingName());
assertTrue(interpreterProcess.getInterpreterDir().endsWith("/interpreter/spark"));
@@ -196,7 +270,10 @@ public class SparkInterpreterLauncherTest {
assertTrue(interpreterProcess.getEnv().size() >= 3);
assertEquals("/user/spark", interpreterProcess.getEnv().get("SPARK_HOME"));
assertEquals("true", interpreterProcess.getEnv().get("ZEPPELIN_SPARK_YARN_CLUSTER"));
- assertEquals(" --master yarn --conf spark.files='file_1',.//conf/log4j_yarn_cluster.properties --conf spark.jars='jar_1' --conf spark.submit.deployMode='cluster' --conf spark.yarn.isPython=true --conf spark.yarn.submit.waitAppCompletion=false --proxy-user user1 --jars " + Paths.get(localRepoPath.toAbsolutePath().toString(), "test.jar").toString(), interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF"));
+ assertEquals(
+ " --master yarn --conf spark.files='file_1',.//conf/log4j_yarn_cluster.properties --conf spark.jars='jar_1' --conf spark.submit.deployMode='cluster' --conf spark.yarn.isPython=true --conf spark.yarn.submit.waitAppCompletion=false --proxy-user user1 --jars "
+ + Paths.get(localRepoPath.toAbsolutePath().toString(), "test.jar").toString(),
+ interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF"));
Files.deleteIfExists(Paths.get(localRepoPath.toAbsolutePath().toString(), "test.jar"));
FileUtils.deleteDirectory(localRepoPath.toFile());
}
@@ -215,13 +292,25 @@ public class SparkInterpreterLauncherTest {
InterpreterOption option = new InterpreterOption();
option.setUserImpersonate(true);
- InterpreterLaunchContext context = new InterpreterLaunchContext(properties, option, null, "user1", "intpGroupId", "groupId", "spark", "spark", 0, "host");
- Path localRepoPath = Paths.get(zConf.getInterpreterLocalRepoPath(), context.getInterpreterSettingId());
+ InterpreterLaunchContext context =
+ new InterpreterLaunchContext(
+ properties,
+ option,
+ null,
+ "user1",
+ "intpGroupId",
+ "groupId",
+ "spark",
+ "spark",
+ 0,
+ "host");
+ Path localRepoPath =
+ Paths.get(zConf.getInterpreterLocalRepoPath(), context.getInterpreterSettingId());
FileUtils.deleteDirectory(localRepoPath.toFile());
Files.createDirectories(localRepoPath);
InterpreterClient client = launcher.launch(context);
- assertTrue( client instanceof RemoteInterpreterManagedProcess);
+ assertTrue(client instanceof RemoteInterpreterManagedProcess);
RemoteInterpreterManagedProcess interpreterProcess = (RemoteInterpreterManagedProcess) client;
assertEquals("spark", interpreterProcess.getInterpreterSettingName());
assertTrue(interpreterProcess.getInterpreterDir().endsWith("/interpreter/spark"));
@@ -230,7 +319,9 @@ public class SparkInterpreterLauncherTest {
assertTrue(interpreterProcess.getEnv().size() >= 3);
assertEquals("/user/spark", interpreterProcess.getEnv().get("SPARK_HOME"));
assertEquals("true", interpreterProcess.getEnv().get("ZEPPELIN_SPARK_YARN_CLUSTER"));
- assertEquals(" --master yarn --conf spark.files='file_1',.//conf/log4j_yarn_cluster.properties --conf spark.jars='jar_1' --conf spark.submit.deployMode='cluster' --conf spark.yarn.isPython=true --conf spark.yarn.submit.waitAppCompletion=false --proxy-user user1", interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF"));
+ assertEquals(
+ " --master yarn --conf spark.files='file_1',.//conf/log4j_yarn_cluster.properties --conf spark.jars='jar_1' --conf spark.submit.deployMode='cluster' --conf spark.yarn.isPython=true --conf spark.yarn.submit.waitAppCompletion=false --proxy-user user1",
+ interpreterProcess.getEnv().get("ZEPPELIN_SPARK_CONF"));
FileUtils.deleteDirectory(localRepoPath.toFile());
}
}