Skip to content

Commit bc04e05

Browse files
author
Ilya Ganelin
committed
Minor fixes and doc updates
1 parent 25d3f52 commit bc04e05

File tree

6 files changed

+36
-66
lines changed

6 files changed

+36
-66
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,28 +178,28 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
178178
* suffix is provided then seconds are assumed.
179179
*/
180180
def getTimeAsSec(key: String): Long = {
181-
Utils.timeStringAsSec(getOption(key).getOrElse(throw new NoSuchElementException(key)))
181+
Utils.timeStringAsSec(get(key))
182182
}
183183

184184
/** Get a time parameter as seconds, falling back to a default if not set. If no
185185
* suffix is provided then seconds are assumed.
186186
*/
187187
def getTimeAsSec(key: String, defaultValue: String): Long = {
188-
Utils.timeStringAsSec(getOption(key).getOrElse(defaultValue))
188+
Utils.timeStringAsSec(get(key, defaultValue))
189189
}
190190

191191
/** Get a time parameter as milliseconds; throws a NoSuchElementException if it's not set. If no
192192
* suffix is provided then milliseconds are assumed.
193193
*/
194194
def getTimeAsMs(key: String): Long = {
195-
Utils.timeStringAsMs(getOption(key).getOrElse(throw new NoSuchElementException(key)))
195+
Utils.timeStringAsMs(get(key))
196196
}
197197

198198
/** Get a time parameter as milliseconds, falling back to a default if not set. If no
199199
* suffix is provided then milliseconds are assumed.
200200
*/
201201
def getTimeAsMs(key: String, defaultValue: String): Long = {
202-
Utils.timeStringAsMs(getOption(key).getOrElse(defaultValue))
202+
Utils.timeStringAsMs(get(key, defaultValue))
203203
}
204204

205205

core/src/main/scala/org/apache/spark/util/Utils.scala

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import java.util.{Properties, Locale, Random, UUID}
2525
import java.util.concurrent._
2626
import javax.net.ssl.HttpsURLConnection
2727

28-
import org.apache.spark.network.util.JavaUtils
29-
3028
import scala.collection.JavaConversions._
3129
import scala.collection.Map
3230
import scala.collection.mutable.ArrayBuffer
@@ -48,6 +46,7 @@ import tachyon.client.{TachyonFS, TachyonFile}
4846

4947
import org.apache.spark._
5048
import org.apache.spark.deploy.SparkHadoopUtil
49+
import org.apache.spark.network.util.JavaUtils
5150
import org.apache.spark.serializer.{DeserializationStream, SerializationStream, SerializerInstance}
5251

5352
/** CallSite represents a place in user code. It can have a short and a long form. */
@@ -1013,14 +1012,6 @@ private[spark] object Utils extends Logging {
10131012
)
10141013
}
10151014

