http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/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 577dd92..68981da 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,31 +17,32 @@ package org.apache.zeppelin.interpreter.remote; -import static org.junit.Assert.assertTrue; +import org.junit.Test; import java.io.IOException; -import org.junit.Test; + +import static org.junit.Assert.assertTrue; 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/0d746fa2/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 afdcfc6..8b42dc8 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,14 +16,16 @@ */ 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; -import org.junit.Test; - -/** Unittest for LocalResourcePool */ +/** + * Unittest for LocalResourcePool + */ public class LocalResourcePoolTest { @Test http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/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 23267f1..cc1cad1 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,11 +16,13 @@ */ package org.apache.zeppelin.resource; -import static org.junit.Assert.assertEquals; - import org.junit.Test; -/** Unit test for ResourceSet */ +import static org.junit.Assert.assertEquals; + +/** + * Unit test for ResourceSet + */ public class ResourceSetTest { @Test http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/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 5d06c4e..fb8b271 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,13 +16,16 @@ */ package org.apache.zeppelin.resource; -import static org.junit.Assert.assertEquals; +import org.junit.Test; import java.io.IOException; import java.nio.ByteBuffer; -import org.junit.Test; -/** Test for Resource */ +import static org.junit.Assert.assertEquals; + +/** + * Test for Resource + */ public class ResourceTest { @Test public void testSerializeDeserialize() throws IOException, ClassNotFoundException { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/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 15bf7a5..807b5ee 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,7 +30,9 @@ public class FIFOSchedulerTest extends TestCase { } @Override - public void tearDown() {} + public void tearDown() { + + } public void testRun() throws InterruptedException { Scheduler s = schedulerSvc.createOrGetFIFOScheduler("test"); @@ -49,12 +51,14 @@ 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/0d746fa2/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 96aeb79..73d45e9 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,13 +17,6 @@ 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; @@ -36,6 +29,13 @@ 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,7 +48,12 @@ 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/0d746fa2/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 edac0a6..2495142 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,6 +17,7 @@ package org.apache.zeppelin.scheduler; + import junit.framework.TestCase; import org.apache.zeppelin.scheduler.Job.Status; @@ -30,7 +31,9 @@ public class ParallelSchedulerTest extends TestCase { } @Override - public void tearDown() {} + public void tearDown() { + + } public void testRun() throws InterruptedException { Scheduler s = schedulerSvc.createOrGetParallelScheduler("test", 2); @@ -59,5 +62,7 @@ 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/0d746fa2/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 dc112f1..fb788ef 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,12 +17,15 @@ package org.apache.zeppelin.scheduler; -import java.util.HashMap; -import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** */ +import java.util.HashMap; +import java.util.Map; + +/** + * + */ public class SleepingJob extends Job { private int time; @@ -33,6 +36,7 @@ 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; @@ -90,4 +94,6 @@ public class SleepingJob extends Job { i.put("LoopCount", Integer.toString(count)); return i; } + + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/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 100e90e..0618d3b 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,20 +16,21 @@ */ 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/0d746fa2/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 03d1ae1..a4a8ffe 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,16 +16,17 @@ */ 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; @@ -36,9 +37,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/0d746fa2/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 9262319..b757033 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,6 +21,7 @@ import static org.junit.Assert.assertEquals; import java.util.ArrayList; import java.util.Arrays; + import org.junit.Test; public class AuthenticationInfoTest { @@ -29,10 +30,13 @@ 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/0d746fa2/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 541e1be..5cdbbbb 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,10 +16,6 @@ */ 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; @@ -28,13 +24,20 @@ 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; @@ -53,7 +56,9 @@ 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; @@ -62,18 +67,13 @@ 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/0d746fa2/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 7a6c474..c3e23e5 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,9 +18,12 @@ 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/0d746fa2/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 874518a..f593da5 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,8 +17,11 @@ 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/0d746fa2/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 2580e6d..a35a262 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,7 +19,9 @@ package org.apache.zeppelin.jupyter.nbformat; import com.google.gson.annotations.SerializedName; import java.util.List; -/** */ +/** + * + */ public class CellMetadata { @SerializedName("name") @@ -27,4 +29,5 @@ public class CellMetadata { @SerializedName("tags") private List<String> tags; + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/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 db7826c..973448c 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,7 +19,9 @@ 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/0d746fa2/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 50e980e..6566e1d 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,12 +16,19 @@ */ 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 java.util.Map; +import org.apache.zeppelin.jupyter.types.JupyterOutputType; 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") @@ -43,21 +50,17 @@ 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/0d746fa2/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 a87e971..679f4cc 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,12 +18,15 @@ package org.apache.zeppelin.jupyter.nbformat; import com.google.common.base.Joiner; import com.google.gson.annotations.SerializedName; -import java.util.Arrays; -import java.util.List; import org.apache.zeppelin.jupyter.types.ZeppelinOutputType; import org.apache.zeppelin.jupyter.zformat.TypeData; -/** */ +import java.util.Arrays; +import java.util.List; + +/** + * + */ public class Error extends Output { @SerializedName("ename") private String ename; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/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 2262501..9e8fe05 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,11 +17,15 @@ package org.apache.zeppelin.jupyter.nbformat; import com.google.gson.annotations.SerializedName; -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; -/** */ +import java.util.Map; + +/** + * + */ public class ExecuteResult extends Output { @SerializedName("execution_count") http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/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 3fe9506..7007088 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,7 +18,9 @@ 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/0d746fa2/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 49fe2b1..6232416 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,7 +18,9 @@ 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/0d746fa2/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 461e063..cc74089 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,7 +18,9 @@ package org.apache.zeppelin.jupyter.nbformat; import com.google.gson.annotations.SerializedName; -/** */ +/** + * + */ public class LanguageInfo { @SerializedName("name") @@ -35,4 +37,5 @@ public class LanguageInfo { @SerializedName("pygments_lexer") private String pygmentsLexer; + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/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 e403978..a1b220b 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,5 +16,9 @@ */ 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/0d746fa2/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 b35540a..f2da8e4 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,7 +19,9 @@ 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/0d746fa2/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 535afd2..9ca4146 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,7 +19,9 @@ 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/0d746fa2/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 6fd8c4f..a37272a 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,14 +18,17 @@ package org.apache.zeppelin.jupyter.nbformat; import com.google.common.base.Joiner; import com.google.gson.annotations.SerializedName; -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; -/** */ +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * + */ public abstract class Output { @SerializedName("output_type") @@ -68,6 +71,7 @@ public abstract class Output { return jupyterOutputType; } + protected TypeData getZeppelinResult(Map<String, Object> data, JupyterOutputType type) { TypeData result = null; Object outputsObject = data.get(type.toString()); @@ -82,18 +86,20 @@ 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); } @@ -101,21 +107,19 @@ 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/0d746fa2/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 23577c3..c5054b8 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,5 +16,9 @@ */ 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/0d746fa2/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 dc8bb30..1b667d7 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,7 +18,9 @@ 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/0d746fa2/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 ab4fd33..fa0e246 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,12 +18,16 @@ package org.apache.zeppelin.jupyter.nbformat; import com.google.common.base.Joiner; import com.google.gson.annotations.SerializedName; -import java.util.ArrayList; -import java.util.List; 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; + +/** + * + */ public class Stream extends Output { @SerializedName("name") http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/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 17c9072..383ba11 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,17 +16,19 @@ */ 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/0d746fa2/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 e84c330..cf1a5e0 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,14 +16,16 @@ */ 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/0d746fa2/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 f5ced4f..78922b5 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,7 +19,9 @@ 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/0d746fa2/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 1b649b2..a93adae 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,7 +22,9 @@ 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/0d746fa2/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 da00c6a..a00cdd3 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,7 +19,9 @@ 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/0d746fa2/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 2ebfca7..4aaa642 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,7 +18,9 @@ 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/0d746fa2/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 cd88763..4688a72 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,18 +18,21 @@ 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 @@ -69,17 +72,13 @@ 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(); @@ -87,19 +86,14 @@ 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/0d746fa2/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 b8a1b8a..bcf319a 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,14 +17,10 @@ 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; @@ -33,7 +29,14 @@ import org.apache.zeppelin.interpreter.remote.RemoteInterpreterUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** Spark specific launcher. */ +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +/** + * Spark specific launcher. + */ public class SparkInterpreterLauncher extends StandardInterpreterLauncher { private static final Logger LOGGER = LoggerFactory.getLogger(SparkInterpreterLauncher.class); @@ -69,12 +72,8 @@ 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"); } @@ -83,8 +82,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 = @@ -104,6 +103,7 @@ 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,19 +127,23 @@ 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 * - * <p>1. interpreter setting 2. zeppelin-env.sh + * 1. interpreter setting + * 2. zeppelin-env.sh + * */ private String getEnv(String envName) { String env = properties.getProperty(envName); @@ -159,8 +163,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); @@ -174,31 +178,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 */ @@ -224,8 +228,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); @@ -247,4 +251,5 @@ public class SparkInterpreterLauncher extends StandardInterpreterLauncher { return "'" + value + "'"; } } + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/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 18e77ae..d7dcd0a 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,14 +17,9 @@ 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; @@ -32,6 +27,12 @@ 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() { @@ -50,20 +51,9 @@ 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()); @@ -86,20 +76,9 @@ 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")); @@ -107,9 +86,7 @@ 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 @@ -124,20 +101,9 @@ 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")); @@ -145,9 +111,7 @@ 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 @@ -163,20 +127,9 @@ 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")); @@ -184,9 +137,7 @@ 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 @@ -201,20 +152,9 @@ 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")); @@ -223,9 +163,7 @@ 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 @@ -242,26 +180,14 @@ 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")); @@ -270,10 +196,7 @@ 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()); } @@ -292,25 +215,13 @@ 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")); @@ -319,9 +230,7 @@ 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()); } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-plugins/launcher/standard/src/main/java/org/apache/zeppelin/interpreter/launcher/StandardInterpreterLauncher.java ---------------------------------------------------------------------- diff --git a/zeppelin-plugins/launcher/standard/src/main/java/org/apache/zeppelin/interpreter/launcher/StandardInterpreterLauncher.java b/zeppelin-plugins/launcher/standard/src/main/java/org/apache/zeppelin/interpreter/launcher/StandardInterpreterLauncher.java index cd3c399..9c7a0b2 100644 --- a/zeppelin-plugins/launcher/standard/src/main/java/org/apache/zeppelin/interpreter/launcher/StandardInterpreterLauncher.java +++ b/zeppelin-plugins/launcher/standard/src/main/java/org/apache/zeppelin/interpreter/launcher/StandardInterpreterLauncher.java @@ -15,11 +15,9 @@ * limitations under the License. */ + package org.apache.zeppelin.interpreter.launcher; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.interpreter.InterpreterOption; import org.apache.zeppelin.interpreter.InterpreterRunner; @@ -30,7 +28,13 @@ import org.apache.zeppelin.interpreter.remote.RemoteInterpreterUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** Interpreter Launcher which use shell script to launch the interpreter process. */ +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * Interpreter Launcher which use shell script to launch the interpreter process. + */ public class StandardInterpreterLauncher extends InterpreterLauncher { private static final Logger LOGGER = LoggerFactory.getLogger(StandardInterpreterLauncher.class); @@ -51,7 +55,10 @@ public class StandardInterpreterLauncher extends InterpreterLauncher { if (option.isExistingProcess()) { return new RemoteInterpreterRunningProcess( - context.getInterpreterSettingName(), connectTimeout, option.getHost(), option.getPort()); + context.getInterpreterSettingName(), + connectTimeout, + option.getHost(), + option.getPort()); } else { // try to recover it first if (zConf.isRecoveryEnabled()) { @@ -59,38 +66,25 @@ public class StandardInterpreterLauncher extends InterpreterLauncher { recoveryStorage.getInterpreterClient(context.getInterpreterGroupId()); if (recoveredClient != null) { if (recoveredClient.isRunning()) { - LOGGER.info( - "Recover interpreter process: " - + recoveredClient.getHost() - + ":" - + recoveredClient.getPort()); + LOGGER.info("Recover interpreter process: " + recoveredClient.getHost() + ":" + + recoveredClient.getPort()); return recoveredClient; } else { - LOGGER.warn( - "Cannot recover interpreter process: " - + recoveredClient.getHost() - + ":" - + recoveredClient.getPort() - + ", as it is already terminated."); + LOGGER.warn("Cannot recover interpreter process: " + recoveredClient.getHost() + ":" + + recoveredClient.getPort() + ", as it is already terminated."); } } } // create new remote process - String localRepoPath = - zConf.getInterpreterLocalRepoPath() + "/" + context.getInterpreterSettingId(); + String localRepoPath = zConf.getInterpreterLocalRepoPath() + "/" + + context.getInterpreterSettingId(); return new RemoteInterpreterManagedProcess( runner != null ? runner.getPath() : zConf.getInterpreterRemoteRunnerPath(), - context.getZeppelinServerRPCPort(), - context.getZeppelinServerHost(), - zConf.getInterpreterPortRange(), - zConf.getInterpreterDir() + "/" + groupName, - localRepoPath, - buildEnvFromProperties(context), - connectTimeout, - name, - context.getInterpreterGroupId(), - option.isUserImpersonate()); + context.getZeppelinServerRPCPort(), context.getZeppelinServerHost(), zConf.getInterpreterPortRange(), + zConf.getInterpreterDir() + "/" + groupName, localRepoPath, + buildEnvFromProperties(context), connectTimeout, name, + context.getInterpreterGroupId(), option.isUserImpersonate()); } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-plugins/launcher/standard/src/test/java/org/apache/zeppelin/interpreter/launcher/StandardInterpreterLauncherTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-plugins/launcher/standard/src/test/java/org/apache/zeppelin/interpreter/launcher/StandardInterpreterLauncherTest.java b/zeppelin-plugins/launcher/standard/src/test/java/org/apache/zeppelin/interpreter/launcher/StandardInterpreterLauncherTest.java index 4f05f29..1861636 100644 --- a/zeppelin-plugins/launcher/standard/src/test/java/org/apache/zeppelin/interpreter/launcher/StandardInterpreterLauncherTest.java +++ b/zeppelin-plugins/launcher/standard/src/test/java/org/apache/zeppelin/interpreter/launcher/StandardInterpreterLauncherTest.java @@ -17,17 +17,18 @@ package org.apache.zeppelin.interpreter.launcher; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.Properties; import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.apache.zeppelin.interpreter.InterpreterOption; 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 StandardInterpreterLauncherTest { @Before public void setUp() { @@ -45,26 +46,14 @@ public class StandardInterpreterLauncherTest { properties.setProperty("property_1", "value_1"); 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()); assertEquals(".//local-repo/groupId", interpreterProcess.getLocalRepoDir()); - assertEquals( - ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT.getIntValue(), + assertEquals(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_CONNECT_TIMEOUT.getIntValue(), interpreterProcess.getConnectTimeout()); assertEquals(zConf.getInterpreterRemoteRunnerPath(), interpreterProcess.getInterpreterRunner()); assertEquals(1, interpreterProcess.getEnv().size()); @@ -81,20 +70,9 @@ public class StandardInterpreterLauncherTest { 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()); @@ -104,4 +82,5 @@ public class StandardInterpreterLauncherTest { assertEquals(0, interpreterProcess.getEnv().size()); assertEquals(true, interpreterProcess.isUserImpersonated()); } + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-plugins/notebookrepo/azure/src/main/java/org/apache/zeppelin/notebook/repo/AzureNotebookRepo.java ---------------------------------------------------------------------- diff --git a/zeppelin-plugins/notebookrepo/azure/src/main/java/org/apache/zeppelin/notebook/repo/AzureNotebookRepo.java b/zeppelin-plugins/notebookrepo/azure/src/main/java/org/apache/zeppelin/notebook/repo/AzureNotebookRepo.java index 63725cd..12dbd90 100644 --- a/zeppelin-plugins/notebookrepo/azure/src/main/java/org/apache/zeppelin/notebook/repo/AzureNotebookRepo.java +++ b/zeppelin-plugins/notebookrepo/azure/src/main/java/org/apache/zeppelin/notebook/repo/AzureNotebookRepo.java @@ -30,6 +30,7 @@ import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.net.URISyntaxException; +import java.security.InvalidKeyException; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -43,7 +44,9 @@ import org.apache.zeppelin.user.AuthenticationInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** Azure storage backend for notebooks */ +/** + * Azure storage backend for notebooks + */ public class AzureNotebookRepo implements NotebookRepo { private static final Logger LOG = LoggerFactory.getLogger(AzureNotebookRepo.class); @@ -52,7 +55,9 @@ public class AzureNotebookRepo implements NotebookRepo { private String shareName; private CloudFileDirectory rootDir; - public AzureNotebookRepo() {} + public AzureNotebookRepo() { + + } public void init(ZeppelinConfiguration conf) throws IOException { this.conf = conf; @@ -60,18 +65,15 @@ public class AzureNotebookRepo implements NotebookRepo { shareName = conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_SHARE); try { - CloudStorageAccount account = - CloudStorageAccount.parse( - conf.getString( - ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_CONNECTION_STRING)); + CloudStorageAccount account = CloudStorageAccount.parse( + conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_CONNECTION_STRING)); CloudFileClient client = account.createCloudFileClient(); CloudFileShare share = client.getShareReference(shareName); share.createIfNotExists(); - CloudFileDirectory userDir = - StringUtils.isBlank(user) - ? share.getRootDirectoryReference() - : share.getRootDirectoryReference().getDirectoryReference(user); + CloudFileDirectory userDir = StringUtils.isBlank(user) ? + share.getRootDirectoryReference() : + share.getRootDirectoryReference().getDirectoryReference(user); userDir.createIfNotExists(); rootDir = userDir.getDirectoryReference("notebook"); @@ -126,8 +128,8 @@ public class AzureNotebookRepo implements NotebookRepo { throw new IOException(msg, e); } - String json = - IOUtils.toString(ins, conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_ENCODING)); + String json = IOUtils.toString(ins, + conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_ENCODING)); ins.close(); return Note.fromJson(json); } @@ -197,7 +199,8 @@ public class AzureNotebookRepo implements NotebookRepo { } @Override - public void close() {} + public void close() { + } @Override public List<NotebookRepoSettingsInfo> getSettings(AuthenticationInfo subject) { @@ -209,4 +212,5 @@ public class AzureNotebookRepo implements NotebookRepo { public void updateSettings(Map<String, String> settings, AuthenticationInfo subject) { LOG.warn("Method not implemented"); } + }
