http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/alluxio/src/test/java/org/apache/zeppelin/alluxio/AlluxioInterpreterTest.java ---------------------------------------------------------------------- diff --git a/alluxio/src/test/java/org/apache/zeppelin/alluxio/AlluxioInterpreterTest.java b/alluxio/src/test/java/org/apache/zeppelin/alluxio/AlluxioInterpreterTest.java index 0b0d81d..06711de 100644 --- a/alluxio/src/test/java/org/apache/zeppelin/alluxio/AlluxioInterpreterTest.java +++ b/alluxio/src/test/java/org/apache/zeppelin/alluxio/AlluxioInterpreterTest.java @@ -1,19 +1,37 @@ /** - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at * - * <p>http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * <p>Unless required by applicable law or agreed to in writing, software distributed under the - * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing permissions and + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.zeppelin.alluxio; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; + import alluxio.AlluxioURI; import alluxio.Constants; import alluxio.client.FileSystemTestUtils; @@ -28,22 +46,11 @@ import alluxio.shell.command.CommandUtils; import alluxio.util.FormatUtils; import alluxio.util.io.BufferUtils; import alluxio.util.io.PathUtils; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Properties; + import org.apache.zeppelin.completer.CompletionType; import org.apache.zeppelin.interpreter.InterpreterResult; import org.apache.zeppelin.interpreter.InterpreterResult.Code; import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; public class AlluxioInterpreterTest { private AlluxioInterpreter alluxioInterpreter; @@ -74,29 +81,26 @@ public class AlluxioInterpreterTest { @Test public void testCompletion() { - List expectedResultOne = - Arrays.asList( - new InterpreterCompletion("cat", "cat", CompletionType.command.name()), - new InterpreterCompletion("chgrp", "chgrp", CompletionType.command.name()), - new InterpreterCompletion("chmod", "chmod", CompletionType.command.name()), - new InterpreterCompletion("chown", "chown", CompletionType.command.name()), - new InterpreterCompletion( - "copyFromLocal", "copyFromLocal", CompletionType.command.name()), - new InterpreterCompletion("copyToLocal", "copyToLocal", CompletionType.command.name()), - new InterpreterCompletion("count", "count", CompletionType.command.name()), - new InterpreterCompletion( - "createLineage", "createLineage", CompletionType.command.name())); - List expectedResultTwo = - Arrays.asList( - new InterpreterCompletion( - "copyFromLocal", "copyFromLocal", CompletionType.command.name()), - new InterpreterCompletion("copyToLocal", "copyToLocal", CompletionType.command.name()), - new InterpreterCompletion("count", "count", CompletionType.command.name())); - List expectedResultThree = - Arrays.asList( - new InterpreterCompletion( - "copyFromLocal", "copyFromLocal", CompletionType.command.name()), - new InterpreterCompletion("copyToLocal", "copyToLocal", CompletionType.command.name())); + List expectedResultOne = Arrays.asList( + new InterpreterCompletion("cat", "cat", CompletionType.command.name()), + new InterpreterCompletion("chgrp", "chgrp", CompletionType.command.name()), + new InterpreterCompletion("chmod", "chmod", CompletionType.command.name()), + new InterpreterCompletion("chown", "chown", CompletionType.command.name()), + new InterpreterCompletion("copyFromLocal", "copyFromLocal", CompletionType.command.name()), + new InterpreterCompletion("copyToLocal", "copyToLocal", CompletionType.command.name()), + new InterpreterCompletion("count", "count", CompletionType.command.name()), + new InterpreterCompletion("createLineage", "createLineage", CompletionType.command.name())); + List expectedResultTwo = Arrays.asList( + new InterpreterCompletion("copyFromLocal", "copyFromLocal", + CompletionType.command.name()), + new InterpreterCompletion("copyToLocal", "copyToLocal", + CompletionType.command.name()), + new InterpreterCompletion("count", "count", CompletionType.command.name())); + List expectedResultThree = Arrays.asList( + new InterpreterCompletion("copyFromLocal", "copyFromLocal", + CompletionType.command.name()), + new InterpreterCompletion("copyToLocal", "copyToLocal", + CompletionType.command.name())); List expectedResultNone = new ArrayList<>(); List<InterpreterCompletion> resultOne = alluxioInterpreter.completion("c", 0, null); @@ -119,11 +123,11 @@ public class AlluxioInterpreterTest { @Test public void catDirectoryTest() throws IOException { - String expected = - "Successfully created directory /testDir\n\n" + "Path /testDir must be a file\n"; + String expected = "Successfully created directory /testDir\n\n" + + "Path /testDir must be a file\n"; - InterpreterResult output = - alluxioInterpreter.interpret("mkdir /testDir" + "\ncat /testDir", null); + InterpreterResult output = alluxioInterpreter.interpret("mkdir /testDir" + + "\ncat /testDir", null); Assert.assertEquals(Code.ERROR, output.code()); Assert.assertEquals(expected, output.message().get(0).getData()); @@ -137,20 +141,16 @@ public class AlluxioInterpreterTest { @Test public void catTest() throws IOException { - FileSystemTestUtils.createByteFile(fs, "/testFile", WriteType.MUST_CACHE, 10, 10); + FileSystemTestUtils.createByteFile(fs, "/testFile", WriteType.MUST_CACHE, + 10, 10); InterpreterResult output = alluxioInterpreter.interpret("cat /testFile", null); byte[] expected = BufferUtils.getIncreasingByteArray(10); Assert.assertEquals(Code.SUCCESS, output.code()); - Assert.assertArrayEquals( - expected, - output - .message() - .get(0) - .getData() - .substring(0, output.message().get(0).getData().length() - 1) - .getBytes()); + Assert.assertArrayEquals(expected, + output.message().get(0).getData().substring(0, + output.message().get(0).getData().length() - 1).getBytes()); } @Test @@ -162,12 +162,11 @@ public class AlluxioInterpreterTest { fos.write(toWrite); fos.close(); - InterpreterResult output = - alluxioInterpreter.interpret( - "copyFromLocal " + testFile.getAbsolutePath() + " /testFile", null); + InterpreterResult output = alluxioInterpreter.interpret("copyFromLocal " + + testFile.getAbsolutePath() + " /testFile", null); Assert.assertEquals( - "Copied " + testFile.getAbsolutePath() + " to /testFile\n\n", - output.message().get(0).getData()); + "Copied " + testFile.getAbsolutePath() + " to /testFile\n\n", + output.message().get(0).getData()); long fileLength = fs.getStatus(new AlluxioURI("/testFile")).getLength(); Assert.assertEquals(SIZE_BYTES, fileLength); @@ -196,10 +195,10 @@ public class AlluxioInterpreterTest { FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA", WriteType.CACHE_THROUGH, 10, 10); FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileB", WriteType.MUST_CACHE, 10, 10); - int memPercentageA = - fs.getStatus(new AlluxioURI("/testRoot/testFileA")).getInMemoryPercentage(); - int memPercentageB = - fs.getStatus(new AlluxioURI("/testRoot/testFileB")).getInMemoryPercentage(); + int memPercentageA = fs.getStatus( + new AlluxioURI("/testRoot/testFileA")).getInMemoryPercentage(); + int memPercentageB = fs.getStatus( + new AlluxioURI("/testRoot/testFileB")).getInMemoryPercentage(); Assert.assertFalse(memPercentageA == 0); Assert.assertTrue(memPercentageB == 100); @@ -218,15 +217,16 @@ public class AlluxioInterpreterTest { File testDirInner = new File(mLocalAlluxioCluster.getAlluxioHome() + "/testDir/testDirInner"); testDirInner.mkdir(); File testFile = - generateFileContent("/testDir/testFile", BufferUtils.getIncreasingByteArray(10)); + generateFileContent("/testDir/testFile", BufferUtils.getIncreasingByteArray(10)); - generateFileContent( - "/testDir/testDirInner/testFile2", BufferUtils.getIncreasingByteArray(10, 20)); + generateFileContent("/testDir/testDirInner/testFile2", + BufferUtils.getIncreasingByteArray(10, 20)); - InterpreterResult output = - alluxioInterpreter.interpret("copyFromLocal " + testFile.getParent() + " /testDir", null); + InterpreterResult output = alluxioInterpreter.interpret("copyFromLocal " + + testFile.getParent() + " /testDir", null); Assert.assertEquals( - "Copied " + testFile.getParent() + " to /testDir\n\n", output.message().get(0).getData()); + "Copied " + testFile.getParent() + " to /testDir\n\n", + output.message().get(0).getData()); long fileLength1 = fs.getStatus(new AlluxioURI("/testDir/testFile")).getLength(); long fileLength2 = fs.getStatus(new AlluxioURI("/testDir/testDirInner/testFile2")).getLength(); @@ -246,17 +246,14 @@ public class AlluxioInterpreterTest { @Test public void copyFromLocalTestWithFullURI() throws IOException, AlluxioException { File testFile = generateFileContent("/srcFileURI", BufferUtils.getIncreasingByteArray(10)); - String uri = - "tachyon://" - + mLocalAlluxioCluster.getMasterHostname() - + ":" - + mLocalAlluxioCluster.getMasterPort() - + "/destFileURI"; - - InterpreterResult output = - alluxioInterpreter.interpret("copyFromLocal " + testFile.getPath() + " " + uri, null); + String uri = "tachyon://" + mLocalAlluxioCluster.getMasterHostname() + ":" + + mLocalAlluxioCluster.getMasterPort() + "/destFileURI"; + + InterpreterResult output = alluxioInterpreter.interpret("copyFromLocal " + + testFile.getPath() + " " + uri, null); Assert.assertEquals( - "Copied " + testFile.getPath() + " to " + uri + "\n\n", output.message().get(0).getData()); + "Copied " + testFile.getPath() + " to " + uri + "\n\n", + output.message().get(0).getData()); long fileLength = fs.getStatus(new AlluxioURI("/destFileURI")).getLength(); Assert.assertEquals(10L, fileLength); @@ -299,13 +296,12 @@ public class AlluxioInterpreterTest { private void copyToLocalWithBytes(int bytes) throws IOException { FileSystemTestUtils.createByteFile(fs, "/testFile", WriteType.MUST_CACHE, 10, 10); - InterpreterResult output = - alluxioInterpreter.interpret( - "copyToLocal /testFile " + mLocalAlluxioCluster.getAlluxioHome() + "/testFile", null); + InterpreterResult output = alluxioInterpreter.interpret("copyToLocal /testFile " + + mLocalAlluxioCluster.getAlluxioHome() + "/testFile", null); Assert.assertEquals( - "Copied /testFile to " + mLocalAlluxioCluster.getAlluxioHome() + "/testFile\n\n", - output.message().get(0).getData()); + "Copied /testFile to " + mLocalAlluxioCluster.getAlluxioHome() + "/testFile\n\n", + output.message().get(0).getData()); fileReadTest("/testFile", 10); } @@ -313,17 +309,18 @@ public class AlluxioInterpreterTest { public void countNotExistTest() throws IOException { InterpreterResult output = alluxioInterpreter.interpret("count /NotExistFile", null); Assert.assertEquals(Code.ERROR, output.code()); - Assert.assertEquals( - ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage("/NotExistFile") + "\n", - output.message().get(0).getData()); + Assert.assertEquals(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage("/NotExistFile") + "\n", + output.message().get(0).getData()); } @Test public void countTest() throws IOException { - FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA", WriteType.CACHE_THROUGH, 10, 10); - FileSystemTestUtils.createByteFile( - fs, "/testRoot/testDir/testFileB", WriteType.CACHE_THROUGH, 20, 20); - FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileB", WriteType.CACHE_THROUGH, 30, 30); + FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA", + WriteType.CACHE_THROUGH, 10, 10); + FileSystemTestUtils.createByteFile(fs, "/testRoot/testDir/testFileB", + WriteType.CACHE_THROUGH, 20, 20); + FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileB", + WriteType.CACHE_THROUGH, 30, 30); InterpreterResult output = alluxioInterpreter.interpret("count /testRoot", null); @@ -338,18 +335,16 @@ public class AlluxioInterpreterTest { @Test public void fileinfoNotExistTest() throws IOException { InterpreterResult output = alluxioInterpreter.interpret("fileInfo /NotExistFile", null); - Assert.assertEquals( - ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage("/NotExistFile") + "\n", - output.message().get(0).getData()); + Assert.assertEquals(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage("/NotExistFile") + "\n", + output.message().get(0).getData()); Assert.assertEquals(Code.ERROR, output.code()); } @Test public void locationNotExistTest() throws IOException { InterpreterResult output = alluxioInterpreter.interpret("location /NotExistFile", null); - Assert.assertEquals( - ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage("/NotExistFile") + "\n", - output.message().get(0).getData()); + Assert.assertEquals(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage("/NotExistFile") + "\n", + output.message().get(0).getData()); Assert.assertEquals(Code.ERROR, output.code()); } @@ -357,10 +352,12 @@ public class AlluxioInterpreterTest { public void lsTest() throws IOException, AlluxioException { URIStatus[] files = new URIStatus[3]; - FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA", WriteType.MUST_CACHE, 10, 10); - FileSystemTestUtils.createByteFile( - fs, "/testRoot/testDir/testFileB", WriteType.MUST_CACHE, 20, 20); - FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileC", WriteType.THROUGH, 30, 30); + FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA", + WriteType.MUST_CACHE, 10, 10); + FileSystemTestUtils.createByteFile(fs, "/testRoot/testDir/testFileB", + WriteType.MUST_CACHE, 20, 20); + FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileC", + WriteType.THROUGH, 30, 30); files[0] = fs.getStatus(new AlluxioURI("/testRoot/testFileA")); files[1] = fs.getStatus(new AlluxioURI("/testRoot/testDir")); @@ -370,26 +367,13 @@ public class AlluxioInterpreterTest { String expected = ""; String format = "%-10s%-25s%-15s%-5s\n"; - expected += - String.format( - format, - FormatUtils.getSizeFromBytes(10), - CommandUtils.convertMsToDate(files[0].getCreationTimeMs()), - "In Memory", + expected += String.format(format, FormatUtils.getSizeFromBytes(10), + CommandUtils.convertMsToDate(files[0].getCreationTimeMs()), "In Memory", "/testRoot/testFileA"); - expected += - String.format( - format, - FormatUtils.getSizeFromBytes(0), - CommandUtils.convertMsToDate(files[1].getCreationTimeMs()), - "", - "/testRoot/testDir"); - expected += - String.format( - format, - FormatUtils.getSizeFromBytes(30), - CommandUtils.convertMsToDate(files[2].getCreationTimeMs()), - "Not In Memory", + expected += String.format(format, FormatUtils.getSizeFromBytes(0), + CommandUtils.convertMsToDate(files[1].getCreationTimeMs()), "", "/testRoot/testDir"); + expected += String.format(format, FormatUtils.getSizeFromBytes(30), + CommandUtils.convertMsToDate(files[2].getCreationTimeMs()), "Not In Memory", "/testRoot/testFileC"); expected += "\n"; @@ -401,10 +385,12 @@ public class AlluxioInterpreterTest { public void lsRecursiveTest() throws IOException, AlluxioException { URIStatus[] files = new URIStatus[4]; - FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA", WriteType.MUST_CACHE, 10, 10); - FileSystemTestUtils.createByteFile( - fs, "/testRoot/testDir/testFileB", WriteType.MUST_CACHE, 20, 20); - FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileC", WriteType.THROUGH, 30, 30); + FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA", + WriteType.MUST_CACHE, 10, 10); + FileSystemTestUtils.createByteFile(fs, "/testRoot/testDir/testFileB", + WriteType.MUST_CACHE, 20, 20); + FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileC", + WriteType.THROUGH, 30, 30); files[0] = fs.getStatus(new AlluxioURI("/testRoot/testFileA")); files[1] = fs.getStatus(new AlluxioURI("/testRoot/testDir")); @@ -416,33 +402,21 @@ public class AlluxioInterpreterTest { String expected = ""; String format = "%-10s%-25s%-15s%-5s\n"; expected += - String.format( - format, - FormatUtils.getSizeFromBytes(10), - CommandUtils.convertMsToDate(files[0].getCreationTimeMs()), - "In Memory", - "/testRoot/testFileA"); + String.format(format, FormatUtils.getSizeFromBytes(10), + CommandUtils.convertMsToDate(files[0].getCreationTimeMs()), "In Memory", + "/testRoot/testFileA"); expected += - String.format( - format, - FormatUtils.getSizeFromBytes(0), - CommandUtils.convertMsToDate(files[1].getCreationTimeMs()), - "", - "/testRoot/testDir"); + String.format(format, FormatUtils.getSizeFromBytes(0), + CommandUtils.convertMsToDate(files[1].getCreationTimeMs()), "", + "/testRoot/testDir"); expected += - String.format( - format, - FormatUtils.getSizeFromBytes(20), - CommandUtils.convertMsToDate(files[2].getCreationTimeMs()), - "In Memory", - "/testRoot/testDir/testFileB"); + String.format(format, FormatUtils.getSizeFromBytes(20), + CommandUtils.convertMsToDate(files[2].getCreationTimeMs()), "In Memory", + "/testRoot/testDir/testFileB"); expected += - String.format( - format, - FormatUtils.getSizeFromBytes(30), - CommandUtils.convertMsToDate(files[3].getCreationTimeMs()), - "Not In Memory", - "/testRoot/testFileC"); + String.format(format, FormatUtils.getSizeFromBytes(30), + CommandUtils.convertMsToDate(files[3].getCreationTimeMs()), "Not In Memory", + "/testRoot/testFileC"); expected += "\n"; Assert.assertEquals(expected, output.message().get(0).getData()); @@ -450,13 +424,13 @@ public class AlluxioInterpreterTest { @Test public void mkdirComplexPathTest() throws IOException, AlluxioException { - InterpreterResult output = - alluxioInterpreter.interpret("mkdir /Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File", null); + InterpreterResult output = alluxioInterpreter.interpret( + "mkdir /Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File", null); boolean existsDir = fs.exists(new AlluxioURI("/Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File")); Assert.assertEquals( - "Successfully created directory /Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File\n\n", - output.message().get(0).getData()); + "Successfully created directory /Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File\n\n", + output.message().get(0).getData()); Assert.assertTrue(existsDir); } @@ -470,7 +444,8 @@ public class AlluxioInterpreterTest { @Test public void mkdirInvalidPathTest() throws IOException { Assert.assertEquals( - Code.ERROR, alluxioInterpreter.interpret("mkdir /test File Invalid Path", null).code()); + Code.ERROR, + alluxioInterpreter.interpret("mkdir /test File Invalid Path", null).code()); } @Test @@ -478,27 +453,26 @@ public class AlluxioInterpreterTest { InterpreterResult output = alluxioInterpreter.interpret("mkdir /root/testFile1", null); boolean existsDir = fs.exists(new AlluxioURI("/root/testFile1")); Assert.assertEquals( - "Successfully created directory /root/testFile1\n\n", output.message().get(0).getData()); + "Successfully created directory /root/testFile1\n\n", + output.message().get(0).getData()); Assert.assertTrue(existsDir); } @Test public void mkdirTest() throws IOException, AlluxioException { String qualifiedPath = - "tachyon://" - + mLocalAlluxioCluster.getMasterHostname() - + ":" - + mLocalAlluxioCluster.getMasterPort() - + "/root/testFile1"; + "tachyon://" + mLocalAlluxioCluster.getMasterHostname() + ":" + + mLocalAlluxioCluster.getMasterPort() + "/root/testFile1"; InterpreterResult output = alluxioInterpreter.interpret("mkdir " + qualifiedPath, null); boolean existsDir = fs.exists(new AlluxioURI("/root/testFile1")); Assert.assertEquals( - "Successfully created directory " + qualifiedPath + "\n\n", - output.message().get(0).getData()); + "Successfully created directory " + qualifiedPath + "\n\n", + output.message().get(0).getData()); Assert.assertTrue(existsDir); } - private File generateFileContent(String path, byte[] toWrite) throws IOException { + private File generateFileContent(String path, byte[] toWrite) + throws IOException { File testFile = new File(mLocalAlluxioCluster.getAlluxioHome() + path); testFile.createNewFile(); FileOutputStream fos = new FileOutputStream(testFile);
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/angular/pom.xml ---------------------------------------------------------------------- diff --git a/angular/pom.xml b/angular/pom.xml index f9d7448..47ffbf3 100644 --- a/angular/pom.xml +++ b/angular/pom.xml @@ -72,6 +72,13 @@ <plugin> <artifactId>maven-resources-plugin</artifactId> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <configuration> + <skip>false</skip> + </configuration> + </plugin> </plugins> </build> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/angular/src/main/java/org/apache/zeppelin/angular/AngularInterpreter.java ---------------------------------------------------------------------- diff --git a/angular/src/main/java/org/apache/zeppelin/angular/AngularInterpreter.java b/angular/src/main/java/org/apache/zeppelin/angular/AngularInterpreter.java index 12fdd25..696e450 100644 --- a/angular/src/main/java/org/apache/zeppelin/angular/AngularInterpreter.java +++ b/angular/src/main/java/org/apache/zeppelin/angular/AngularInterpreter.java @@ -20,6 +20,7 @@ package org.apache.zeppelin.angular; import java.util.LinkedList; import java.util.List; import java.util.Properties; + import org.apache.zeppelin.interpreter.Interpreter; import org.apache.zeppelin.interpreter.InterpreterContext; import org.apache.zeppelin.interpreter.InterpreterResult; @@ -29,7 +30,9 @@ import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; import org.apache.zeppelin.scheduler.Scheduler; import org.apache.zeppelin.scheduler.SchedulerFactory; -/** */ +/** + * + */ public class AngularInterpreter extends Interpreter { public AngularInterpreter(Properties property) { @@ -37,10 +40,12 @@ public class AngularInterpreter extends Interpreter { } @Override - public void open() {} + public void open() { + } @Override - public void close() {} + public void close() { + } @Override public InterpreterResult interpret(String st, InterpreterContext context) { @@ -48,7 +53,8 @@ public class AngularInterpreter extends Interpreter { } @Override - public void cancel(InterpreterContext context) {} + public void cancel(InterpreterContext context) { + } @Override public FormType getFormType() { @@ -61,14 +67,14 @@ public class AngularInterpreter extends Interpreter { } @Override - public List<InterpreterCompletion> completion( - String buf, int cursor, InterpreterContext interpreterContext) { + public List<InterpreterCompletion> completion(String buf, int cursor, + InterpreterContext interpreterContext) { return new LinkedList<>(); } @Override public Scheduler getScheduler() { - return SchedulerFactory.singleton() - .createOrGetFIFOScheduler(AngularInterpreter.class.getName() + this.hashCode()); + return SchedulerFactory.singleton().createOrGetFIFOScheduler( + AngularInterpreter.class.getName() + this.hashCode()); } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/beam/pom.xml ---------------------------------------------------------------------- diff --git a/beam/pom.xml b/beam/pom.xml index 77203f7..1ad5b87 100644 --- a/beam/pom.xml +++ b/beam/pom.xml @@ -259,6 +259,13 @@ <plugin> <artifactId>maven-resources-plugin</artifactId> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <configuration> + <skip>false</skip> + </configuration> + </plugin> </plugins> </build> </project> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/beam/src/main/java/org/apache/zeppelin/beam/BeamInterpreter.java ---------------------------------------------------------------------- diff --git a/beam/src/main/java/org/apache/zeppelin/beam/BeamInterpreter.java b/beam/src/main/java/org/apache/zeppelin/beam/BeamInterpreter.java index 5ab271e..06ab33b 100644 --- a/beam/src/main/java/org/apache/zeppelin/beam/BeamInterpreter.java +++ b/beam/src/main/java/org/apache/zeppelin/beam/BeamInterpreter.java @@ -17,13 +17,17 @@ package org.apache.zeppelin.beam; -import java.util.Properties; import org.apache.zeppelin.java.JavaInterpreter; -/** Beam interpreter */ +import java.util.Properties; + +/** + * Beam interpreter + */ public class BeamInterpreter extends JavaInterpreter { public BeamInterpreter(Properties property) { super(property); } + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/bigquery/pom.xml ---------------------------------------------------------------------- diff --git a/bigquery/pom.xml b/bigquery/pom.xml index c116c2f..66fe3f2 100644 --- a/bigquery/pom.xml +++ b/bigquery/pom.xml @@ -133,6 +133,13 @@ </descriptorRefs> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <configuration> + <skip>false</skip> + </configuration> + </plugin> </plugins> </build> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java ---------------------------------------------------------------------- diff --git a/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java b/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java index 3c6dd6f..0973fda 100644 --- a/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java +++ b/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java @@ -36,6 +36,10 @@ import com.google.api.services.bigquery.model.TableCell; import com.google.api.services.bigquery.model.TableFieldSchema; import com.google.api.services.bigquery.model.TableRow; import com.google.common.base.Function; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -43,6 +47,7 @@ import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; import java.util.Properties; + import org.apache.zeppelin.interpreter.Interpreter; import org.apache.zeppelin.interpreter.InterpreterContext; import org.apache.zeppelin.interpreter.InterpreterResult; @@ -50,37 +55,35 @@ import org.apache.zeppelin.interpreter.InterpreterResult.Code; import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; import org.apache.zeppelin.scheduler.Scheduler; import org.apache.zeppelin.scheduler.SchedulerFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * BigQuery interpreter for Zeppelin. - * + * * <ul> * <li>{@code zeppelin.bigquery.project_id} - Project ID in GCP</li> * <li>{@code zeppelin.bigquery.wait_time} - Query Timeout in ms</li> * <li>{@code zeppelin.bigquery.max_no_of_rows} - Max Result size</li> * </ul> - * + * * <p> * How to use: <br/> * {@code %bigquery.sql<br/> * {@code - * SELECT departure_airport,count(case when departure_delay>0 then 1 else 0 end) as no_of_delays - * FROM [bigquery-samples:airline_ontime_data.flights] - * group by departure_airport - * order by 2 desc + * SELECT departure_airport,count(case when departure_delay>0 then 1 else 0 end) as no_of_delays + * FROM [bigquery-samples:airline_ontime_data.flights] + * group by departure_airport + * order by 2 desc * limit 10 * } * </p> - * + * */ public class BigQueryInterpreter extends Interpreter { private static Logger logger = LoggerFactory.getLogger(BigQueryInterpreter.class); private static final char NEWLINE = '\n'; private static final char TAB = '\t'; private static Bigquery service = null; - // Mutex created to create the singleton in thread-safe fashion. + //Mutex created to create the singleton in thread-safe fashion. private static Object serviceLock = new Object(); static final String PROJECT_ID = "zeppelin.bigquery.project_id"; @@ -96,16 +99,16 @@ public class BigQueryInterpreter extends Interpreter { private static final Function<CharSequence, String> sequenceToStringTransformer = new Function<CharSequence, String>() { - public String apply(CharSequence seq) { - return seq.toString(); - } - }; + public String apply(CharSequence seq) { + return seq.toString(); + } + }; public BigQueryInterpreter(Properties property) { super(property); } - // Function to return valid BigQuery Service + //Function to return valid BigQuery Service @Override public void open() { if (service == null) { @@ -117,7 +120,7 @@ public class BigQueryInterpreter extends Interpreter { logger.info("Opened BigQuery SQL Connection"); } catch (IOException e) { logger.error("Cannot open connection", e); - exceptionOnConnect = e; + exceptionOnConnect = e; close(); } } @@ -125,11 +128,11 @@ public class BigQueryInterpreter extends Interpreter { } } - // Function that Creates an authorized client to Google Bigquery. + //Function that Creates an authorized client to Google Bigquery. private static Bigquery createAuthorizedClient() throws IOException { HttpTransport transport = new NetHttpTransport(); JsonFactory jsonFactory = new JacksonFactory(); - GoogleCredential credential = GoogleCredential.getApplicationDefault(transport, jsonFactory); + GoogleCredential credential = GoogleCredential.getApplicationDefault(transport, jsonFactory); if (credential.createScopedRequired()) { Collection<String> bigqueryScopes = BigqueryScopes.all(); @@ -137,16 +140,15 @@ public class BigQueryInterpreter extends Interpreter { } return new Bigquery.Builder(transport, jsonFactory, credential) - .setApplicationName("Zeppelin/1.0 (GPN:Apache Zeppelin;)") - .build(); + .setApplicationName("Zeppelin/1.0 (GPN:Apache Zeppelin;)").build(); } - // Function that generates and returns the schema and the rows as string + //Function that generates and returns the schema and the rows as string public static String printRows(final GetQueryResultsResponse response) { StringBuilder msg = new StringBuilder(); try { List<String> schemNames = new ArrayList<String>(); - for (TableFieldSchema schem : response.getSchema().getFields()) { + for (TableFieldSchema schem: response.getSchema().getFields()) { schemNames.add(schem.getName()); } msg.append(Joiner.on(TAB).join(schemNames)); @@ -165,34 +167,32 @@ public class BigQueryInterpreter extends Interpreter { } } - // Function to poll a job for completion. Future use - public static Job pollJob(final Bigquery.Jobs.Get request, final long interval) + //Function to poll a job for completion. Future use + public static Job pollJob(final Bigquery.Jobs.Get request, final long interval) throws IOException, InterruptedException { Job job = request.execute(); while (!job.getStatus().getState().equals("DONE")) { - System.out.println( - "Job is " + job.getStatus().getState() + " waiting " + interval + " milliseconds..."); + System.out.println("Job is " + + job.getStatus().getState() + + " waiting " + interval + " milliseconds..."); Thread.sleep(interval); job = request.execute(); } return job; } - // Function to page through the results of an arbitrary bigQuery request + //Function to page through the results of an arbitrary bigQuery request public static <T extends GenericJson> Iterator<T> getPages( final BigqueryRequest<T> requestTemplate) { class PageIterator implements Iterator<T> { private BigqueryRequest<T> request; private boolean hasNext = true; - PageIterator(final BigqueryRequest<T> requestTemplate) { this.request = requestTemplate; } - public boolean hasNext() { return hasNext; } - public T next() { if (!hasNext) { throw new NoSuchElementException(); @@ -217,8 +217,8 @@ public class BigQueryInterpreter extends Interpreter { return new PageIterator(requestTemplate); } - - // Function to call bigQuery to run SQL and return results to the Interpreter for output + + //Function to call bigQuery to run SQL and return results to the Interpreter for output private InterpreterResult executeSql(String sql) { int counter = 0; StringBuilder finalmessage = null; @@ -256,31 +256,25 @@ public class BigQueryInterpreter extends Interpreter { } } - // Function to run the SQL on bigQuery service - public static Iterator<GetQueryResultsResponse> run( - final String queryString, - final String projId, - final long wTime, - final long maxRows, - Boolean useLegacySql) - throws IOException { + //Function to run the SQL on bigQuery service + public static Iterator<GetQueryResultsResponse> run(final String queryString, + final String projId, final long wTime, final long maxRows, Boolean useLegacySql) + throws IOException { try { logger.info("Use legacy sql: {}", useLegacySql); QueryResponse query; - query = - service - .jobs() - .query( - projId, - new QueryRequest() - .setTimeoutMs(wTime) - .setUseLegacySql(useLegacySql) - .setQuery(queryString) - .setMaxResults(maxRows)) - .execute(); + query = service + .jobs() + .query( + projId, + new QueryRequest().setTimeoutMs(wTime) + .setUseLegacySql(useLegacySql).setQuery(queryString) + .setMaxResults(maxRows)).execute(); jobId = query.getJobReference().getJobId(); projectId = query.getJobReference().getProjectId(); - GetQueryResults getRequest = service.jobs().getQueryResults(projectId, jobId); + GetQueryResults getRequest = service.jobs().getQueryResults( + projectId, + jobId); return getPages(getRequest); } catch (IOException ex) { throw ex; @@ -302,8 +296,8 @@ public class BigQueryInterpreter extends Interpreter { @Override public Scheduler getScheduler() { - return SchedulerFactory.singleton() - .createOrGetFIFOScheduler(BigQueryInterpreter.class.getName() + this.hashCode()); + return SchedulerFactory.singleton().createOrGetFIFOScheduler( + BigQueryInterpreter.class.getName() + this.hashCode()); } @Override @@ -335,8 +329,8 @@ public class BigQueryInterpreter extends Interpreter { } @Override - public List<InterpreterCompletion> completion( - String buf, int cursor, InterpreterContext interpreterContext) { + public List<InterpreterCompletion> completion(String buf, int cursor, + InterpreterContext interpreterContext) { return NO_COMPLETION; } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTest.java ---------------------------------------------------------------------- diff --git a/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTest.java b/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTest.java index b5411c8..9dcd9f8 100644 --- a/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTest.java +++ b/bigquery/src/test/java/org/apache/zeppelin/bigquery/BigQueryInterpreterTest.java @@ -21,15 +21,18 @@ import static org.junit.Assert.assertEquals; import com.google.gson.Gson; import com.google.gson.JsonIOException; import com.google.gson.JsonSyntaxException; + +import org.junit.Before; +import org.junit.Test; + import java.io.FileNotFoundException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Properties; + import org.apache.zeppelin.interpreter.InterpreterContext; import org.apache.zeppelin.interpreter.InterpreterGroup; import org.apache.zeppelin.interpreter.InterpreterResult; -import org.junit.Before; -import org.junit.Test; public class BigQueryInterpreterTest { protected static class Constants { @@ -45,7 +48,7 @@ public class BigQueryInterpreterTest { return oneQuery; } - public String getWrong() { + public String getWrong() { return wrongQuery; } } @@ -95,8 +98,8 @@ public class BigQueryInterpreterTest { @Test public void testWithQueryPrefix() { - InterpreterResult ret = - bqInterpreter.interpret("#standardSQL\n WITH t AS (select 1) SELECT * FROM t", context); + InterpreterResult ret = bqInterpreter.interpret( + "#standardSQL\n WITH t AS (select 1) SELECT * FROM t", context); assertEquals(InterpreterResult.Code.SUCCESS, ret.code()); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/cassandra/pom.xml ---------------------------------------------------------------------- diff --git a/cassandra/pom.xml b/cassandra/pom.xml index a07ed82..c5b08f7 100644 --- a/cassandra/pom.xml +++ b/cassandra/pom.xml @@ -249,6 +249,13 @@ <plugin> <artifactId>maven-resources-plugin</artifactId> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <configuration> + <skip>false</skip> + </configuration> + </plugin> </plugins> </build> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/cassandra/src/main/java/org/apache/zeppelin/cassandra/CassandraInterpreter.java ---------------------------------------------------------------------- diff --git a/cassandra/src/main/java/org/apache/zeppelin/cassandra/CassandraInterpreter.java b/cassandra/src/main/java/org/apache/zeppelin/cassandra/CassandraInterpreter.java index 65e40e5..105e271 100644 --- a/cassandra/src/main/java/org/apache/zeppelin/cassandra/CassandraInterpreter.java +++ b/cassandra/src/main/java/org/apache/zeppelin/cassandra/CassandraInterpreter.java @@ -18,10 +18,9 @@ package org.apache.zeppelin.cassandra; import static java.lang.Integer.parseInt; -import com.datastax.driver.core.Cluster; -import com.datastax.driver.core.JdkSSLOptions; -import com.datastax.driver.core.ProtocolOptions.Compression; -import com.datastax.driver.core.Session; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Paths; @@ -29,24 +28,31 @@ import java.security.KeyStore; import java.util.ArrayList; import java.util.List; import java.util.Properties; + import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManagerFactory; + +import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.JdkSSLOptions; +import com.datastax.driver.core.ProtocolOptions.Compression; +import com.datastax.driver.core.Session; + import org.apache.zeppelin.interpreter.Interpreter; import org.apache.zeppelin.interpreter.InterpreterContext; import org.apache.zeppelin.interpreter.InterpreterResult; import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; import org.apache.zeppelin.scheduler.Scheduler; import org.apache.zeppelin.scheduler.SchedulerFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -/** Interpreter for Apache Cassandra CQL query language. */ +/** + * Interpreter for Apache Cassandra CQL query language. + */ public class CassandraInterpreter extends Interpreter { private static final Logger LOGGER = LoggerFactory.getLogger(CassandraInterpreter.class); public static final String CASSANDRA_INTERPRETER_PARALLELISM = - "cassandra.interpreter.parallelism"; + "cassandra.interpreter.parallelism"; public static final String CASSANDRA_HOSTS = "cassandra.hosts"; public static final String CASSANDRA_PORT = "cassandra.native.port"; public static final String CASSANDRA_PROTOCOL_VERSION = "cassandra.protocol.version"; @@ -59,54 +65,62 @@ public class CassandraInterpreter extends Interpreter { public static final String CASSANDRA_RETRY_POLICY = "cassandra.retry.policy"; public static final String CASSANDRA_RECONNECTION_POLICY = "cassandra.reconnection.policy"; public static final String CASSANDRA_SPECULATIVE_EXECUTION_POLICY = - "cassandra.speculative.execution.policy"; + "cassandra.speculative.execution.policy"; public static final String CASSANDRA_MAX_SCHEMA_AGREEMENT_WAIT_SECONDS = - "cassandra.max.schema.agreement.wait.second"; + "cassandra.max.schema.agreement.wait.second"; public static final String CASSANDRA_POOLING_NEW_CONNECTION_THRESHOLD_LOCAL = - "cassandra.pooling.new.connection.threshold.local"; + "cassandra.pooling.new.connection.threshold.local"; public static final String CASSANDRA_POOLING_NEW_CONNECTION_THRESHOLD_REMOTE = - "cassandra.pooling.new.connection.threshold.remote"; + "cassandra.pooling.new.connection.threshold.remote"; public static final String CASSANDRA_POOLING_MAX_CONNECTION_PER_HOST_LOCAL = - "cassandra.pooling.max.connection.per.host.local"; + "cassandra.pooling.max.connection.per.host.local"; public static final String CASSANDRA_POOLING_MAX_CONNECTION_PER_HOST_REMOTE = - "cassandra.pooling.max.connection.per.host.remote"; + "cassandra.pooling.max.connection.per.host.remote"; public static final String CASSANDRA_POOLING_CORE_CONNECTION_PER_HOST_LOCAL = - "cassandra.pooling.core.connection.per.host.local"; + "cassandra.pooling.core.connection.per.host.local"; public static final String CASSANDRA_POOLING_CORE_CONNECTION_PER_HOST_REMOTE = - "cassandra.pooling.core.connection.per.host.remote"; + "cassandra.pooling.core.connection.per.host.remote"; public static final String CASSANDRA_POOLING_MAX_REQUESTS_PER_CONNECTION_LOCAL = - "cassandra.pooling.max.request.per.connection.local"; + "cassandra.pooling.max.request.per.connection.local"; public static final String CASSANDRA_POOLING_MAX_REQUESTS_PER_CONNECTION_REMOTE = - "cassandra.pooling.max.request.per.connection.remote"; + "cassandra.pooling.max.request.per.connection.remote"; public static final String CASSANDRA_POOLING_IDLE_TIMEOUT_SECONDS = - "cassandra.pooling.idle.timeout.seconds"; + "cassandra.pooling.idle.timeout.seconds"; public static final String CASSANDRA_POOLING_POOL_TIMEOUT_MILLIS = - "cassandra.pooling.pool.timeout.millisecs"; + "cassandra.pooling.pool.timeout.millisecs"; public static final String CASSANDRA_POOLING_HEARTBEAT_INTERVAL_SECONDS = - "cassandra.pooling.heartbeat.interval.seconds"; + "cassandra.pooling.heartbeat.interval.seconds"; public static final String CASSANDRA_QUERY_DEFAULT_CONSISTENCY = - "cassandra.query.default.consistency"; + "cassandra.query.default.consistency"; public static final String CASSANDRA_QUERY_DEFAULT_SERIAL_CONSISTENCY = - "cassandra.query.default.serial.consistency"; + "cassandra.query.default.serial.consistency"; public static final String CASSANDRA_QUERY_DEFAULT_FETCH_SIZE = - "cassandra.query.default.fetchSize"; + "cassandra.query.default.fetchSize"; public static final String CASSANDRA_QUERY_DEFAULT_IDEMPOTENCE = - "cassandra.query.default.idempotence"; + "cassandra.query.default.idempotence"; public static final String CASSANDRA_SOCKET_CONNECTION_TIMEOUT_MILLIS = - "cassandra.socket.connection.timeout.millisecs"; - public static final String CASSANDRA_SOCKET_KEEP_ALIVE = "cassandra.socket.keep.alive"; + "cassandra.socket.connection.timeout.millisecs"; + public static final String CASSANDRA_SOCKET_KEEP_ALIVE = + "cassandra.socket.keep.alive"; public static final String CASSANDRA_SOCKET_READ_TIMEOUT_MILLIS = - "cassandra.socket.read.timeout.millisecs"; + "cassandra.socket.read.timeout.millisecs"; public static final String CASSANDRA_SOCKET_RECEIVED_BUFFER_SIZE_BYTES = - "cassandra.socket.received.buffer.size.bytes"; - public static final String CASSANDRA_SOCKET_REUSE_ADDRESS = "cassandra.socket.reuse.address"; + "cassandra.socket.received.buffer.size.bytes"; + public static final String CASSANDRA_SOCKET_REUSE_ADDRESS = + "cassandra.socket.reuse.address"; public static final String CASSANDRA_SOCKET_SEND_BUFFER_SIZE_BYTES = - "cassandra.socket.send.buffer.size.bytes"; - public static final String CASSANDRA_SOCKET_SO_LINGER = "cassandra.socket.soLinger"; - public static final String CASSANDRA_SOCKET_TCP_NO_DELAY = "cassandra.socket.tcp.no_delay"; - public static final String CASSANDRA_WITH_SSL = "cassandra.ssl.enabled"; - public static final String CASSANDRA_TRUSTSTORE_PATH = "cassandra.ssl.truststore.path"; - public static final String CASSANDRA_TRUSTSTORE_PASSWORD = "cassandra.ssl.truststore.password"; + "cassandra.socket.send.buffer.size.bytes"; + public static final String CASSANDRA_SOCKET_SO_LINGER = + "cassandra.socket.soLinger"; + public static final String CASSANDRA_SOCKET_TCP_NO_DELAY = + "cassandra.socket.tcp.no_delay"; + public static final String CASSANDRA_WITH_SSL = + "cassandra.ssl.enabled"; + public static final String CASSANDRA_TRUSTSTORE_PATH = + "cassandra.ssl.truststore.path"; + public static final String CASSANDRA_TRUSTSTORE_PASSWORD = + "cassandra.ssl.truststore.password"; + public static final String DEFAULT_HOST = "localhost"; public static final String DEFAULT_PORT = "9042"; @@ -163,30 +177,25 @@ public class CassandraInterpreter extends Interpreter { hosts.append(address).append(","); } - LOGGER.info( - "Bootstrapping Cassandra Java Driver to connect to " - + hosts.toString() - + "on port " - + port); + LOGGER.info("Bootstrapping Cassandra Java Driver to connect to " + hosts.toString() + + "on port " + port); Compression compression = driverConfig.getCompressionProtocol(this); - clusterBuilder = - Cluster.builder() + clusterBuilder = Cluster.builder() .addContactPoints(addresses) .withPort(port) .withProtocolVersion(driverConfig.getProtocolVersion(this)) .withClusterName(getProperty(CASSANDRA_CLUSTER_NAME)) .withCompression(compression) - .withCredentials( - getProperty(CASSANDRA_CREDENTIALS_USERNAME), - getProperty(CASSANDRA_CREDENTIALS_PASSWORD)) + .withCredentials(getProperty(CASSANDRA_CREDENTIALS_USERNAME), + getProperty(CASSANDRA_CREDENTIALS_PASSWORD)) .withLoadBalancingPolicy(driverConfig.getLoadBalancingPolicy(this)) .withRetryPolicy(driverConfig.getRetryPolicy(this)) .withReconnectionPolicy(driverConfig.getReconnectionPolicy(this)) .withSpeculativeExecutionPolicy(driverConfig.getSpeculativeExecutionPolicy(this)) .withMaxSchemaAgreementWaitSeconds( - parseInt(getProperty(CASSANDRA_MAX_SCHEMA_AGREEMENT_WAIT_SECONDS))) + parseInt(getProperty(CASSANDRA_MAX_SCHEMA_AGREEMENT_WAIT_SECONDS))) .withPoolingOptions(driverConfig.getPoolingOptions(this)) .withQueryOptions(driverConfig.getQueryOptions(this)) .withSocketOptions(driverConfig.getSocketOptions(this)); @@ -199,19 +208,20 @@ public class CassandraInterpreter extends Interpreter { final SSLContext sslContext; { final KeyStore trustStore = KeyStore.getInstance("JKS"); - final InputStream stream = - Files.newInputStream(Paths.get(getProperty(CASSANDRA_TRUSTSTORE_PATH))); + final InputStream stream = Files.newInputStream(Paths.get( + getProperty(CASSANDRA_TRUSTSTORE_PATH))); trustStore.load(stream, getProperty(CASSANDRA_TRUSTSTORE_PASSWORD).toCharArray()); - final TrustManagerFactory trustManagerFactory = - TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance( + TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(trustStore); sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, trustManagerFactory.getTrustManagers(), null); } - clusterBuilder = - clusterBuilder.withSSL(JdkSSLOptions.builder().withSSLContext(sslContext).build()); + clusterBuilder = clusterBuilder.withSSL(JdkSSLOptions.builder() + .withSSLContext(sslContext) + .build()); } catch (Exception e) { LOGGER.error(e.toString()); } @@ -236,7 +246,8 @@ public class CassandraInterpreter extends Interpreter { } @Override - public void cancel(InterpreterContext context) {} + public void cancel(InterpreterContext context) { + } @Override public FormType getFormType() { @@ -249,16 +260,15 @@ public class CassandraInterpreter extends Interpreter { } @Override - public List<InterpreterCompletion> completion( - String buf, int cursor, InterpreterContext interpreterContext) { + public List<InterpreterCompletion> completion(String buf, int cursor, + InterpreterContext interpreterContext) { return NO_COMPLETION; } @Override public Scheduler getScheduler() { return SchedulerFactory.singleton() - .createOrGetParallelScheduler( - CassandraInterpreter.class.getName() + this.hashCode(), - parseInt(getProperty(CASSANDRA_INTERPRETER_PARALLELISM))); + .createOrGetParallelScheduler(CassandraInterpreter.class.getName() + this.hashCode(), + parseInt(getProperty(CASSANDRA_INTERPRETER_PARALLELISM))); } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/cassandra/src/main/java/org/apache/zeppelin/cassandra/ParsingException.java ---------------------------------------------------------------------- diff --git a/cassandra/src/main/java/org/apache/zeppelin/cassandra/ParsingException.java b/cassandra/src/main/java/org/apache/zeppelin/cassandra/ParsingException.java index 20e1971..b87e8b2 100644 --- a/cassandra/src/main/java/org/apache/zeppelin/cassandra/ParsingException.java +++ b/cassandra/src/main/java/org/apache/zeppelin/cassandra/ParsingException.java @@ -16,8 +16,10 @@ */ package org.apache.zeppelin.cassandra; -/** Parsing Exception for Cassandra CQL statement. */ -public class ParsingException extends RuntimeException { +/** + * Parsing Exception for Cassandra CQL statement. + */ +public class ParsingException extends RuntimeException{ public ParsingException(String message) { super(message); }
