pan3793 commented on code in PR #4746:
URL: https://github.com/apache/zeppelin/pull/4746#discussion_r1560365128


##########
zeppelin-test/src/main/java/org/apache/zeppelin/test/DownloadUtils.java:
##########
@@ -0,0 +1,537 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zeppelin.test;
+
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.ArchiveInputStream;
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import me.tongfei.progressbar.DelegatingProgressBarConsumer;
+import me.tongfei.progressbar.ProgressBar;
+import me.tongfei.progressbar.ProgressBarBuilder;
+import me.tongfei.progressbar.ProgressBarStyle;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.Optional;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+/**
+ * Utility class for downloading spark/flink/livy. This is used for 
spark/flink integration test.
+ */
+public class DownloadUtils {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(DownloadUtils.class);
+
+  private static final String MIRROR_URL = 
"https://www.apache.org/dyn/closer.lua?preferred=true";;
+  private static final String ARCHIVE_URL = "https://archive.apache.org/dist/";;
+
+  private static String downloadFolder = System.getProperty("user.home") + 
"/.cache";
+  public static final String DEFAULT_SPARK_VERSION = "3.4.2";
+  public static final String DEFAULT_SPARK_HADOOP_VERSION = "3";
+
+  private DownloadUtils() {
+    throw new IllegalStateException("Utility class");
+  }
+
+  static {
+    try {
+      FileUtils.forceMkdir(new File(downloadFolder));
+    } catch (IOException e) {
+      throw new RuntimeException("Fail to create download folder: " + 
downloadFolder, e);
+    }
+  }
+
+  /**
+   * Download Spark with default versions
+   *
+   * @return home of Spark installation
+   */
+  public static String downloadSpark() {
+    return downloadSpark(DEFAULT_SPARK_VERSION, DEFAULT_SPARK_HADOOP_VERSION);
+  }
+
+  /**
+   * Download of a Spark distribution
+   *
+   * @param sparkVersion
+   * @param hadoopVersion
+   * @return home of Spark installation
+   */
+  public static String downloadSpark(String sparkVersion, String 
hadoopVersion) {

Review Comment:
   maybe we should expose `scalaVersion` too, Spark 4 is going to release in 
mid-2024, it only supports Scala 2.13



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to