Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment;
import org.apache.flink.table.api.TableEnvironment;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.interpreter.*;
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
import org.slf4j.Logger;
Expand Down Expand Up @@ -91,8 +90,8 @@ private FlinkScalaInterpreter loadFlinkScalaInterpreter() throws Exception {
Class<?> clazz = Class.forName(innerIntpClassName);

return (FlinkScalaInterpreter)
clazz.getConstructor(Properties.class, ClassLoader.class, ZeppelinConfiguration.class)
.newInstance(getProperties(), flinkScalaClassLoader, zConf);
clazz.getConstructor(Properties.class, ClassLoader.class)
.newInstance(getProperties(), flinkScalaClassLoader);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ import java.util.Properties

import org.apache.zeppelin.interpreter.InterpreterContext
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion
import org.apache.zeppelin.conf.ZeppelinConfiguration

import scala.tools.nsc.Settings
import scala.tools.nsc.interpreter.{IMain, JPrintWriter}

class FlinkScala212Interpreter(override val properties: Properties,
override val flinkScalaClassLoader: ClassLoader,
override val zConf: ZeppelinConfiguration)
extends FlinkScalaInterpreter(properties, flinkScalaClassLoader, zConf) {
override val flinkScalaClassLoader: ClassLoader)
extends FlinkScalaInterpreter(properties, flinkScalaClassLoader) {

override def completion(buf: String,
cursor: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import org.apache.flink.table.catalog.hive.HiveCatalog
import org.apache.flink.table.functions.{AggregateFunction, ScalarFunction, TableAggregateFunction, TableFunction}
import org.apache.flink.table.module.hive.HiveModule
import org.apache.flink.yarn.cli.FlinkYarnSessionCli
import org.apache.zeppelin.conf.ZeppelinConfiguration
import org.apache.zeppelin.dep.DependencyResolver
import org.apache.zeppelin.flink.internal.FlinkShell
import org.apache.zeppelin.flink.internal.FlinkShell._
Expand All @@ -66,8 +65,7 @@ import scala.tools.nsc.interpreter.{Completion, IMain, IR, JPrintWriter, Results
* @param properties
*/
abstract class FlinkScalaInterpreter(val properties: Properties,
val flinkScalaClassLoader: ClassLoader,
val zConf: ZeppelinConfiguration) {
val flinkScalaClassLoader: ClassLoader) {

private lazy val LOGGER: Logger = LoggerFactory.getLogger(getClass)

Expand Down Expand Up @@ -800,7 +798,12 @@ abstract class FlinkScalaInterpreter(val properties: Properties,
val flinkPackageJars =
if (!StringUtils.isBlank(properties.getProperty("flink.execution.packages", ""))) {
val packages = properties.getProperty("flink.execution.packages")
val dependencyResolver = new DependencyResolver(System.getProperty("user.home") + "/.m2/repository", zConf)
val dependencyResolver = new DependencyResolver(
System.getProperty("user.home") + "/.m2/repository",
properties.getProperty("zeppelin.proxy.url"),
properties.getProperty("zeppelin.proxy.user"),
properties.getProperty("zeppelin.proxy.password"),
properties.getProperty("zeppelin.interpreter.dep.mvnRepo"))
packages.split(",")
.flatMap(e => JavaConversions.asScalaBuffer(dependencyResolver.load(e)))
.map(e => e.getAbsolutePath).toSeq
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import com.vladsch.flexmark.html.HtmlRenderer;
import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.util.data.MutableDataSet;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;
import java.util.Properties;

import static com.vladsch.flexmark.ext.emoji.EmojiImageType.UNICODE_ONLY;

Expand All @@ -44,7 +44,9 @@ public class FlexmarkParser implements MarkdownParser {
private Parser parser;
private HtmlRenderer renderer;

public FlexmarkParser(ZeppelinConfiguration zConf) {
public FlexmarkParser(Properties properties) {
boolean escapeHtml = Boolean.parseBoolean(
properties.getProperty("zeppelin.notebook.markdown.escape.html", "true"));
MutableDataSet options = new MutableDataSet();
options.set(Parser.EXTENSIONS, Arrays.asList(StrikethroughExtension.create(),
TablesExtension.create(),
Expand All @@ -55,7 +57,7 @@ public FlexmarkParser(ZeppelinConfiguration zConf) {
EmojiExtension.create()));
options.set(HtmlRenderer.SOFT_BREAK, "<br />\n");
options.set(EmojiExtension.USE_IMAGE_TYPE, UNICODE_ONLY);
options.set(HtmlRenderer.ESCAPE_HTML, zConf.isZeppelinNotebookMarkdownEscapeHtml());
options.set(HtmlRenderer.ESCAPE_HTML, escapeHtml);
parser = Parser.builder(options).build();
renderer = HtmlRenderer.builder(options).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public MarkdownParser createMarkdownParser(String parserType) {
LOGGER.debug("Creating {} markdown interpreter", parserType);

if (MarkdownParserType.FLEXMARK.toString().equals(parserType)) {
return new FlexmarkParser(zConf);
return new FlexmarkParser(getProperties());
} else {
// default parser
return new Markdown4jParser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.apache.zeppelin.markdown;

import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.interpreter.InterpreterResult;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -44,7 +43,6 @@ public void setUp() throws Exception {
Properties props = new Properties();
props.put(Markdown.MARKDOWN_PARSER_TYPE, Markdown.PARSER_TYPE_FLEXMARK);
md = new Markdown(props);
md.setZeppelinConfiguration(ZeppelinConfiguration.load());
md.open();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ void testGraphAction() throws Exception {
clickAndWait(By.xpath("//div[@class='modal-dialog'][contains(.,'Do you want to personalize your analysis?')" +
"]//div[@class='modal-footer']//button[contains(.,'OK')]"));

clickableWait(By.xpath(getParagraphXPath(1) +
"//button[contains(@uib-tooltip, 'Bar Chart')]"), MAX_BROWSER_TIMEOUT_SEC).click();
clickAndWait(By.xpath(getParagraphXPath(1) +
"//button[contains(@uib-tooltip, 'Bar Chart')]"));
assertEquals("fa fa-bar-chart",
manager.getWebDriver().findElement(By.xpath(getParagraphXPath(1)
+ "//button[contains(@class," +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.LinkedList;
import java.util.List;

import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.Authentication;
Expand All @@ -49,26 +48,28 @@ public abstract class AbstractDependencyResolver {
protected RepositorySystemSession session;
private Proxy proxy = null;

protected AbstractDependencyResolver(String localRepoPath, ZeppelinConfiguration zConf) {
if (zConf.getZeppelinProxyUrl() != null) {
protected AbstractDependencyResolver(String localRepoPath,
String proxyUrl, String proxyUser, String proxyPassword, String mvnRepoUrl) {
if (proxyUrl != null) {
try {
URL proxyUrl = new URL(zConf.getZeppelinProxyUrl());
Authentication auth = new AuthenticationBuilder().addUsername(zConf.getZeppelinProxyUser()).addPassword(zConf.getZeppelinProxyPassword()).build();
proxy = new Proxy(proxyUrl.getProtocol(), proxyUrl.getHost(), proxyUrl.getPort(), auth);
URL parsedProxyUrl = new URL(proxyUrl);
Authentication auth = new AuthenticationBuilder()
.addUsername(proxyUser).addPassword(proxyPassword).build();
proxy = new Proxy(parsedProxyUrl.getProtocol(), parsedProxyUrl.getHost(),
parsedProxyUrl.getPort(), auth);
} catch (MalformedURLException e) {
LOGGER.error("Proxy Url {} is not valid - skipping Proxy config", zConf.getZeppelinProxyUrl(), e);
LOGGER.error("Proxy Url {} is not valid - skipping Proxy config", proxyUrl, e);
}
}
session = Booter.newRepositorySystemSession(system, localRepoPath);
repos.addAll(Booter.newCentralRepositorys(proxy, zConf)); // add maven central
repos.addAll(Booter.newCentralRepositorys(proxy, mvnRepoUrl)); // add maven central
repos.add(Booter.newLocalRepository());
}

protected AbstractDependencyResolver(String localRepoPath, Proxy proxy,
ZeppelinConfiguration zConf) {
protected AbstractDependencyResolver(String localRepoPath, Proxy proxy, String mvnRepoUrl) {
this.proxy = proxy;
session = Booter.newRepositorySystemSession(system, localRepoPath);
repos.addAll(Booter.newCentralRepositorys(proxy, zConf)); // add maven central
repos.addAll(Booter.newCentralRepositorys(proxy, mvnRepoUrl)); // add maven central
repos.add(Booter.newLocalRepository());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.apache.zeppelin.dep;

import org.apache.commons.lang3.Validate;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.RepositorySystem;
Expand Down Expand Up @@ -83,10 +82,10 @@ static String resolveLocalRepoPath(String localRepoPath) {
}

public static List<RemoteRepository> newCentralRepositorys(Proxy proxy,
ZeppelinConfiguration zConf) {
String mvnRepoUrl) {
String mvnRepoEnv = System.getenv("ZEPPELIN_INTERPRETER_DEP_MVNREPO");
if (mvnRepoEnv == null) {
mvnRepoEnv = zConf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_INTERPRETER_DEP_MVNREPO);
mvnRepoEnv = mvnRepoUrl;
}
if (mvnRepoEnv == null) {
mvnRepoEnv = "https://repo1.maven.org/maven2/";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This part is a bit hard for me to read due to multiple re-assignments. Would it be better to use a more explicit pattern to clarify?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can handle it with another PR.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.eclipse.aether.RepositoryException;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
Expand Down Expand Up @@ -56,12 +55,13 @@ public class DependencyResolver extends AbstractDependencyResolver {
"org.apache.zeppelin:zeppelin-interpreter",
"org.apache.zeppelin:zeppelin-server"};

public DependencyResolver(String localRepoPath, ZeppelinConfiguration zConf) {
super(localRepoPath, zConf);
public DependencyResolver(String localRepoPath,
String proxyUrl, String proxyUser, String proxyPassword, String mvnRepoUrl) {
super(localRepoPath, proxyUrl, proxyUser, proxyPassword, mvnRepoUrl);
}

public DependencyResolver(String localRepoPath, Proxy proxy, ZeppelinConfiguration zConf) {
super(localRepoPath, proxy, zConf);
public DependencyResolver(String localRepoPath, Proxy proxy, String mvnRepoUrl) {
super(localRepoPath, proxy, mvnRepoUrl);
}

public List<File> load(String artifact)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.zeppelin.annotation.Experimental;
import org.apache.zeppelin.annotation.ZeppelinApi;
import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
import org.apache.zeppelin.scheduler.Scheduler;
import org.apache.zeppelin.scheduler.SchedulerFactory;
Expand Down Expand Up @@ -150,7 +149,6 @@ public Scheduler getScheduler() {
private URL[] classloaderUrls;
protected Properties properties;
protected String userName;
protected ZeppelinConfiguration zConf;

@ZeppelinApi
public Interpreter(Properties properties) {
Expand Down Expand Up @@ -200,10 +198,6 @@ public String getUserName() {
return this.userName;
}

public void setZeppelinConfiguration(ZeppelinConfiguration zConf) {
this.zConf = zConf;
}

public void setInterpreterGroup(InterpreterGroup interpreterGroup) {
this.interpreterGroup = interpreterGroup;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.zeppelin.conf.ZeppelinConfiguration;

/**
*
*/
public class InterpreterOption {
public static final transient String SHARED = "shared";
public static final transient String SCOPED = "scoped";
public static final transient String ISOLATED = "isolated";
private transient ZeppelinConfiguration zConf;
private transient boolean usernameForceLowerCase;

// always set it as true, keep this field just for backward compatibility
boolean remote = true;
Expand Down Expand Up @@ -60,8 +58,8 @@ public void setHost(String host) {
this.host = host;
}

public void setConf(ZeppelinConfiguration zConf) {
this.zConf = zConf;
public void setUsernameForceLowerCase(boolean usernameForceLowerCase) {
this.usernameForceLowerCase = usernameForceLowerCase;
}

public boolean permissionIsSet() {
Expand All @@ -73,7 +71,7 @@ public void setUserPermission(boolean setPermission) {
}

public List<String> getOwners() {
if (null != owners && zConf.isUsernameForceLowerCase()) {
if (null != owners && usernameForceLowerCase) {
List<String> lowerCaseUsers = new ArrayList<>();
for (String owner : owners) {
lowerCaseUsers.add(owner.toLowerCase());
Expand Down Expand Up @@ -117,7 +115,7 @@ public static InterpreterOption fromInterpreterOption(InterpreterOption other) {
option.setPermission = other.setPermission;
option.owners = (null == other.owners) ?
new ArrayList<>() : new ArrayList<>(other.owners);
option.zConf = other.zConf;
option.usernameForceLowerCase = other.usernameForceLowerCase;
return option;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.List;
import java.util.Properties;

import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
import org.apache.zeppelin.scheduler.Scheduler;

Expand Down Expand Up @@ -205,11 +204,6 @@ public void setUserName(String userName) {
this.intp.setUserName(userName);
}

@Override
public void setZeppelinConfiguration(ZeppelinConfiguration zConf) {
this.intp.setZeppelinConfiguration(zConf);
}

@Override
public String getUserName() {
return this.intp.getUserName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@
package org.apache.zeppelin.interpreter;


import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer;

import java.util.Properties;

/**
* Abstract base class for managing the lifecycle of interpreters
*/
public abstract class LifecycleManager {

protected ZeppelinConfiguration zConf;
protected Properties properties;
protected RemoteInterpreterServer remoteInterpreterServer;

public LifecycleManager(ZeppelinConfiguration zConf, RemoteInterpreterServer remoteInterpreterServer) {
this.zConf = zConf;
public LifecycleManager(Properties properties, RemoteInterpreterServer remoteInterpreterServer) {
this.properties = properties;
this.remoteInterpreterServer = remoteInterpreterServer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@

package org.apache.zeppelin.interpreter.lifecycle;

import org.apache.zeppelin.conf.ZeppelinConfiguration;
import org.apache.zeppelin.interpreter.LifecycleManager;
import org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer;

import java.util.Properties;

/**
* Do nothing for the lifecycle of interpreter. User need to explicitly start/stop interpreter.
*/
public class NullLifecycleManager extends LifecycleManager {

public NullLifecycleManager(ZeppelinConfiguration zConf,
public NullLifecycleManager(Properties properties,
RemoteInterpreterServer remoteInterpreterServer) {
super(zConf, remoteInterpreterServer);
super(properties, remoteInterpreterServer);
}

@Override
Expand Down
Loading
Loading