Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs525-sp18-g07
spark
Commits
a842c630
Commit
a842c630
authored
12 years ago
by
Matei Zaharia
Browse files
Options
Downloads
Patches
Plain Diff
Minor formatting fixes
parent
2d6a629f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/src/main/scala/spark/storage/BlockManager.scala
+15
-12
15 additions, 12 deletions
core/src/main/scala/spark/storage/BlockManager.scala
with
15 additions
and
12 deletions
core/src/main/scala/spark/storage/BlockManager.scala
+
15
−
12
View file @
a842c630
...
...
@@ -83,6 +83,8 @@ class BlockManager(val master: BlockManagerMaster, val serializer: Serializer, m
// TODO: This will be removed after cacheTracker is removed from the code base.
var
cacheTracker
:
CacheTracker
=
null
val
numParallelFetches
=
BlockManager
.
getNumParallelFetchesFromSystemProperties
()
initLogging
()
initialize
()
...
...
@@ -279,7 +281,6 @@ class BlockManager(val master: BlockManagerMaster, val serializer: Serializer, m
val
results
=
new
LinkedBlockingQueue
[(
String
,
Option
[()
=>
Iterator
[
Any
]])]
// Bound the number and memory usage of fetched remote blocks.
val
parallelFetches
=
BlockManager
.
getNumParallelFetchesFromSystemProperties
val
blocksToRequest
=
new
Queue
[(
BlockManagerId
,
BlockMessage
)]
def
sendRequest
(
bmId
:
BlockManagerId
,
blockMessages
:
Seq
[
BlockMessage
])
{
...
...
@@ -290,7 +291,7 @@ class BlockManager(val master: BlockManagerMaster, val serializer: Serializer, m
case
Some
(
message
)
=>
{
val
bufferMessage
=
message
.
asInstanceOf
[
BufferMessage
]
val
blockMessageArray
=
BlockMessageArray
.
fromBufferMessage
(
bufferMessage
)
blockMessage
Array
.
foreach
(
blockMessage
=>
{
for
(
blockMessage
<-
blockMessage
Array
)
{
if
(
blockMessage
.
getType
!=
BlockMessage
.
TYPE_GOT_BLOCK
)
{
throw
new
SparkException
(
"Unexpected message "
+
blockMessage
.
getType
+
" received from "
+
cmId
)
...
...
@@ -298,7 +299,7 @@ class BlockManager(val master: BlockManagerMaster, val serializer: Serializer, m
val
blockId
=
blockMessage
.
getId
results
.
put
((
blockId
,
Some
(()
=>
dataDeserialize
(
blockMessage
.
getData
))))
logDebug
(
"Got remote block "
+
blockId
+
" after "
+
Utils
.
getUsedTimeMs
(
startTime
))
}
)
}
}
case
None
=>
{
logError
(
"Could not get block(s) from "
+
cmId
)
...
...
@@ -318,9 +319,9 @@ class BlockManager(val master: BlockManagerMaster, val serializer: Serializer, m
localBlockIds
++=
blockIds
}
else
{
remoteBlockIds
++=
blockIds
blockId
s
.
foreach
{
blockId
=>
for
(
blockId
<-
blockId
s
)
{
val
blockMessage
=
BlockMessage
.
fromGetBlock
(
GetBlock
(
blockId
))
if
(
initialRequests
<
p
arallelFetches
)
{
if
(
initialRequests
<
numP
arallelFetches
)
{
initialRequestBlocks
.
getOrElseUpdate
(
address
,
new
ArrayBuffer
[
BlockMessage
])
.
append
(
blockMessage
)
initialRequests
+=
1
...
...
@@ -331,15 +332,17 @@ class BlockManager(val master: BlockManagerMaster, val serializer: Serializer, m
}
}
// Send out initial request(s) for 'parallelFetches' blocks.
for
((
bmId
,
blockMessages
)
<-
initialRequestBlocks
)
{
sendRequest
(
bmId
,
blockMessages
)
}
// Send out initial request(s) for 'numParallelFetches' blocks.
for
((
bmId
,
blockMessages
)
<-
initialRequestBlocks
)
{
sendRequest
(
bmId
,
blockMessages
)
}
logDebug
(
"Started remote gets for "
+
p
arallelFetches
+
" blocks in "
+
logDebug
(
"Started remote gets for "
+
numP
arallelFetches
+
" blocks in "
+
Utils
.
getUsedTimeMs
(
startTime
)
+
" ms"
)
// Get the local blocks while remote blocks are being fetched.
startTime
=
System
.
currentTimeMillis
localBlockIds
.
foreach
(
id
=>
{
for
(
id
<-
localBlockIds
)
{
getLocal
(
id
)
match
{
case
Some
(
block
)
=>
{
results
.
put
((
id
,
Some
(()
=>
block
)))
...
...
@@ -349,7 +352,7 @@ class BlockManager(val master: BlockManagerMaster, val serializer: Serializer, m
throw
new
BlockException
(
id
,
"Could not get block "
+
id
+
" from local machine"
)
}
}
}
)
}
logDebug
(
"Got local blocks in "
+
Utils
.
getUsedTimeMs
(
startTime
)
+
" ms"
)
// Return an iterator that will read fetched blocks off the queue as they arrive.
...
...
@@ -362,8 +365,8 @@ class BlockManager(val master: BlockManagerMaster, val serializer: Serializer, m
resultsGotten
+=
1
val
(
blockId
,
functionOption
)
=
results
.
take
()
if
(
remoteBlockIds
.
contains
(
blockId
)
&&
!
blocksToRequest
.
isEmpty
)
{
val
(
bmId
,
blockMessage
)
=
blocksToRequest
.
dequeue
sendRequest
(
bmId
,
Seq
(
blockMessage
))
val
(
bmId
,
blockMessage
)
=
blocksToRequest
.
dequeue
()
sendRequest
(
bmId
,
Seq
(
blockMessage
))
}
(
blockId
,
functionOption
.
map
(
_
.
apply
()))
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment