Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Commit

Permalink
Autofill HDFS URI in DeltaTableDialog (#737)
Browse files Browse the repository at this point in the history
* Autofill HDFS URI in DeltaTableDialog
* Use login shell to run commands on remote hosts
so that that hilview processes can pick up environment variables.

Co-authored-by: Bin Wang <[email protected]>
  • Loading branch information
bin-wang and wkk authored Aug 9, 2021
1 parent 27f530d commit 11dbb58
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bin/hillviewCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def run_remote_shell_command(self, command, verbose=True):
logger.info(message)
f.close()

command = "ssh " + self.uh() + " bash -s < " + file.name
command = "ssh " + self.uh() + " bash -l -s < " + file.name
exitcode = subprocess.call(command, shell=True)
if exitcode != 0:
error = "Exit code returned: " + str(exitcode)
Expand Down
31 changes: 31 additions & 0 deletions web/src/main/java/org/hillview/targets/InitialObjectTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

package org.hillview.targets;

import com.google.gson.JsonPrimitive;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.hillview.*;
import org.hillview.dataset.RemoteDataSet;
import org.hillview.dataset.api.*;
Expand Down Expand Up @@ -106,6 +109,34 @@ public void getUIConfig(RpcRequest request, RpcRequestContext context) {
this.returnResult(Configuration.instance.getAsJson(), request, context);
}

@HillviewRpc
public void getHDFSUri(RpcRequest request, RpcRequestContext context) {
final String hadoopHome = System.getenv("HADOOP_HOME");
String hdfsUri;

if (hadoopHome == null) {
HillviewLogger.instance.warn("Could not find HADOOP_HOME");
hdfsUri = "";
} else {
try {
final Path hadoopConfigDir = new Path(Paths.get(hadoopHome, "etc", "hadoop").toUri());
org.apache.hadoop.conf.Configuration configuration
= new org.apache.hadoop.conf.Configuration();
configuration.addResource(new Path(hadoopConfigDir, "core-site.xml"));
configuration.addResource(new Path(hadoopConfigDir, "hdfs-site.xml"));
hdfsUri = FileSystem.getDefaultUri(configuration).toString();
} catch (Exception exception) {
HillviewLogger.instance.warn(
"Found HADOOP_HOME but failed to load config",
"HADOOP_HOME: {0}, error message: {1}",
hadoopHome, exception.getMessage());
hdfsUri = "";
}
}

this.returnResult(new JsonValue(new JsonPrimitive(hdfsUri)), request, context);
}

@HillviewRpc
public void openingBookmark(RpcRequest request, RpcRequestContext context) throws IOException {
String bookmarkFile = request.parseArgs(String.class);
Expand Down
14 changes: 9 additions & 5 deletions web/src/main/webapp/loadView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,13 @@ export class LoadView extends RemoteObject implements IDataView {
}, {
text: "Delta table...",
action: () => {
const dialog = new DeltaTableDialog();
dialog.setAction(() => this.init.loadDeltaTable(dialog.getDeltaTableDescription(), this.page))
dialog.show();
const rr = this.createStreamingRpcRequest<string>("getHDFSUri", null);
const observer = new GenericReceiver("get HDFS URI", this.page, rr, hdfsUri => {
const dialog = new DeltaTableDialog(hdfsUri);
dialog.setAction(() => this.init.loadDeltaTable(dialog.getDeltaTableDescription(), this.page))
dialog.show();
});
rr.invoke(observer);
},
help: "A delta lake table"
});
Expand Down Expand Up @@ -482,7 +486,7 @@ class OrcFileDialog extends Dialog {
}

class DeltaTableDialog extends Dialog {
constructor() {
constructor(hdfsUri: string) {
super(
"Load a Delta Lake table",
"Load a Delta Lake table from local filesystem, hdfs, or s3"
Expand All @@ -491,7 +495,7 @@ class DeltaTableDialog extends Dialog {
"deltaTablePath",
"Delta table path",
FieldKind.String,
"/delta-table",
hdfsUri,
"Path to the delta table to load."
);
path.required = true;
Expand Down

0 comments on commit 11dbb58

Please sign in to comment.