-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[ZEPPELIN-2698] Apply KerberosInterpreter to JDBCInterpreter #2443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
57ea80c
7f8b867
7fe883c
5823727
a5a54d4
835b4bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,17 +57,14 @@ public ShellInterpreter(Properties property) { | |
|
|
||
| @Override | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can move
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, done. |
||
| public void open() { | ||
| super.open(); | ||
| LOGGER.info("Command timeout property: {}", getProperty(TIMEOUT_PROPERTY)); | ||
| executors = new ConcurrentHashMap<>(); | ||
| if (!StringUtils.isAnyEmpty(getProperty("zeppelin.shell.auth.type"))) { | ||
| startKerberosLoginThread(); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void close() { | ||
| shutdownExecutorService(); | ||
|
|
||
| super.close(); | ||
| for (String executorKey : executors.keySet()) { | ||
| DefaultExecutor executor = executors.remove(executorKey); | ||
| if (executor != null) { | ||
|
|
@@ -171,4 +168,13 @@ protected boolean runKerberosLogin() { | |
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean isKerboseEnabled() { | ||
| if (!StringUtils.isAnyEmpty(getProperty("zeppelin.shell.auth.type")) && getProperty( | ||
| "zeppelin.shell.auth.type").equalsIgnoreCase("kerberos")) { | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,8 +38,8 @@ | |
| public abstract class KerberosInterpreter extends Interpreter { | ||
|
|
||
| private Integer kinitFailCount = 0; | ||
| protected ScheduledExecutorService scheduledExecutorService; | ||
| public static Logger logger = LoggerFactory.getLogger(KerberosInterpreter.class); | ||
| private ScheduledExecutorService scheduledExecutorService; | ||
| private static Logger logger = LoggerFactory.getLogger(KerberosInterpreter.class); | ||
|
|
||
| public KerberosInterpreter(Properties property) { | ||
| super(property); | ||
|
|
@@ -48,23 +48,38 @@ public KerberosInterpreter(Properties property) { | |
| @ZeppelinApi | ||
| protected abstract boolean runKerberosLogin(); | ||
|
|
||
| public String getKerberosRefreshInterval() { | ||
| @ZeppelinApi | ||
| protected abstract boolean isKerboseEnabled(); | ||
|
|
||
| public void open() { | ||
| if (isKerboseEnabled()) { | ||
| startKerberosLoginThread(); | ||
| } | ||
| } | ||
|
|
||
| public void close() { | ||
| if (isKerboseEnabled()) { | ||
| shutdownExecutorService(); | ||
| } | ||
| } | ||
|
|
||
| private String getKerberosRefreshInterval() { | ||
| if (System.getenv("KERBEROS_REFRESH_INTERVAL") == null) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to add javadoc for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, have added isKerboseEnabled in javadoc. |
||
| return "1d"; | ||
| } else { | ||
| return System.getenv("KERBEROS_REFRESH_INTERVAL"); | ||
| } | ||
| } | ||
|
|
||
| public Integer kinitFailThreshold() { | ||
| private Integer kinitFailThreshold() { | ||
| if (System.getenv("KINIT_FAIL_THRESHOLD") == null) { | ||
| return 5; | ||
| } else { | ||
| return new Integer(System.getenv("KINIT_FAIL_THRESHOLD")); | ||
| } | ||
| } | ||
|
|
||
| public Long getTimeAsMs(String time) { | ||
| private Long getTimeAsMs(String time) { | ||
| if (time == null) { | ||
| logger.error("Cannot convert to time value.", time); | ||
| time = "1d"; | ||
|
|
@@ -86,7 +101,7 @@ public Long getTimeAsMs(String time) { | |
| suffix != null ? Constants.TIME_SUFFIXES.get(suffix) : TimeUnit.MILLISECONDS); | ||
| } | ||
|
|
||
| protected ScheduledExecutorService startKerberosLoginThread() { | ||
| private ScheduledExecutorService startKerberosLoginThread() { | ||
| scheduledExecutorService = Executors.newScheduledThreadPool(1); | ||
|
|
||
| scheduledExecutorService.schedule(new Callable() { | ||
|
|
@@ -116,7 +131,7 @@ public Object call() throws Exception { | |
| return scheduledExecutorService; | ||
| } | ||
|
|
||
| protected void shutdownExecutorService() { | ||
| private void shutdownExecutorService() { | ||
| if (scheduledExecutorService != null) { | ||
| scheduledExecutorService.shutdown(); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authTypeis not needed to check asrunKerberosLoginwould be only called when kerberos is enabled.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, make sense, removed unnecessary if condition.