Skip to content

Commit 99ce053

Browse files
committed
merge in master
2 parents e54a8a9 + 9213f73 commit 99ce053

File tree

209 files changed

+4884
-2833
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+4884
-2833
lines changed

.rat-excludes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,8 @@ local-1430917381535_2
8686
DESCRIPTION
8787
NAMESPACE
8888
test_support/*
89+
.*Rd
90+
help/*
91+
html/*
92+
INDEX
8993
.lintr

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,6 @@ The following components are provided under the MIT License. See project link fo
948948
(MIT License) SLF4J LOG4J-12 Binding (org.slf4j:slf4j-log4j12:1.7.5 - http://www.slf4j.org)
949949
(MIT License) pyrolite (org.spark-project:pyrolite:2.0.1 - http://pythonhosted.org/Pyro4/)
950950
(MIT License) scopt (com.github.scopt:scopt_2.10:3.2.0 - https://github.com/scopt/scopt)
951-
(The MIT License) Mockito (org.mockito:mockito-all:1.8.5 - http://www.mockito.org)
951+
(The MIT License) Mockito (org.mockito:mockito-core:1.9.5 - http://www.mockito.org)
952952
(MIT License) jquery (https://jquery.org/license/)
953953
(MIT License) AnchorJS (https://github.com/bryanbraun/anchorjs)

R/pkg/R/DataFrame.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ setMethod("isLocal",
169169
#'}
170170
setMethod("showDF",
171171
signature(x = "DataFrame"),
172-
function(x, numRows = 20) {
173-
s <- callJMethod(x@sdf, "showString", numToInt(numRows))
172+
function(x, numRows = 20, truncate = TRUE) {
173+
s <- callJMethod(x@sdf, "showString", numToInt(numRows), truncate)
174174
cat(s)
175175
})
176176

2.82 KB
Binary file not shown.

R/pkg/inst/tests/jarTest.R

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
library(SparkR)
18+
19+
sc <- sparkR.init()
20+
21+
helloTest <- SparkR:::callJStatic("sparkR.test.hello",
22+
"helloWorld",
23+
"Dave")
24+
25+
basicFunction <- SparkR:::callJStatic("sparkR.test.basicFunction",
26+
"addStuff",
27+
2L,
28+
2L)
29+
30+
sparkR.stop()
31+
output <- c(helloTest, basicFunction)
32+
writeLines(output)

R/pkg/inst/tests/test_includeJAR.R

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
context("include an external JAR in SparkContext")
18+
19+
runScript <- function() {
20+
sparkHome <- Sys.getenv("SPARK_HOME")
21+
jarPath <- paste("--jars",
22+
shQuote(file.path(sparkHome, "R/lib/SparkR/test_support/sparktestjar_2.10-1.0.jar")))
23+
scriptPath <- file.path(sparkHome, "R/lib/SparkR/tests/jarTest.R")
24+
submitPath <- file.path(sparkHome, "bin/spark-submit")
25+
res <- system2(command = submitPath,
26+
args = c(jarPath, scriptPath),
27+
stdout = TRUE)
28+
tail(res, 2)
29+
}
30+
31+
test_that("sparkJars tag in SparkContext", {
32+
testOutput <- runScript()
33+
helloTest <- testOutput[1]
34+
expect_true(helloTest == "Hello, Dave")
35+
basicFunction <- testOutput[2]
36+
expect_true(basicFunction == 4L)
37+
})

R/pkg/inst/tests/test_sparkSQL.R

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ library(testthat)
1919

2020
context("SparkSQL functions")
2121

22+
# Utility function for easily checking the values of a StructField
23+
checkStructField <- function(actual, expectedName, expectedType, expectedNullable) {
24+
expect_equal(class(actual), "structField")
25+
expect_equal(actual$name(), expectedName)
26+
expect_equal(actual$dataType.toString(), expectedType)
27+
expect_equal(actual$nullable(), expectedNullable)
28+
}
29+
2230
# Tests for SparkSQL functions in SparkR
2331

2432
sc <- sparkR.init()
@@ -52,9 +60,10 @@ test_that("infer types", {
5260
list(type = 'array', elementType = "integer", containsNull = TRUE))
5361
expect_equal(infer_type(list(1L, 2L)),
5462
list(type = 'array', elementType = "integer", containsNull = TRUE))
55-
expect_equal(infer_type(list(a = 1L, b = "2")),
56-
structType(structField(x = "a", type = "integer", nullable = TRUE),
57-
structField(x = "b", type = "string", nullable = TRUE)))
63+
testStruct <- infer_type(list(a = 1L, b = "2"))
64+
expect_true(class(testStruct) == "structType")
65+
checkStructField(testStruct$fields()[[1]], "a", "IntegerType", TRUE)
66+
checkStructField(testStruct$fields()[[2]], "b", "StringType", TRUE)
5867
e <- new.env()
5968
assign("a", 1L, envir = e)
6069
expect_equal(infer_type(e),

core/pom.xml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,6 @@
6969
<dependency>
7070
<groupId>org.apache.hadoop</groupId>
7171
<artifactId>hadoop-client</artifactId>
72-
<exclusions>
73-
<exclusion>
74-
<groupId>javax.servlet</groupId>
75-
<artifactId>servlet-api</artifactId>
76-
</exclusion>
77-
<exclusion>
78-
<groupId>org.codehaus.jackson</groupId>
79-
<artifactId>jackson-mapper-asl</artifactId>
80-
</exclusion>
81-
</exclusions>
8272
</dependency>
8373
<dependency>
8474
<groupId>org.apache.spark</groupId>
@@ -354,7 +344,7 @@
354344
</dependency>
355345
<dependency>
356346
<groupId>org.mockito</groupId>
357-
<artifactId>mockito-all</artifactId>
347+
<artifactId>mockito-core</artifactId>
358348
<scope>test</scope>
359349
</dependency>
360350
<dependency>

core/src/main/scala/org/apache/spark/SSLOptions.scala

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717

1818
package org.apache.spark
1919

20-
import java.io.File
20+
import java.io.{File, FileInputStream}
21+
import java.security.{KeyStore, NoSuchAlgorithmException}
22+
import javax.net.ssl.{KeyManager, KeyManagerFactory, SSLContext, TrustManager, TrustManagerFactory}
2123

2224
import com.typesafe.config.{Config, ConfigFactory, ConfigValueFactory}
2325
import org.eclipse.jetty.util.ssl.SslContextFactory
@@ -38,7 +40,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory
3840
* @param trustStore a path to the trust-store file
3941
* @param trustStorePassword a password to access the trust-store file
4042
* @param protocol SSL protocol (remember that SSLv3 was compromised) supported by Java
41-
* @param enabledAlgorithms a set of encryption algorithms to use
43+
* @param enabledAlgorithms a set of encryption algorithms that may be used
4244
*/
4345
private[spark] case class SSLOptions(
4446
enabled: Boolean = false,
@@ -48,7 +50,8 @@ private[spark] case class SSLOptions(
4850
trustStore: Option[File] = None,
4951
trustStorePassword: Option[String] = None,
5052
protocol: Option[String] = None,
51-
enabledAlgorithms: Set[String] = Set.empty) {
53+
enabledAlgorithms: Set[String] = Set.empty)
54+
extends Logging {
5255

5356
/**
5457
* Creates a Jetty SSL context factory according to the SSL settings represented by this object.
@@ -63,7 +66,7 @@ private[spark] case class SSLOptions(
6366
trustStorePassword.foreach(sslContextFactory.setTrustStorePassword)
6467
keyPassword.foreach(sslContextFactory.setKeyManagerPassword)
6568
protocol.foreach(sslContextFactory.setProtocol)
66-
sslContextFactory.setIncludeCipherSuites(enabledAlgorithms.toSeq: _*)
69+
sslContextFactory.setIncludeCipherSuites(supportedAlgorithms.toSeq: _*)
6770

6871
Some(sslContextFactory)
6972
} else {
@@ -94,14 +97,44 @@ private[spark] case class SSLOptions(
9497
.withValue("akka.remote.netty.tcp.security.protocol",
9598
ConfigValueFactory.fromAnyRef(protocol.getOrElse("")))
9699
.withValue("akka.remote.netty.tcp.security.enabled-algorithms",
97-
ConfigValueFactory.fromIterable(enabledAlgorithms.toSeq))
100+
ConfigValueFactory.fromIterable(supportedAlgorithms.toSeq))
98101
.withValue("akka.remote.netty.tcp.enable-ssl",
99102
ConfigValueFactory.fromAnyRef(true)))
100103
} else {
101104
None
102105
}
103106
}
104107

108+
/*
109+
* The supportedAlgorithms set is a subset of the enabledAlgorithms that
110+
* are supported by the current Java security provider for this protocol.
111+
*/
112+
private val supportedAlgorithms: Set[String] = {
113+
var context: SSLContext = null
114+
try {
115+
context = SSLContext.getInstance(protocol.orNull)
116+
/* The set of supported algorithms does not depend upon the keys, trust, or
117+
rng, although they will influence which algorithms are eventually used. */
118+
context.init(null, null, null)
119+
} catch {
120+
case npe: NullPointerException =>
121+
logDebug("No SSL protocol specified")
122+
context = SSLContext.getDefault
123+
case nsa: NoSuchAlgorithmException =>
124+
logDebug(s"No support for requested SSL protocol ${protocol.get}")
125+
context = SSLContext.getDefault
126+
}
127+
128+
val providerAlgorithms = context.getServerSocketFactory.getSupportedCipherSuites.toSet
129+
130+
// Log which algorithms we are discarding
131+
(enabledAlgorithms &~ providerAlgorithms).foreach { cipher =>
132+
logDebug(s"Discarding unsupported cipher $cipher")
133+
}
134+
135+
enabledAlgorithms & providerAlgorithms
136+
}
137+
105138
/** Returns a string representation of this SSLOptions with all the passwords masked. */
106139
override def toString: String = s"SSLOptions{enabled=$enabled, " +
107140
s"keyStore=$keyStore, keyStorePassword=${keyStorePassword.map(_ => "xxx")}, " +

core/src/main/scala/org/apache/spark/SparkContext.scala

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,14 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
315315
_dagScheduler = ds
316316
}
317317

318+
/**
319+
* A unique identifier for the Spark application.
320+
* Its format depends on the scheduler implementation.
321+
* (i.e.
322+
* in case of local spark app something like 'local-1433865536131'
323+
* in case of YARN something like 'application_1433865536131_34483'
324+
* )
325+
*/
318326
def applicationId: String = _applicationId
319327
def applicationAttemptId: Option[String] = _applicationAttemptId
320328

@@ -823,7 +831,8 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
823831
* }}}
824832
*
825833
* @note Small files are preferred, large file is also allowable, but may cause bad performance.
826-
*
834+
* @note On some filesystems, `.../path/&#42;` can be a more efficient way to read all files
835+
* in a directory rather than `.../path/` or `.../path`
827836
* @param minPartitions A suggestion value of the minimal splitting number for input data.
828837
*/
829838
def wholeTextFiles(
@@ -870,9 +879,10 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
870879
* (a-hdfs-path/part-nnnnn, its content)
871880
* }}}
872881
*
873-
* @param minPartitions A suggestion value of the minimal splitting number for input data.
874-
*
875882
* @note Small files are preferred; very large files may cause bad performance.
883+
* @note On some filesystems, `.../path/&#42;` can be a more efficient way to read all files
884+
* in a directory rather than `.../path/` or `.../path`
885+
* @param minPartitions A suggestion value of the minimal splitting number for input data.
876886
*/
877887
@Experimental
878888
def binaryFiles(

0 commit comments

Comments
 (0)