relogin using keytab, and append message for the same

This commit is contained in:
Prabhjyot Singh 2017-06-13 15:48:44 +05:30
parent 380cfbfe3c
commit ab823d3ee9

View file

@ -50,6 +50,7 @@ public class ShellInterpreter extends Interpreter {
private final boolean isWindows = System.getProperty("os.name").startsWith("Windows");
private final String shell = isWindows ? "cmd /c" : "bash -c";
ConcurrentHashMap<String, DefaultExecutor> executors;
private Boolean isGSSInit = false;
public ShellInterpreter(Properties property) {
super(property);
@ -61,6 +62,7 @@ public class ShellInterpreter extends Interpreter {
executors = new ConcurrentHashMap<>();
if (!StringUtils.isAnyEmpty(getProperty("zeppelin.shell.auth.type"))) {
ShellSecurityImpl.createSecureConfiguration(getProperty(), shell);
isGSSInit = true;
}
}
@ -93,18 +95,29 @@ public class ShellInterpreter extends Interpreter {
+ " return with exit value: " + exitVal);
return new InterpreterResult(Code.SUCCESS, outStream.toString());
} catch (ExecuteException e) {
int exitValue = e.getExitValue();
LOGGER.error("Can not run " + cmd, e);
Code code = Code.ERROR;
String message = outStream.toString();
if (exitValue == 143) {
code = Code.INCOMPLETE;
message += "Paragraph received a SIGTERM\n";
LOGGER.info("The paragraph " + contextInterpreter.getParagraphId()
+ " stopped executing: " + message);
if (contextInterpreter.out.getCurrentOutput().toString().contains("GSS") && isGSSInit) {
isGSSInit = false;
if (!StringUtils.isAnyEmpty(getProperty("zeppelin.shell.auth.type"))) {
ShellSecurityImpl.createSecureConfiguration(getProperty(), shell);
isGSSInit = true;
}
appendSessionExpire(contextInterpreter);
return interpret(cmd, contextInterpreter);
} else {
int exitValue = e.getExitValue();
LOGGER.error("Can not run " + cmd, e);
Code code = Code.ERROR;
String message = outStream.toString();
if (exitValue == 143) {
code = Code.INCOMPLETE;
message += "Paragraph received a SIGTERM\n";
LOGGER.info("The paragraph " + contextInterpreter.getParagraphId()
+ " stopped executing: " + message);
}
message += "ExitValue: " + exitValue;
return new InterpreterResult(code, message);
}
message += "ExitValue: " + exitValue;
return new InterpreterResult(code, message);
} catch (IOException e) {
LOGGER.error("Can not run " + cmd, e);
return new InterpreterResult(Code.ERROR, e.getMessage());
@ -113,6 +126,18 @@ public class ShellInterpreter extends Interpreter {
}
}
private void appendSessionExpire(InterpreterContext contextInterpreter) {
String appInfoHtml = "\n\n" +
"Previous Keytab session is expired, new Keytab session is created. " +
"Will execute this paragraph again!" +
"\n\n";
try {
contextInterpreter.out.getCurrentOutput().write(appInfoHtml);
} catch (IOException eIOException) {
LOGGER.error("Error writing to currentOutput", eIOException);
}
}
@Override
public void cancel(InterpreterContext context) {
DefaultExecutor executor = executors.remove(context.getParagraphId());