Skip to content

Commit

Permalink
[ZEPPELIN-5819] Configures ivy to download jar libraries only from re…
Browse files Browse the repository at this point in the history
…mote

### What is this PR for?
Configures ivy to download jar libraries only from remote and ignore local jars

### What type of PR is it?
 * Hot Fix

### What is the Jira issue?
 * https://issues.apache.org/jira/browse/ZEPPELIN-5819

### How should this be tested?
* CI

### Questions:
* Does the licenses files need to update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: Philipp Dallig <[email protected]>

Closes #4495 from Reamer/ivy_download and squashes the following commits:

b74631a [Philipp Dallig] Configures ivy to download jar libraries only from remote

(cherry picked from commit e70b57c)
Signed-off-by: Philipp Dallig <[email protected]>

# Conflicts:
#	zeppelin-interpreter-integration/src/test/java/org/apache/zeppelin/integration/SparkIntegrationTest.java
  • Loading branch information
Reamer committed Oct 24, 2022
1 parent f4f0479 commit a312408
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.zeppelin.integration;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse;
Expand Down Expand Up @@ -45,6 +46,7 @@
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.EnumSet;

import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -95,6 +97,18 @@ protected void setUpSparkInterpreterSetting(InterpreterSetting interpreterSettin
// sub class can customize spark interpreter setting.
}

/**
* Configures ivy to download jar libraries only from remote.
*
* @param interpreterSetting
* @throws IOException
*/
private void setupIvySettings(InterpreterSetting interpreterSetting) throws IOException {
File ivysettings = new File(zeppelin.getZeppelinConfDir(), "ivysettings.xml");
FileUtils.copyToFile(SparkIntegrationTest.class.getResourceAsStream("/ivysettings.xml"), ivysettings);
interpreterSetting.setProperty("spark.jars.ivySettings", ivysettings.getAbsolutePath());
}

private void testInterpreterBasics() throws IOException, InterpreterException, XmlPullParserException {
// add jars & packages for testing
InterpreterSetting sparkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("spark");
Expand Down Expand Up @@ -170,6 +184,7 @@ public void testLocalMode() throws IOException, YarnException, InterpreterExcept

try {
setUpSparkInterpreterSetting(sparkInterpreterSetting);
setupIvySettings(sparkInterpreterSetting);
testInterpreterBasics();

// no yarn application launched
Expand Down Expand Up @@ -199,6 +214,7 @@ public void testYarnClientMode() throws IOException, YarnException, InterruptedE

try {
setUpSparkInterpreterSetting(sparkInterpreterSetting);
setupIvySettings(sparkInterpreterSetting);
testInterpreterBasics();

// 1 yarn application launched
Expand Down Expand Up @@ -251,6 +267,7 @@ public void testYarnClusterMode() throws IOException, YarnException, Interrupted

try {
setUpSparkInterpreterSetting(sparkInterpreterSetting);
setupIvySettings(sparkInterpreterSetting);
testInterpreterBasics();

// 1 yarn application launched
Expand Down Expand Up @@ -333,6 +350,6 @@ private String getPythonExec() throws IOException, InterruptedException {
if (process.waitFor() != 0) {
throw new RuntimeException("Fail to run command: which python.");
}
return IOUtils.toString(process.getInputStream()).trim();
return IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8).trim();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ivysettings>
<settings defaultResolver="central"/>
<resolvers>
<ibiblio name="central" m2compatible="true" root="https://repo1.maven.org/maven2/"/>
</resolvers>
</ivysettings>

0 comments on commit a312408

Please sign in to comment.