1016-
/**
1017-
* Convert a time parameter such as (50s, 100ms, or 250us) to microseconds for internal use. If
1018-
* no suffix is provided, the passed number is assumed to be in us.
1019-
*/
1020-
def timeStringAsUs(str: String): Long = {
1021-
JavaUtils.timeStringAsUs(str)
1022-
}
1023-
10241015
/**
10251016
* Convert a time parameter such as (50s, 100ms, or 250us) to microseconds for internal use. If
10261017
* no suffix is provided, the passed number is assumed to be in ms.

core/src/test/scala/org/apache/spark/util/UtilsSuite.scala

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@
1717

1818
package org.apache.spark.util
1919

20-
import java.lang.NumberFormatException
21-
import java.util.concurrent.TimeUnit
22-
2320
import scala.util.Random
2421

2522
import java.io.{File, ByteArrayOutputStream, ByteArrayInputStream, FileOutputStream}
2623
import java.net.{BindException, ServerSocket, URI}
2724
import java.nio.{ByteBuffer, ByteOrder}
2825
import java.text.DecimalFormatSymbols
26+
import java.util.concurrent.TimeUnit
2927
import java.util.Locale
3028

3129
import com.google.common.base.Charsets.UTF_8
@@ -61,14 +59,6 @@ class UtilsSuite extends FunSuite with ResetSystemProperties {
6159
assert(Utils.timeStringAsMs("1min") === TimeUnit.MINUTES.toMillis(1))
6260
assert(Utils.timeStringAsMs("1h") === TimeUnit.HOURS.toMillis(1))
6361
assert(Utils.timeStringAsMs("1d") === TimeUnit.DAYS.toMillis(1))
64-
65-
assert(Utils.timeStringAsUs("1") === 1)
66-
assert(Utils.timeStringAsUs("1us") === 1)
67-
assert(Utils.timeStringAsUs("1ms") === TimeUnit.MILLISECONDS.toMicros(1))
68-
assert(Utils.timeStringAsUs("1s") === TimeUnit.SECONDS.toMicros(1))
69-
assert(Utils.timeStringAsUs("1min") === TimeUnit.MINUTES.toMicros(1))
70-
assert(Utils.timeStringAsUs("1h") === TimeUnit.HOURS.toMicros(1))
71-
assert(Utils.timeStringAsUs("1d") === TimeUnit.DAYS.toMicros(1))
7262

7363
// Test invalid strings
7464
try {

docs/configuration.md

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ val conf = new SparkConf()
3535
val sc = new SparkContext(conf)
3636
{% endhighlight %}
3737

38-
Note that we can have more than 1 thread in local mode, and in cases like spark streaming, we may
38+
Note that we can have more than 1 thread in local mode, and in cases like Spark Streaming, we may
3939
actually require one to prevent any sort of starvation issues.
4040

4141
Properties that specify some time duration should be configured with a unit of time.
4242
The following format is accepted:
4343

44-
200us (microseconds)
4544
5s (seconds)
4645
25ms (milliseconds)
4746
10m or 10min (minutes)
@@ -444,8 +443,8 @@ Apart from these, the following properties are also available, and may be useful
444443
<td><code>spark.shuffle.io.retryWait</code></td>
445444
<td>5s</td>
446445
<td>
447-
(Netty only) Seconds to wait between retries of fetches. The maximum delay caused by retrying
448-
is simply <code>maxRetries * retryWait</code>, by default 15 seconds.
446+
(Netty only) How long to wait between retries of fetches. The maximum delay caused by retrying
447+
is simply <code>maxRetries * retryWait</code>, by default 5 seconds.
449448
</td>
450449
</tr>
451450
<tr>
@@ -745,8 +744,8 @@ Apart from these, the following properties are also available, and may be useful
745744
</tr>
746745
<tr>
747746
<td><code>spark.executor.heartbeatInterval</code></td>
748-
<td>10000ms</td>
749-
<td>Interval (milliseconds) between each executor's heartbeats to the driver. Heartbeats let
747+
<td>10s</td>
748+
<td>Interval between each executor's heartbeats to the driver. Heartbeats let
750749
the driver know that the executor is still alive and update it with metrics for in-progress
751750
tasks.</td>
752751
</tr>
@@ -755,7 +754,7 @@ Apart from these, the following properties are also available, and may be useful
755754
<td>60s</td>
756755
<td>
757756
Communication timeout to use when fetching files added through SparkContext.addFile() from
758-
the driver, in seconds.
757+
the driver.
759758
</td>
760759
</tr>
761760
<tr>
@@ -870,7 +869,7 @@ Apart from these, the following properties are also available, and may be useful
870869
<td>
871870
This is set to a larger value to disable the transport failure detector that comes built in to
872871
Akka. It can be enabled again, if you plan to use this feature (Not recommended). A larger
873-
interval value in seconds reduces network overhead and a smaller value ( ~ 1 s) might be more
872+
interval value reduces network overhead and a smaller value ( ~ 1 s) might be more
874873
informative for Akka's failure detector. Tune this in combination of `spark.akka.heartbeat.pauses`
875874
if you need to. A likely positive use case for using failure detector would be: a sensistive
876875
failure detector can help evict rogue executors quickly. However this is usually not the case
@@ -885,7 +884,7 @@ Apart from these, the following properties are also available, and may be useful
885884
<td>
886885
This is set to a larger value to disable the transport failure detector that comes built in to Akka.
887886
It can be enabled again, if you plan to use this feature (Not recommended). Acceptable heart
888-
beat pause in seconds for Akka. This can be used to control sensitivity to GC pauses. Tune
887+
beat pause for Akka. This can be used to control sensitivity to GC pauses. Tune
889888
this along with `spark.akka.heartbeat.interval` if you need to.
890889
</td>
891890
</tr>
@@ -901,7 +900,7 @@ Apart from these, the following properties are also available, and may be useful
901900
<td><code>spark.akka.timeout</code></td>
902901
<td>100s</td>
903902
<td>
904-
Communication timeout between Spark nodes, in seconds.
903+
Communication timeout between Spark nodes.
905904
</td>
906905
</tr>
907906
<tr>
@@ -953,8 +952,8 @@ Apart from these, the following properties are also available, and may be useful
953952
<td><code>spark.network.timeout</code></td>
954953
<td>120s</td>
955954
<td>
956-
Default timeout for all network interactions, in seconds. This config will be used in
957-
place of <code>spark.core.connection.ack.wait.timeout</code>, <code>spark.akka.timeout</code>,
955+
Default timeout for all network interactions. This config will be used in place of
956+
<code>spark.core.connection.ack.wait.timeout</code>, <code>spark.akka.timeout</code>,
958957
<code>spark.storage.blockManagerSlaveTimeoutMs</code> or
959958
<code>spark.shuffle.io.connectionTimeout</code>, if they are not configured.
960959
</td>
@@ -1002,9 +1001,9 @@ Apart from these, the following properties are also available, and may be useful
10021001
</tr>
10031002
<tr>
10041003
<td><code>spark.locality.wait</code></td>
1005-
<td>3000ms</td>
1004+
<td>3s</td>
10061005
<td>
1007-
Number of milliseconds to wait to launch a data-local task before giving up and launching it
1006+
How long to wait to launch a data-local task before giving up and launching it
10081007
on a less-local node. The same wait will be used to step through multiple locality levels
10091008
(process-local, node-local, rack-local and then any). It is also possible to customize the
10101009
waiting time for each level by setting <code>spark.locality.wait.node</code>, etc.
@@ -1037,10 +1036,9 @@ Apart from these, the following properties are also available, and may be useful
10371036
</tr>
10381037
<tr>
10391038
<td><code>spark.scheduler.maxRegisteredResourcesWaitingTime</code></td>
1040-
<td>30000ms</td>
1039+
<td>30s</td>
10411040
<td>
1042-
Maximum amount of time to wait for resources to register before scheduling begins
1043-
(in milliseconds).
1041+
Maximum amount of time to wait for resources to register before scheduling begins.
10441042
</td>
10451043
</tr>
10461044
<tr>
@@ -1067,10 +1065,9 @@ Apart from these, the following properties are also available, and may be useful
10671065
</tr>
10681066
<tr>
10691067
<td><code>spark.scheduler.revive.interval</code></td>
1070-
<td>1000ms</td>
1068+
<td>1s</td>
10711069
<td>
1072-
The interval length for the scheduler to revive the worker resource offers to run tasks
1073-
(in milliseconds).
1070+
The interval length for the scheduler to revive the worker resource offers to run tasks.
10741071
</td>
10751072
</tr>
10761073
<tr>
@@ -1085,7 +1082,7 @@ Apart from these, the following properties are also available, and may be useful
10851082
<td><code>spark.speculation.interval</code></td>
10861083
<td>100ms</td>
10871084
<td>
1088-
How often Spark will check for tasks to speculate, in milliseconds.
1085+
How often Spark will check for tasks to speculate.
10891086
</td>
10901087
</tr>
10911088
<tr>
@@ -1142,8 +1139,8 @@ Apart from these, the following properties are also available, and may be useful
11421139
<td><code>spark.dynamicAllocation.executorIdleTimeout</code></td>
11431140
<td>600s</td>
11441141
<td>
1145-
If dynamic allocation is enabled and an executor has been idle for more than this duration
1146-
(in seconds), the executor will be removed. For more detail, see this
1142+
If dynamic allocation is enabled and an executor has been idle for more than this duration,
1143+
the executor will be removed. For more detail, see this
11471144
<a href="job-scheduling.html#resource-allocation-policy">description</a>.
11481145
</td>
11491146
</tr>
@@ -1173,7 +1170,7 @@ Apart from these, the following properties are also available, and may be useful
11731170
<td>5s</td>
11741171
<td>
11751172
If dynamic allocation is enabled and there have been pending tasks backlogged for more than
1176-
this duration (in seconds), new executors will be requested. For more detail, see this
1173+
this duration, new executors will be requested. For more detail, see this
11771174
<a href="job-scheduling.html#resource-allocation-policy">description</a>.
11781175
</td>
11791176
</tr>
@@ -1230,7 +1227,7 @@ Apart from these, the following properties are also available, and may be useful
12301227
<td><code>spark.core.connection.ack.wait.timeout</code></td>
12311228
<td>60s</td>
12321229
<td>
1233-
Number of seconds for the connection to wait for ack to occur before timing
1230+
How long for the connection to wait for ack to occur before timing
12341231
out and giving up. To avoid unwilling timeout caused by long pause like GC,
12351232
you can set larger value.
12361233
</td>
@@ -1239,7 +1236,7 @@ Apart from these, the following properties are also available, and may be useful
12391236
<td><code>spark.core.connection.auth.wait.timeout</code></td>
12401237
<td>30s</td>
12411238
<td>
1242-
Number of seconds for the connection to wait for authentication to occur before timing
1239+
How long for the connection to wait for authentication to occur before timing
12431240
out and giving up.
12441241
</td>
12451242
</tr>
@@ -1362,7 +1359,7 @@ Apart from these, the following properties are also available, and may be useful
13621359
<td><code>spark.streaming.blockInterval</code></td>
13631360
<td>200ms</td>
13641361
<td>
1365-
Interval (milliseconds) at which data received by Spark Streaming receivers is chunked
1362+
Interval at which data received by Spark Streaming receivers is chunked
13661363
into blocks of data before storing them in Spark. Minimum recommended - 50 ms. See the
13671364
<a href="streaming-programming-guide.html#level-of-parallelism-in-data-receiving">performance
13681365
tuning</a> section in the Spark Streaming programing guide for more details.

network/common/src/main/java/org/apache/spark/network/util/JavaUtils.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,7 @@ private static long parseTimeString(String str, TimeUnit unit) {
170170
throw new NumberFormatException(timeError + "\n" + e.getMessage());
171171
}
172172
}
173-
174-
/**
175-
* Convert a time parameter such as (50s, 100ms, or 250us) to microseconds for internal use. If
176-
* no suffix is provided, the passed number is assumed to be in us.
177-
*/
178-
public static long timeStringAsUs(String str) {
179-
return parseTimeString(str, TimeUnit.MICROSECONDS);
180-
}
181-
173+
182174
/**
183175
* Convert a time parameter such as (50s, 100ms, or 250us) to milliseconds for internal use. If
184176
* no suffix is provided, the passed number is assumed to be in ms.

streaming/src/test/scala/org/apache/spark/streaming/ReceiverSuite.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class ReceiverSuite extends TestSuiteBase with Timeouts with Serializable {
132132
test("block generator") {
133133
val blockGeneratorListener = new FakeBlockGeneratorListener
134134
val blockIntervalMs = 200
135-
val conf = new SparkConf().set("spark.streaming.blockInterval", s"${blockIntervalMs.toString}ms")
135+
val conf = new SparkConf().set("spark.streaming.blockInterval", s"${blockIntervalMs}ms")
136136
val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, conf)
137137
val expectedBlocks = 5
138138
val waitTime = expectedBlocks * blockIntervalMs + (blockIntervalMs / 2)
@@ -157,15 +157,15 @@ class ReceiverSuite extends TestSuiteBase with Timeouts with Serializable {
157157

158158
test("block generator throttling") {
159159
val blockGeneratorListener = new FakeBlockGeneratorListener
160-
val blockInterval = 100
160+
val blockIntervalMs = 100
161161
val maxRate = 100
162-
val conf = new SparkConf().set("spark.streaming.blockInterval", s"${blockInterval.toString}ms").
162+
val conf = new SparkConf().set("spark.streaming.blockInterval", s"${blockIntervalMs}ms").
163163
set("spark.streaming.receiver.maxRate", maxRate.toString)
164164
val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, conf)
165165
val expectedBlocks = 20
166-
val waitTime = expectedBlocks * blockInterval
166+
val waitTime = expectedBlocks * blockIntervalMs
167167
val expectedMessages = maxRate * waitTime / 1000
168-
val expectedMessagesPerBlock = maxRate * blockInterval / 1000
168+
val expectedMessagesPerBlock = maxRate * blockIntervalMs / 1000
169169
val generatedData = new ArrayBuffer[Int]
170170

171171
// Generate blocks

0 commit comments

Comments
 (0)