mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Proxy support
This commit is contained in:
parent
9079580ff5
commit
4c1f029078
3 changed files with 58 additions and 6 deletions
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.apache.zeppelin.dep;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
|
@ -25,6 +26,7 @@ import java.util.List;
|
|||
import org.sonatype.aether.RepositorySystem;
|
||||
import org.sonatype.aether.RepositorySystemSession;
|
||||
import org.sonatype.aether.repository.Authentication;
|
||||
import org.sonatype.aether.repository.Proxy;
|
||||
import org.sonatype.aether.repository.RemoteRepository;
|
||||
import org.sonatype.aether.repository.RepositoryPolicy;
|
||||
import org.sonatype.aether.resolution.ArtifactResult;
|
||||
|
|
@ -44,6 +46,16 @@ public abstract class AbstractDependencyResolver {
|
|||
repos.add(Booter.newLocalRepository());
|
||||
}
|
||||
|
||||
public void setProxy(URL proxyUrl, String proxyUser, String proxyPassword) {
|
||||
Authentication auth = new Authentication(proxyUser, proxyPassword);
|
||||
Proxy proxy = new Proxy(proxyUrl.getProtocol(), proxyUrl.getHost(), proxyUrl.getPort(), auth);
|
||||
synchronized (repos) {
|
||||
for (RemoteRepository repo : repos) {
|
||||
repo.setProxy(proxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<RemoteRepository> getRepos() {
|
||||
return this.repos;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.apache.zeppelin.dep;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.apache.zeppelin.util.Util;
|
|||
import org.sonatype.aether.RepositoryException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
|
@ -40,6 +41,9 @@ public class InstallInterpreter {
|
|||
private final File interpreterBaseDir;
|
||||
private final List<AvailableInterpreterInfo> availableInterpreters;
|
||||
private final String localRepoDir;
|
||||
private URL proxyUrl;
|
||||
private String proxyUser;
|
||||
private String proxyPassword;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -149,6 +153,9 @@ public class InstallInterpreter {
|
|||
|
||||
public void install(String name, String artifact) {
|
||||
DependencyResolver depResolver = new DependencyResolver(localRepoDir);
|
||||
if (proxyUrl != null) {
|
||||
depResolver.setProxy(proxyUrl, proxyUser, proxyPassword);
|
||||
}
|
||||
|
||||
File installDir = new File(interpreterBaseDir, name);
|
||||
if (installDir.exists()) {
|
||||
|
|
@ -170,15 +177,26 @@ public class InstallInterpreter {
|
|||
}
|
||||
}
|
||||
|
||||
public void setProxy(URL proxyUrl, String proxyUser, String proxyPassword) {
|
||||
this.proxyUrl = proxyUrl;
|
||||
this.proxyUser = proxyUser;
|
||||
this.proxyPassword = proxyPassword;
|
||||
}
|
||||
|
||||
public static void usage() {
|
||||
System.out.println("Options");
|
||||
System.out.println(" -l, --list List available interpreters");
|
||||
System.out.println(" -a, --all Install all available interpreters");
|
||||
System.out.println(" -n, --name [NAMES] Install interpreters (comma separated list)" +
|
||||
System.out.println(" -l, --list List available interpreters");
|
||||
System.out.println(" -a, --all Install all available interpreters");
|
||||
System.out.println(" -n, --name [NAMES] Install interpreters (comma separated " +
|
||||
"list)" +
|
||||
"e.g. md,shell,jdbc,python,angular");
|
||||
System.out.println(" -t, --artifact [ARTIFACTS] (Optional with -n) custom artifact names. " +
|
||||
System.out.println(" -t, --artifact [ARTIFACTS] (Optional with -n) custom artifact names" +
|
||||
". " +
|
||||
"(comma separated list correspond to --name) " +
|
||||
"e.g. customGroup:customArtifact:customVersion");
|
||||
System.out.println(" --proxy-url [url] (Optional) proxy url. http(s)://host:port");
|
||||
System.out.println(" --proxy-user [user] (Optional) proxy user");
|
||||
System.out.println(" --proxy-password [password] (Optional) proxy password");
|
||||
}
|
||||
|
||||
public static void main(String [] args) throws IOException {
|
||||
|
|
@ -195,6 +213,10 @@ public class InstallInterpreter {
|
|||
|
||||
String names = null;
|
||||
String artifacts = null;
|
||||
URL proxyUrl = null;
|
||||
String proxyUser = null;
|
||||
String proxyPassword = null;
|
||||
boolean all = false;
|
||||
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String arg = args[i].toLowerCase(Locale.US);
|
||||
|
|
@ -206,8 +228,7 @@ public class InstallInterpreter {
|
|||
break;
|
||||
case "--all":
|
||||
case "-a":
|
||||
installer.installAll();
|
||||
System.exit(0);
|
||||
all = true;
|
||||
break;
|
||||
case "--name":
|
||||
case "-n":
|
||||
|
|
@ -221,6 +242,15 @@ public class InstallInterpreter {
|
|||
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();
|
||||
|
|
@ -231,6 +261,15 @@ public class InstallInterpreter {
|
|||
}
|
||||
}
|
||||
|
||||
if (proxyUrl != null) {
|
||||
installer.setProxy(proxyUrl, proxyUser, proxyPassword);
|
||||
}
|
||||
|
||||
if (all) {
|
||||
installer.installAll();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
if (names != null) {
|
||||
if (artifacts != null) {
|
||||
installer.install(names.split(","), artifacts.split(","));
|
||||
|
|
|
|||
Loading…
Reference in a new issue