Repository: zeppelin Updated Branches: refs/heads/master e5e3a88cd -> 4668da159
[MINOR] Change `case` indent ### What is this PR for? Changing style in case of 'case'. Zeppelin has two spaces as default indentation but checkstyle has different style of 'case'. ### What type of PR is it? [Bug Fix] ### Todos * [x] - Change style and adopt it ### What is the Jira issue? N/A ### How should this be tested? N/A ### Screenshots (if appropriate) ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Jongyoul Lee <jongy...@gmail.com> Closes #2336 from jongyoul/minor/change-case-indent and squashes the following commits: 26788c5f [Jongyoul Lee] Adopted new style f95418f7 [Jongyoul Lee] Changed case indentation to 2 7d404a17 [Jongyoul Lee] Reformatted xml Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/4668da15 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/4668da15 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/4668da15 Branch: refs/heads/master Commit: 4668da159fbd2b2243fbb3fedd55f2dc42beb64d Parents: e5e3a88 Author: Jongyoul Lee <jongy...@gmail.com> Authored: Wed May 10 15:22:57 2017 +0900 Committer: Jongyoul Lee <jongy...@apache.org> Committed: Fri May 12 11:59:40 2017 +0900 ---------------------------------------------------------------------- _tools/checkstyle.xml | 507 ++++++++++--------- .../apache/zeppelin/jdbc/JDBCInterpreter.java | 60 +-- .../jdbc/security/JDBCSecurityImpl.java | 28 +- .../shell/security/ShellSecurityImpl.java | 26 +- .../apache/zeppelin/socket/NotebookServer.java | 284 +++++------ .../apache/zeppelin/utils/CommandLineUtils.java | 12 +- .../interpreter/install/InstallInterpreter.java | 74 +-- .../websocket/ZeppelinhubClient.java | 12 +- 8 files changed, 502 insertions(+), 501 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4668da15/_tools/checkstyle.xml ---------------------------------------------------------------------- diff --git a/_tools/checkstyle.xml b/_tools/checkstyle.xml index 618d74d..cdb8fbf 100644 --- a/_tools/checkstyle.xml +++ b/_tools/checkstyle.xml @@ -15,268 +15,269 @@ limitations under the License. --> <!DOCTYPE module PUBLIC - "-//Puppy Crawl//DTD Check Configuration 1.3//EN" - "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> + "-//Puppy Crawl//DTD Check Configuration 1.3//EN" + "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> <!-- This is a checkstyle configuration file. For descriptions of what the following rules do, please see the checkstyle configuration page at http://checkstyle.sourceforge.net/config.html --> <module name="Checker"> - <module name="FileTabCharacter"> - <!-- Checks that there are no tab characters in the file. --> - </module> - - <module name="NewlineAtEndOfFile"> - <property name="lineSeparator" value="lf" /> - </module> - - <module name="RegexpSingleline"> - <!-- Checks that FIXME is not used in comments. TODO is preferred. --> - <property name="format" value="((//.*)|(\*.*))FIXME" /> - <property name="message" - value='TODO is preferred to FIXME. e.g. "TODO(johndoe): Refactor when v2 is released."' /> - </module> - - <module name="RegexpSingleline"> - <!-- Checks that TODOs are named. (Actually, just that they are followed - by an open paren.) --> - <property name="format" value="((//.*)|(\*.*))TODO[^(]" /> - <property name="message" - value='All TODOs should be named. e.g. "TODO(johndoe): Refactor when v2 is released."' /> - </module> - - <!-- <module name="JavadocPackage"> - Checks that each Java package has - a Javadoc file used for commenting. Only allows a package-info.java, not - package.html. </module> --> - <!-- All Java AST specific tests live under TreeWalker module. --> - <module name="TreeWalker"> - - <!-- IMPORT CHECKS --> - - <module name="RedundantImport"> - <!-- Checks for redundant import statements. --> - <property name="severity" value="error" /> - </module> - <!-- <module name="ImportOrder"> Checks for out of order import statements - <property name="severity" value="warning"/> <property name="groups" value="com.google,android,junit,net,org,java,javax"/> - This ensures that static imports go first <property name="option" value="top"/> - <property name="tokens" value="STATIC_IMPORT, IMPORT"/> </module> --> - <!-- JAVADOC CHECKS --> - - <!-- Checks for Javadoc comments. --> - <!-- See http://checkstyle.sf.net/config_javadoc.html --> - <module name="JavadocMethod"> - <property name="scope" value="protected" /> - <property name="severity" value="warning" /> - <property name="allowMissingJavadoc" value="true" /> - <property name="allowMissingParamTags" value="true" /> - <property name="allowMissingReturnTag" value="true" /> - <property name="allowMissingThrowsTags" value="true" /> - <property name="allowThrowsTagsForSubclasses" value="true" /> - <property name="allowUndeclaredRTE" value="true" /> - </module> - - <module name="JavadocType"> - <property name="scope" value="protected" /> - <property name="severity" value="error" /> - </module> - - <module name="JavadocStyle"> - <property name="severity" value="warning" /> - </module> - - <!-- NAMING CHECKS --> - - <!-- Item 38 - Adhere to generally accepted naming conventions --> - - <module name="PackageName"> - <!-- Validates identifiers for package names against the supplied expression. --> - <!-- Here the default checkstyle rule restricts package name parts to - seven characters, this is not in line with common practice at Google. --> - <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$" /> - <property name="severity" value="warning" /> - </module> - - <module name="TypeNameCheck"> - <!-- Validates static, final fields against the expression "^[A-Z][a-zA-Z0-9]*$". --> - <metadata name="altname" value="TypeName" /> - <property name="severity" value="warning" /> - </module> - - <module name="ConstantNameCheck"> - <!-- Validates non-private, static, final fields against the supplied - public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". --> - <metadata name="altname" value="ConstantName" /> - <property name="applyToPublic" value="true" /> - <property name="applyToProtected" value="true" /> - <property name="applyToPackage" value="true" /> - <property name="applyToPrivate" value="false" /> - <property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$" /> - <message key="name.invalidPattern" - value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)." /> - <property name="severity" value="warning" /> - </module> - - <module name="StaticVariableNameCheck"> - <!-- Validates static, non-final fields against the supplied expression - "^[a-z][a-zA-Z0-9]*_?$". --> - <metadata name="altname" value="StaticVariableName" /> - <property name="applyToPublic" value="true" /> - <property name="applyToProtected" value="true" /> - <property name="applyToPackage" value="true" /> - <property name="applyToPrivate" value="true" /> - <property name="format" value="^[a-z][a-zA-Z0-9]*_?$" /> - <property name="severity" value="warning" /> - </module> - - <module name="MemberNameCheck"> - <!-- Validates non-static members against the supplied expression. --> - <metadata name="altname" value="MemberName" /> - <property name="applyToPublic" value="true" /> - <property name="applyToProtected" value="true" /> - <property name="applyToPackage" value="true" /> - <property name="applyToPrivate" value="true" /> - <property name="format" value="^[a-z][a-zA-Z0-9]*$" /> - <property name="severity" value="warning" /> - </module> - - <module name="MethodNameCheck"> - <!-- Validates identifiers for method names. --> - <metadata name="altname" value="MethodName" /> - <property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$" /> - <property name="severity" value="warning" /> - </module> - - <module name="ParameterName"> - <!-- Validates identifiers for method parameters against the expression - "^[a-z][a-zA-Z0-9]*$". --> - <property name="severity" value="warning" /> - </module> - - <module name="LocalFinalVariableName"> - <!-- Validates identifiers for local final variables against the expression - "^[a-z][a-zA-Z0-9]*$". --> - <property name="severity" value="warning" /> - </module> - - <module name="LocalVariableName"> - <!-- Validates identifiers for local variables against the expression - "^[a-z][a-zA-Z0-9]*$". --> - <property name="severity" value="warning" /> - </module> - - - <!-- LENGTH and CODING CHECKS --> - - <module name="LineLength"> - <!-- Checks if a line is too long. --> - <property name="max" - value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" - default="100" /> - <property name="severity" value="error" /> - - <!-- The default ignore pattern exempts the following elements: - import - statements - long URLs inside comments --> - - <property name="ignorePattern" - value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}" - default="^(package .*;\s*)|(import .*;\s*)|( *\* *https?://.*)$" /> - </module> - - <module name="LeftCurly"> - <!-- Checks for placement of the left curly brace ('{'). --> - <property name="severity" value="warning" /> - </module> - - <module name="RightCurly"> - <!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on the same - line. e.g., the following example is fine: <pre> if { ... } else </pre> --> - <!-- This next example is not fine: <pre> if { ... } else </pre> --> - <property name="option" value="same" /> - <property name="severity" value="warning" /> - </module> - - <!-- Checks for braces around if and else blocks --> - <module name="NeedBraces"> - <property name="severity" value="warning" /> - <property name="tokens" - value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO" /> - </module> - - <module name="UpperEll"> - <!-- Checks that long constants are defined with an upper ell. --> - <property name="severity" value="error" /> - </module> - - <module name="FallThrough"> - <!-- Warn about falling through to the next case statement. Similar to - javac -Xlint:fallthrough, but the check is suppressed if a single-line comment - on the last non-blank line preceding the fallen-into case contains 'fall - through' (or some other variants which we don't publicized to promote consistency). --> - <property name="reliefPattern" - value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on" /> - <property name="severity" value="error" /> - </module> - - - <!-- MODIFIERS CHECKS --> - - <module name="ModifierOrder"> - <!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and - 8.4.3. The prescribed order is: public, protected, private, abstract, static, - final, transient, volatile, synchronized, native, strictfp --> - </module> - - - <!-- WHITESPACE CHECKS --> - - <module name="WhitespaceAround"> - <!-- Checks that various tokens are surrounded by whitespace. This includes - most binary operators and keywords followed by regular or curly braces. --> - <property name="tokens" - value="ASSIGN, BAND, BAND_ASSIGN, BOR, + <module name="FileTabCharacter"> + <!-- Checks that there are no tab characters in the file. --> + </module> + + <module name="NewlineAtEndOfFile"> + <property name="lineSeparator" value="lf"/> + </module> + + <module name="RegexpSingleline"> + <!-- Checks that FIXME is not used in comments. TODO is preferred. --> + <property name="format" value="((//.*)|(\*.*))FIXME"/> + <property name="message" + value='TODO is preferred to FIXME. e.g. "TODO(johndoe): Refactor when v2 is released."'/> + </module> + + <module name="RegexpSingleline"> + <!-- Checks that TODOs are named. (Actually, just that they are followed + by an open paren.) --> + <property name="format" value="((//.*)|(\*.*))TODO[^(]"/> + <property name="message" + value='All TODOs should be named. e.g. "TODO(johndoe): Refactor when v2 is released."'/> + </module> + + <!-- <module name="JavadocPackage"> - Checks that each Java package has + a Javadoc file used for commenting. Only allows a package-info.java, not + package.html. </module> --> + <!-- All Java AST specific tests live under TreeWalker module. --> + <module name="TreeWalker"> + + <!-- IMPORT CHECKS --> + + <module name="RedundantImport"> + <!-- Checks for redundant import statements. --> + <property name="severity" value="error"/> + </module> + <!-- <module name="ImportOrder"> Checks for out of order import statements + <property name="severity" value="warning"/> <property name="groups" value="com.google,android,junit,net,org,java,javax"/> + This ensures that static imports go first <property name="option" value="top"/> + <property name="tokens" value="STATIC_IMPORT, IMPORT"/> </module> --> + <!-- JAVADOC CHECKS --> + + <!-- Checks for Javadoc comments. --> + <!-- See http://checkstyle.sf.net/config_javadoc.html --> + <module name="JavadocMethod"> + <property name="scope" value="protected"/> + <property name="severity" value="warning"/> + <property name="allowMissingJavadoc" value="true"/> + <property name="allowMissingParamTags" value="true"/> + <property name="allowMissingReturnTag" value="true"/> + <property name="allowMissingThrowsTags" value="true"/> + <property name="allowThrowsTagsForSubclasses" value="true"/> + <property name="allowUndeclaredRTE" value="true"/> + </module> + + <module name="JavadocType"> + <property name="scope" value="protected"/> + <property name="severity" value="error"/> + </module> + + <module name="JavadocStyle"> + <property name="severity" value="warning"/> + </module> + + <!-- NAMING CHECKS --> + + <!-- Item 38 - Adhere to generally accepted naming conventions --> + + <module name="PackageName"> + <!-- Validates identifiers for package names against the supplied expression. --> + <!-- Here the default checkstyle rule restricts package name parts to + seven characters, this is not in line with common practice at Google. --> + <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/> + <property name="severity" value="warning"/> + </module> + + <module name="TypeNameCheck"> + <!-- Validates static, final fields against the expression "^[A-Z][a-zA-Z0-9]*$". --> + <metadata name="altname" value="TypeName"/> + <property name="severity" value="warning"/> + </module> + + <module name="ConstantNameCheck"> + <!-- Validates non-private, static, final fields against the supplied + public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". --> + <metadata name="altname" value="ConstantName"/> + <property name="applyToPublic" value="true"/> + <property name="applyToProtected" value="true"/> + <property name="applyToPackage" value="true"/> + <property name="applyToPrivate" value="false"/> + <property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$"/> + <message key="name.invalidPattern" + value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/> + <property name="severity" value="warning"/> + </module> + + <module name="StaticVariableNameCheck"> + <!-- Validates static, non-final fields against the supplied expression + "^[a-z][a-zA-Z0-9]*_?$". --> + <metadata name="altname" value="StaticVariableName"/> + <property name="applyToPublic" value="true"/> + <property name="applyToProtected" value="true"/> + <property name="applyToPackage" value="true"/> + <property name="applyToPrivate" value="true"/> + <property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/> + <property name="severity" value="warning"/> + </module> + + <module name="MemberNameCheck"> + <!-- Validates non-static members against the supplied expression. --> + <metadata name="altname" value="MemberName"/> + <property name="applyToPublic" value="true"/> + <property name="applyToProtected" value="true"/> + <property name="applyToPackage" value="true"/> + <property name="applyToPrivate" value="true"/> + <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> + <property name="severity" value="warning"/> + </module> + + <module name="MethodNameCheck"> + <!-- Validates identifiers for method names. --> + <metadata name="altname" value="MethodName"/> + <property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/> + <property name="severity" value="warning"/> + </module> + + <module name="ParameterName"> + <!-- Validates identifiers for method parameters against the expression + "^[a-z][a-zA-Z0-9]*$". --> + <property name="severity" value="warning"/> + </module> + + <module name="LocalFinalVariableName"> + <!-- Validates identifiers for local final variables against the expression + "^[a-z][a-zA-Z0-9]*$". --> + <property name="severity" value="warning"/> + </module> + + <module name="LocalVariableName"> + <!-- Validates identifiers for local variables against the expression + "^[a-z][a-zA-Z0-9]*$". --> + <property name="severity" value="warning"/> + </module> + + + <!-- LENGTH and CODING CHECKS --> + + <module name="LineLength"> + <!-- Checks if a line is too long. --> + <property name="max" + value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" + default="100"/> + <property name="severity" value="error"/> + + <!-- The default ignore pattern exempts the following elements: - import + statements - long URLs inside comments --> + + <property name="ignorePattern" + value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}" + default="^(package .*;\s*)|(import .*;\s*)|( *\* *https?://.*)$"/> + </module> + + <module name="LeftCurly"> + <!-- Checks for placement of the left curly brace ('{'). --> + <property name="severity" value="warning"/> + </module> + + <module name="RightCurly"> + <!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on the same + line. e.g., the following example is fine: <pre> if { ... } else </pre> --> + <!-- This next example is not fine: <pre> if { ... } else </pre> --> + <property name="option" value="same"/> + <property name="severity" value="warning"/> + </module> + + <!-- Checks for braces around if and else blocks --> + <module name="NeedBraces"> + <property name="severity" value="warning"/> + <property name="tokens" + value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/> + </module> + + <module name="UpperEll"> + <!-- Checks that long constants are defined with an upper ell. --> + <property name="severity" value="error"/> + </module> + + <module name="FallThrough"> + <!-- Warn about falling through to the next case statement. Similar to + javac -Xlint:fallthrough, but the check is suppressed if a single-line comment + on the last non-blank line preceding the fallen-into case contains 'fall + through' (or some other variants which we don't publicized to promote consistency). --> + <property name="reliefPattern" + value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/> + <property name="severity" value="error"/> + </module> + + + <!-- MODIFIERS CHECKS --> + + <module name="ModifierOrder"> + <!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and + 8.4.3. The prescribed order is: public, protected, private, abstract, static, + final, transient, volatile, synchronized, native, strictfp --> + </module> + + + <!-- WHITESPACE CHECKS --> + + <module name="WhitespaceAround"> + <!-- Checks that various tokens are surrounded by whitespace. This includes + most binary operators and keywords followed by regular or curly braces. --> + <property name="tokens" + value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, - SL, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN" /> - <property name="severity" value="error" /> - </module> - - <module name="WhitespaceAfter"> - <!-- Checks that commas, semicolons and typecasts are followed by whitespace. --> - <property name="tokens" value="COMMA, SEMI, TYPECAST" /> - </module> - - <module name="NoWhitespaceAfter"> - <!-- Checks that there is no whitespace after various unary operators. - Linebreaks are allowed. --> - <property name="tokens" - value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, - UNARY_PLUS" /> - <property name="allowLineBreaks" value="true" /> - <property name="severity" value="error" /> - </module> - - <module name="NoWhitespaceBefore"> - <!-- Checks that there is no whitespace before various unary operators. - Linebreaks are allowed. --> - <property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC" /> - <property name="allowLineBreaks" value="true" /> - <property name="severity" value="error" /> - </module> - - <module name="ParenPad"> - <!-- Checks that there is no whitespace before close parens or after open - parens. --> - <property name="severity" value="warning" /> - </module> - - <module name="Indentation"> - <!-- Checks code indentation --> - <property name="basicOffset" value="2" /> - </module> - </module> + SL, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/> + <property name="severity" value="error"/> + </module> + + <module name="WhitespaceAfter"> + <!-- Checks that commas, semicolons and typecasts are followed by whitespace. --> + <property name="tokens" value="COMMA, SEMI, TYPECAST"/> + </module> + + <module name="NoWhitespaceAfter"> + <!-- Checks that there is no whitespace after various unary operators. + Linebreaks are allowed. --> + <property name="tokens" + value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, + UNARY_PLUS"/> + <property name="allowLineBreaks" value="true"/> + <property name="severity" value="error"/> + </module> + + <module name="NoWhitespaceBefore"> + <!-- Checks that there is no whitespace before various unary operators. + Linebreaks are allowed. --> + <property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/> + <property name="allowLineBreaks" value="true"/> + <property name="severity" value="error"/> + </module> + + <module name="ParenPad"> + <!-- Checks that there is no whitespace before close parens or after open + parens. --> + <property name="severity" value="warning"/> + </module> + + <module name="Indentation"> + <!-- Checks code indentation --> + <property name="basicOffset" value="2"/> + <property name="caseIndent" value="2"/> + </module> + </module> </module> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4668da15/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java index 3272bc1..b75d8b8 100644 --- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java +++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java @@ -354,41 +354,41 @@ public class JDBCInterpreter extends Interpreter { JDBCSecurityImpl.createSecureConfiguration(property, authType); switch (authType) { - case KERBEROS: - if (user == null || "false".equalsIgnoreCase( - property.getProperty("zeppelin.jdbc.auth.kerberos.proxy.enable"))) { + case KERBEROS: + if (user == null || "false".equalsIgnoreCase( + property.getProperty("zeppelin.jdbc.auth.kerberos.proxy.enable"))) { + connection = getConnectionFromPool(connectionUrl, user, propertyKey, properties); + } else { + if (basePropretiesMap.get(propertyKey).containsKey("proxy.user.property")) { connection = getConnectionFromPool(connectionUrl, user, propertyKey, properties); } else { - if (basePropretiesMap.get(propertyKey).containsKey("proxy.user.property")) { - connection = getConnectionFromPool(connectionUrl, user, propertyKey, properties); - } else { - UserGroupInformation ugi = null; - try { - ugi = UserGroupInformation.createProxyUser( - user, UserGroupInformation.getCurrentUser()); - } catch (Exception e) { - logger.error("Error in getCurrentUser", e); - throw new InterpreterException("Error in getCurrentUser", e); - } - - final String poolKey = propertyKey; - try { - connection = ugi.doAs(new PrivilegedExceptionAction<Connection>() { - @Override - public Connection run() throws Exception { - return getConnectionFromPool(connectionUrl, user, poolKey, properties); - } - }); - } catch (Exception e) { - logger.error("Error in doAs", e); - throw new InterpreterException("Error in doAs", e); - } + UserGroupInformation ugi = null; + try { + ugi = UserGroupInformation.createProxyUser( + user, UserGroupInformation.getCurrentUser()); + } catch (Exception e) { + logger.error("Error in getCurrentUser", e); + throw new InterpreterException("Error in getCurrentUser", e); + } + + final String poolKey = propertyKey; + try { + connection = ugi.doAs(new PrivilegedExceptionAction<Connection>() { + @Override + public Connection run() throws Exception { + return getConnectionFromPool(connectionUrl, user, poolKey, properties); + } + }); + } catch (Exception e) { + logger.error("Error in doAs", e); + throw new InterpreterException("Error in doAs", e); } } - break; + } + break; - default: - connection = getConnectionFromPool(connectionUrl, user, propertyKey, properties); + default: + connection = getConnectionFromPool(connectionUrl, user, propertyKey, properties); } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4668da15/jdbc/src/main/java/org/apache/zeppelin/jdbc/security/JDBCSecurityImpl.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/zeppelin/jdbc/security/JDBCSecurityImpl.java b/jdbc/src/main/java/org/apache/zeppelin/jdbc/security/JDBCSecurityImpl.java index 25959e1..6e9470f 100644 --- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/security/JDBCSecurityImpl.java +++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/security/JDBCSecurityImpl.java @@ -41,20 +41,20 @@ public class JDBCSecurityImpl { public static void createSecureConfiguration(Properties properties, AuthenticationMethod authType) { switch (authType) { - case KERBEROS: - Configuration conf = new - org.apache.hadoop.conf.Configuration(); - conf.set("hadoop.security.authentication", KERBEROS.toString()); - UserGroupInformation.setConfiguration(conf); - try { - UserGroupInformation.loginUserFromKeytab( - properties.getProperty("zeppelin.jdbc.principal"), - properties.getProperty("zeppelin.jdbc.keytab.location") - ); - } catch (IOException e) { - LOGGER.error("Failed to get either keytab location or principal name in the " + - "interpreter", e); - } + case KERBEROS: + Configuration conf = new + org.apache.hadoop.conf.Configuration(); + conf.set("hadoop.security.authentication", KERBEROS.toString()); + UserGroupInformation.setConfiguration(conf); + try { + UserGroupInformation.loginUserFromKeytab( + properties.getProperty("zeppelin.jdbc.principal"), + properties.getProperty("zeppelin.jdbc.keytab.location") + ); + } catch (IOException e) { + LOGGER.error("Failed to get either keytab location or principal name in the " + + "interpreter", e); + } } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4668da15/shell/src/main/java/org/apache/zeppelin/shell/security/ShellSecurityImpl.java ---------------------------------------------------------------------- diff --git a/shell/src/main/java/org/apache/zeppelin/shell/security/ShellSecurityImpl.java b/shell/src/main/java/org/apache/zeppelin/shell/security/ShellSecurityImpl.java index bb3ce86..ecfdb0c 100644 --- a/shell/src/main/java/org/apache/zeppelin/shell/security/ShellSecurityImpl.java +++ b/shell/src/main/java/org/apache/zeppelin/shell/security/ShellSecurityImpl.java @@ -39,21 +39,21 @@ public class ShellSecurityImpl { .trim().toUpperCase(); switch (authType) { - case "KERBEROS": - CommandLine cmdLine = CommandLine.parse(shell); - cmdLine.addArgument("-c", false); - String kinitCommand = String.format("kinit -k -t %s %s", + case "KERBEROS": + CommandLine cmdLine = CommandLine.parse(shell); + cmdLine.addArgument("-c", false); + String kinitCommand = String.format("kinit -k -t %s %s", properties.getProperty("zeppelin.shell.keytab.location"), properties.getProperty("zeppelin.shell.principal")); - cmdLine.addArgument(kinitCommand, false); - DefaultExecutor executor = new DefaultExecutor(); - - try { - int exitVal = executor.execute(cmdLine); - } catch (Exception e) { - LOGGER.error("Unable to run kinit for zeppelin user " + kinitCommand, e); - throw new InterpreterException(e); - } + cmdLine.addArgument(kinitCommand, false); + DefaultExecutor executor = new DefaultExecutor(); + + try { + int exitVal = executor.execute(cmdLine); + } catch (Exception e) { + LOGGER.error("Unable to run kinit for zeppelin user " + kinitCommand, e); + throw new InterpreterException(e); + } } } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4668da15/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java index 64a4126..87d0009 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java @@ -236,148 +236,148 @@ public class NotebookServer extends WebSocketServlet /** Lets be elegant here */ switch (messagereceived.op) { - case LIST_NOTES: - unicastNoteList(conn, subject, userAndRoles); - break; - case RELOAD_NOTES_FROM_REPO: - broadcastReloadedNoteList(subject, userAndRoles); - break; - case GET_HOME_NOTE: - sendHomeNote(conn, userAndRoles, notebook, messagereceived); - break; - case GET_NOTE: - sendNote(conn, userAndRoles, notebook, messagereceived); - break; - case NEW_NOTE: - createNote(conn, userAndRoles, notebook, messagereceived); - break; - case DEL_NOTE: - removeNote(conn, userAndRoles, notebook, messagereceived); - break; - case REMOVE_FOLDER: - removeFolder(conn, userAndRoles, notebook, messagereceived); - break; - case MOVE_NOTE_TO_TRASH: - moveNoteToTrash(conn, userAndRoles, notebook, messagereceived); - break; - case MOVE_FOLDER_TO_TRASH: - moveFolderToTrash(conn, userAndRoles, notebook, messagereceived); - break; - case EMPTY_TRASH: - emptyTrash(conn, userAndRoles, notebook, messagereceived); - break; - case RESTORE_FOLDER: - restoreFolder(conn, userAndRoles, notebook, messagereceived); - break; - case RESTORE_NOTE: - restoreNote(conn, userAndRoles, notebook, messagereceived); - break; - case RESTORE_ALL: - restoreAll(conn, userAndRoles, notebook, messagereceived); - break; - case CLONE_NOTE: - cloneNote(conn, userAndRoles, notebook, messagereceived); - break; - case IMPORT_NOTE: - importNote(conn, userAndRoles, notebook, messagereceived); - break; - case COMMIT_PARAGRAPH: - updateParagraph(conn, userAndRoles, notebook, messagereceived); - break; - case RUN_PARAGRAPH: - runParagraph(conn, userAndRoles, notebook, messagereceived); - break; - case PARAGRAPH_EXECUTED_BY_SPELL: - broadcastSpellExecution(conn, userAndRoles, notebook, messagereceived); - break; - case RUN_ALL_PARAGRAPHS: - runAllParagraphs(conn, userAndRoles, notebook, messagereceived); - break; - case CANCEL_PARAGRAPH: - cancelParagraph(conn, userAndRoles, notebook, messagereceived); - break; - case MOVE_PARAGRAPH: - moveParagraph(conn, userAndRoles, notebook, messagereceived); - break; - case INSERT_PARAGRAPH: - insertParagraph(conn, userAndRoles, notebook, messagereceived); - break; - case COPY_PARAGRAPH: - copyParagraph(conn, userAndRoles, notebook, messagereceived); - break; - case PARAGRAPH_REMOVE: - removeParagraph(conn, userAndRoles, notebook, messagereceived); - break; - case PARAGRAPH_CLEAR_OUTPUT: - clearParagraphOutput(conn, userAndRoles, notebook, messagereceived); - break; - case PARAGRAPH_CLEAR_ALL_OUTPUT: - clearAllParagraphOutput(conn, userAndRoles, notebook, messagereceived); - break; - case NOTE_UPDATE: - updateNote(conn, userAndRoles, notebook, messagereceived); - break; - case NOTE_RENAME: - renameNote(conn, userAndRoles, notebook, messagereceived); - break; - case FOLDER_RENAME: - renameFolder(conn, userAndRoles, notebook, messagereceived); - break; - case UPDATE_PERSONALIZED_MODE: - updatePersonalizedMode(conn, userAndRoles, notebook, messagereceived); - break; - case COMPLETION: - completion(conn, userAndRoles, notebook, messagereceived); - break; - case PING: - break; //do nothing - case ANGULAR_OBJECT_UPDATED: - angularObjectUpdated(conn, userAndRoles, notebook, messagereceived); - break; - case ANGULAR_OBJECT_CLIENT_BIND: - angularObjectClientBind(conn, userAndRoles, notebook, messagereceived); - break; - case ANGULAR_OBJECT_CLIENT_UNBIND: - angularObjectClientUnbind(conn, userAndRoles, notebook, messagereceived); - break; - case LIST_CONFIGURATIONS: - sendAllConfigurations(conn, userAndRoles, notebook); - break; - case CHECKPOINT_NOTE: - checkpointNote(conn, notebook, messagereceived); - break; - case LIST_REVISION_HISTORY: - listRevisionHistory(conn, notebook, messagereceived); - break; - case SET_NOTE_REVISION: - setNoteRevision(conn, userAndRoles, notebook, messagereceived); - break; - case NOTE_REVISION: - getNoteByRevision(conn, notebook, messagereceived); - break; - case LIST_NOTE_JOBS: - unicastNoteJobInfo(conn, messagereceived); - break; - case UNSUBSCRIBE_UPDATE_NOTE_JOBS: - unsubscribeNoteJobInfo(conn); - break; - case GET_INTERPRETER_BINDINGS: - getInterpreterBindings(conn, messagereceived); - break; - case SAVE_INTERPRETER_BINDINGS: - saveInterpreterBindings(conn, messagereceived); - break; - case EDITOR_SETTING: - getEditorSetting(conn, messagereceived); - break; - case GET_INTERPRETER_SETTINGS: - getInterpreterSettings(conn, subject); - break; - case WATCHER: - switchConnectionToWatcher(conn, messagereceived); - break; - default: - break; + case LIST_NOTES: + unicastNoteList(conn, subject, userAndRoles); + break; + case RELOAD_NOTES_FROM_REPO: + broadcastReloadedNoteList(subject, userAndRoles); + break; + case GET_HOME_NOTE: + sendHomeNote(conn, userAndRoles, notebook, messagereceived); + break; + case GET_NOTE: + sendNote(conn, userAndRoles, notebook, messagereceived); + break; + case NEW_NOTE: + createNote(conn, userAndRoles, notebook, messagereceived); + break; + case DEL_NOTE: + removeNote(conn, userAndRoles, notebook, messagereceived); + break; + case REMOVE_FOLDER: + removeFolder(conn, userAndRoles, notebook, messagereceived); + break; + case MOVE_NOTE_TO_TRASH: + moveNoteToTrash(conn, userAndRoles, notebook, messagereceived); + break; + case MOVE_FOLDER_TO_TRASH: + moveFolderToTrash(conn, userAndRoles, notebook, messagereceived); + break; + case EMPTY_TRASH: + emptyTrash(conn, userAndRoles, notebook, messagereceived); + break; + case RESTORE_FOLDER: + restoreFolder(conn, userAndRoles, notebook, messagereceived); + break; + case RESTORE_NOTE: + restoreNote(conn, userAndRoles, notebook, messagereceived); + break; + case RESTORE_ALL: + restoreAll(conn, userAndRoles, notebook, messagereceived); + break; + case CLONE_NOTE: + cloneNote(conn, userAndRoles, notebook, messagereceived); + break; + case IMPORT_NOTE: + importNote(conn, userAndRoles, notebook, messagereceived); + break; + case COMMIT_PARAGRAPH: + updateParagraph(conn, userAndRoles, notebook, messagereceived); + break; + case RUN_PARAGRAPH: + runParagraph(conn, userAndRoles, notebook, messagereceived); + break; + case PARAGRAPH_EXECUTED_BY_SPELL: + broadcastSpellExecution(conn, userAndRoles, notebook, messagereceived); + break; + case RUN_ALL_PARAGRAPHS: + runAllParagraphs(conn, userAndRoles, notebook, messagereceived); + break; + case CANCEL_PARAGRAPH: + cancelParagraph(conn, userAndRoles, notebook, messagereceived); + break; + case MOVE_PARAGRAPH: + moveParagraph(conn, userAndRoles, notebook, messagereceived); + break; + case INSERT_PARAGRAPH: + insertParagraph(conn, userAndRoles, notebook, messagereceived); + break; + case COPY_PARAGRAPH: + copyParagraph(conn, userAndRoles, notebook, messagereceived); + break; + case PARAGRAPH_REMOVE: + removeParagraph(conn, userAndRoles, notebook, messagereceived); + break; + case PARAGRAPH_CLEAR_OUTPUT: + clearParagraphOutput(conn, userAndRoles, notebook, messagereceived); + break; + case PARAGRAPH_CLEAR_ALL_OUTPUT: + clearAllParagraphOutput(conn, userAndRoles, notebook, messagereceived); + break; + case NOTE_UPDATE: + updateNote(conn, userAndRoles, notebook, messagereceived); + break; + case NOTE_RENAME: + renameNote(conn, userAndRoles, notebook, messagereceived); + break; + case FOLDER_RENAME: + renameFolder(conn, userAndRoles, notebook, messagereceived); + break; + case UPDATE_PERSONALIZED_MODE: + updatePersonalizedMode(conn, userAndRoles, notebook, messagereceived); + break; + case COMPLETION: + completion(conn, userAndRoles, notebook, messagereceived); + break; + case PING: + break; //do nothing + case ANGULAR_OBJECT_UPDATED: + angularObjectUpdated(conn, userAndRoles, notebook, messagereceived); + break; + case ANGULAR_OBJECT_CLIENT_BIND: + angularObjectClientBind(conn, userAndRoles, notebook, messagereceived); + break; + case ANGULAR_OBJECT_CLIENT_UNBIND: + angularObjectClientUnbind(conn, userAndRoles, notebook, messagereceived); + break; + case LIST_CONFIGURATIONS: + sendAllConfigurations(conn, userAndRoles, notebook); + break; + case CHECKPOINT_NOTE: + checkpointNote(conn, notebook, messagereceived); + break; + case LIST_REVISION_HISTORY: + listRevisionHistory(conn, notebook, messagereceived); + break; + case SET_NOTE_REVISION: + setNoteRevision(conn, userAndRoles, notebook, messagereceived); + break; + case NOTE_REVISION: + getNoteByRevision(conn, notebook, messagereceived); + break; + case LIST_NOTE_JOBS: + unicastNoteJobInfo(conn, messagereceived); + break; + case UNSUBSCRIBE_UPDATE_NOTE_JOBS: + unsubscribeNoteJobInfo(conn); + break; + case GET_INTERPRETER_BINDINGS: + getInterpreterBindings(conn, messagereceived); + break; + case SAVE_INTERPRETER_BINDINGS: + saveInterpreterBindings(conn, messagereceived); + break; + case EDITOR_SETTING: + getEditorSetting(conn, messagereceived); + break; + case GET_INTERPRETER_SETTINGS: + getInterpreterSettings(conn, subject); + break; + case WATCHER: + switchConnectionToWatcher(conn, messagereceived); + break; + default: + break; } } catch (Exception e) { LOG.error("Can't handle message", e); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4668da15/zeppelin-server/src/main/java/org/apache/zeppelin/utils/CommandLineUtils.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/utils/CommandLineUtils.java b/zeppelin-server/src/main/java/org/apache/zeppelin/utils/CommandLineUtils.java index 93b3628..9e33ef1 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/utils/CommandLineUtils.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/utils/CommandLineUtils.java @@ -30,12 +30,12 @@ public class CommandLineUtils { } String usage = args[0].toLowerCase(Locale.US); - switch (usage){ - case "--version": - case "-v": - System.out.println(Util.getVersion()); - break; - default: + switch (usage) { + case "--version": + case "-v": + System.out.println(Util.getVersion()); + break; + default: } } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4668da15/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/install/InstallInterpreter.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/install/InstallInterpreter.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/install/InstallInterpreter.java index 7b67201..3838f63 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/install/InstallInterpreter.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/install/InstallInterpreter.java @@ -224,43 +224,43 @@ public class InstallInterpreter { for (int i = 0; i < args.length; i++) { String arg = args[i].toLowerCase(Locale.US); switch (arg) { - case "--list": - case "-l": - installer.list(); - System.exit(0); - break; - case "--all": - case "-a": - all = true; - break; - case "--name": - case "-n": - names = args[++i]; - break; - case "--artifact": - case "-t": - artifacts = args[++i]; - break; - case "--version": - case "-v": - Util.getVersion(); - break; - case "--proxy-url": - proxyUrl = new URL(args[++i]); - break; - case "--proxy-user": - proxyUser = args[++i]; - break; - case "--proxy-password": - proxyPassword = args[++i]; - break; - case "--help": - case "-h": - usage(); - System.exit(0); - break; - default: - System.out.println("Unknown option " + arg); + case "--list": + case "-l": + installer.list(); + System.exit(0); + break; + case "--all": + case "-a": + all = true; + break; + case "--name": + case "-n": + names = args[++i]; + break; + case "--artifact": + case "-t": + artifacts = args[++i]; + break; + case "--version": + case "-v": + Util.getVersion(); + break; + case "--proxy-url": + proxyUrl = new URL(args[++i]); + break; + case "--proxy-user": + proxyUser = args[++i]; + break; + case "--proxy-password": + proxyPassword = args[++i]; + break; + case "--help": + case "-h": + usage(); + System.exit(0); + break; + default: + System.out.println("Unknown option " + arg); } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/4668da15/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/websocket/ZeppelinhubClient.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/websocket/ZeppelinhubClient.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/websocket/ZeppelinhubClient.java index f692938..4eb00df 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/websocket/ZeppelinhubClient.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/repo/zeppelinhub/websocket/ZeppelinhubClient.java @@ -220,12 +220,12 @@ public class ZeppelinhubClient { return; } switch (op) { - case RUN_NOTEBOOK: - runAllParagraph(hubMsg.meta.get("noteId"), msg); - break; - default: - LOG.debug("Received {} from ZeppelinHub, not handled", op); - break; + case RUN_NOTEBOOK: + runAllParagraph(hubMsg.meta.get("noteId"), msg); + break; + default: + LOG.debug("Received {} from ZeppelinHub, not handled", op); + break; } }