Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KYUUBI #6084] JDBC driver supports configuration not to pull engine startup logs #6106

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ public class KyuubiBeeLine extends BeeLine {
private static final int ERRNO_OTHER = 2;

private static final String PYTHON_MODE_PREFIX = "--python-mode";
private static final String IGNORE_LAUNCH_ENGINE_PREFIX = "--ignore-launch-engine";
private boolean pythonMode = false;
private boolean ignoreLaunchEngine = false;

public KyuubiBeeLine() {
this(true);
Expand Down Expand Up @@ -90,6 +92,8 @@ void usage() {
super.usage();
output("Usage: java " + KyuubiBeeLine.class.getCanonicalName());
output(" --python-mode Execute python code/script.");
output("Usage: java " + KyuubiBeeLine.class.getCanonicalName());
output(" --ignore-launch-engine Ignore launch engine log.");
}

public boolean isPythonMode() {
Expand All @@ -101,6 +105,15 @@ public void setPythonMode(boolean pythonMode) {
this.pythonMode = pythonMode;
}

public boolean isIgnoreLaunchEngine() {
return ignoreLaunchEngine;
}

// Visible for testing
public void setIgnoreLaunchEngine(boolean ignoreLaunchEngine) {
this.ignoreLaunchEngine = ignoreLaunchEngine;
}

/** Starts the program. */
public static void main(String[] args) throws IOException {
mainWithInputRedirection(args, null);
Expand Down Expand Up @@ -169,13 +182,19 @@ int initArgs(String[] args) {
protected void processOption(String arg, ListIterator iter) throws ParseException {
if (PYTHON_MODE_PREFIX.equals(arg)) {
pythonMode = true;
} else if (IGNORE_LAUNCH_ENGINE_PREFIX.equals(arg)) {
ignoreLaunchEngine = true;
} else {
super.processOption(arg, iter);
}
}
};
cl = beelineParser.parse(options, args);

if (getOpts().getVerbose()) {
ignoreLaunchEngine = false;
}

connSuccessful =
DynMethods.builder("connectUsingArgs")
.hiddenImpl(BeeLine.class, BeelineParser.class, CommandLine.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.hive.beeline;

import static org.apache.kyuubi.jdbc.hive.JdbcConnectionParams.*;
import static org.apache.kyuubi.jdbc.hive.KyuubiConnection.IGNORE_LAUNCH_ENGINE_PROPERTY;

import com.google.common.annotations.VisibleForTesting;
import java.io.*;
Expand Down Expand Up @@ -450,6 +451,10 @@ public boolean connect(Properties props) throws IOException {
AUTH_PASSWD, "javax.jdo.option.ConnectionPassword", "ConnectionPassword",
});

if (beeLine.isIgnoreLaunchEngine()) {
props.put(IGNORE_LAUNCH_ENGINE_PROPERTY, "true");
}

if (url == null || url.length() == 0) {
return beeLine.error("Property \"url\" is required");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.hive.beeline;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
Expand Down Expand Up @@ -88,6 +89,32 @@ public void testKyuubiBeeLinePythonMode() {
kyuubiBeeLine.setPythonMode(false);
}

@Test
public void testKyuubiBeelineIgnoreLaunchEngine() {
KyuubiBeeLine kyuubiBeeLine = new KyuubiBeeLine();
String[] args1 = {"-u", "badUrl", "--ignore-launch-engine"};
kyuubiBeeLine.initArgs(args1);
assertTrue(kyuubiBeeLine.isIgnoreLaunchEngine());
kyuubiBeeLine.setIgnoreLaunchEngine(false);

String[] args2 = {"--ignore-launch-engine", "-f", "test.sql"};
kyuubiBeeLine.initArgs(args2);
assertTrue(kyuubiBeeLine.isIgnoreLaunchEngine());
assert kyuubiBeeLine.getOpts().getScriptFile().equals("test.sql");
kyuubiBeeLine.setIgnoreLaunchEngine(false);

String[] args3 = {"-u", "badUrl"};
kyuubiBeeLine.initArgs(args3);
assertFalse(kyuubiBeeLine.isIgnoreLaunchEngine());
kyuubiBeeLine.setIgnoreLaunchEngine(false);

String[] args4 = {"--ignore-launch-engine", "--verbose", "-f", "test.sql"};
kyuubiBeeLine.initArgs(args4);
assertFalse(kyuubiBeeLine.isIgnoreLaunchEngine());
assert kyuubiBeeLine.getOpts().getScriptFile().equals("test.sql");
kyuubiBeeLine.setIgnoreLaunchEngine(false);
}

@Test
public void testKyuubiBeelineComment() {
KyuubiBeeLine kyuubiBeeLine = new KyuubiBeeLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
public class KyuubiConnection implements SQLConnection, KyuubiLoggable {
public static final Logger LOG = LoggerFactory.getLogger(KyuubiConnection.class.getName());
public static final String BEELINE_MODE_PROPERTY = "BEELINE_MODE";
public static final String IGNORE_LAUNCH_ENGINE_PROPERTY = "IGNORE_LAUNCH_ENGINE_LOG";
public static final String HS2_PROXY_USER = "hive.server2.proxy.user";
public static int DEFAULT_ENGINE_LOG_THREAD_TIMEOUT = 10 * 1000;

Expand Down Expand Up @@ -112,6 +113,8 @@ public class KyuubiConnection implements SQLConnection, KyuubiLoggable {

private boolean isBeeLineMode;

private boolean ignoreLaunchEngineLog;

/** Get all direct HiveServer2 URLs from a ZooKeeper based HiveServer2 URL */
public static List<JdbcConnectionParams> getAllUrls(String zookeeperBasedHS2Url)
throws Exception {
Expand All @@ -127,6 +130,7 @@ public static List<JdbcConnectionParams> getAllUrls(String zookeeperBasedHS2Url)

public KyuubiConnection(String uri, Properties info) throws SQLException {
isBeeLineMode = Boolean.parseBoolean(info.getProperty(BEELINE_MODE_PROPERTY));
ignoreLaunchEngineLog = Boolean.parseBoolean(info.getProperty(IGNORE_LAUNCH_ENGINE_PROPERTY));
try {
connParams = Utils.parseURL(uri, info);
} catch (ZooKeeperHiveClientException e) {
Expand Down Expand Up @@ -262,7 +266,7 @@ public List<String> getExecLog() throws SQLException, ClosedOrCancelledException
"Method getExecLog() failed. The " + "connection has been closed.");
}

if (launchEngineOpHandle == null) {
if (launchEngineOpHandle == null || ignoreLaunchEngineLog) {
return Collections.emptyList();
}

Expand All @@ -285,7 +289,7 @@ public List<String> getExecLog() throws SQLException, ClosedOrCancelledException
}

private void showLaunchEngineLog() {
if (launchEngineOpHandle != null) {
if (launchEngineOpHandle != null && !ignoreLaunchEngineLog) {
LOG.info("Starting to get launch engine log.");
engineLogThread =
new Thread("engine-launch-log") {
Expand Down