1919# from CRAN.
2020
2121# ' Download and Install Apache Spark to a Local Directory
22- # '
22+ # '
2323# ' \code{install.spark} downloads and installs Spark to a local directory if
2424# ' it is not found. The Spark version we use is the same as the SparkR version.
2525# ' Users can specify a desired Hadoop version, the remote mirror site, and
5959# ' @return \code{install.spark} returns the local directory where Spark is found or installed
6060# ' @rdname install.spark
6161# ' @name install.spark
62+ # ' @aliases install.spark
6263# ' @export
6364# ' @examples
6465# '\dontrun{
@@ -131,7 +132,7 @@ robust_download_tar <- function(mirrorUrl, version, hadoopVersion, packageName,
131132
132133 # step 2: use url suggested from apache website
133134 message(" Looking for site suggested from apache website..." )
134- mirrorUrl <- get_preferred_mirror()
135+ mirrorUrl <- get_preferred_mirror(version , packageName )
135136 if (! is.null(mirrorUrl )) {
136137 success <- direct_download_tar(mirrorUrl , version , hadoopVersion ,
137138 packageName , packageLocalPath )
@@ -156,8 +157,11 @@ robust_download_tar <- function(mirrorUrl, version, hadoopVersion, packageName,
156157 }
157158}
158159
159- get_preferred_mirror <- function () {
160- jsonUrl <- " http://www.apache.org/dyn/closer.cgi?as_json=1"
160+ get_preferred_mirror <- function (version , packageName ) {
161+ jsonUrl <- paste0(" http://www.apache.org/dyn/closer.cgi?path=" ,
162+ file.path(" spark" , version , packageName ),
163+ " .tgz&as_json=1" )
164+ # jsonUrl <- "http://www.apache.org/dyn/closer.cgi?as_json=1"
161165 textLines <- readLines(jsonUrl , warn = FALSE )
162166 rowNum <- grep(" \" preferred\" " , textLines )
163167 linePreferred <- textLines [rowNum ]
@@ -185,6 +189,7 @@ direct_download_tar <- function(mirrorUrl, version, hadoopVersion, packageName,
185189 isFail <- tryCatch(download.file(packageRemotePath , packageLocalPath ),
186190 error = function (e ) {
187191 message(sprintf(" Fetch failed from %s" , mirrorUrl ))
192+ print(e )
188193 TRUE
189194 })
190195 ! isFail
0 commit comments