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
3a1bcd40
Commit
3a1bcd40
authored
12 years ago
by
Richard Benkovsky
Browse files
Options
Downloads
Patches
Plain Diff
Added tests for CacheTrackerActor
parent
8f2f736d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/main/scala/spark/CacheTracker.scala
+3
-1
3 additions, 1 deletion
core/src/main/scala/spark/CacheTracker.scala
core/src/test/scala/spark/CacheTrackerSuite.scala
+97
-0
97 additions, 0 deletions
core/src/test/scala/spark/CacheTrackerSuite.scala
with
100 additions
and
1 deletion
core/src/main/scala/spark/CacheTracker.scala
+
3
−
1
View file @
3a1bcd40
...
...
@@ -82,7 +82,8 @@ class CacheTrackerActor extends DaemonActor with Logging {
logInfo
(
"Cache entry removed: (%s, %s) on %s"
.
format
(
rddId
,
partition
,
host
))
}
locs
(
rddId
)(
partition
)
=
locs
(
rddId
)(
partition
).
filterNot
(
_
==
host
)
reply
(
'OK
)
case
MemoryCacheLost
(
host
)
=>
logInfo
(
"Memory cache lost on "
+
host
)
// TODO: Drop host from the memory locations list of all RDDs
...
...
@@ -225,6 +226,7 @@ class CacheTracker(isMaster: Boolean, theCache: Cache) extends Logging {
// Called by the Cache to report that an entry has been dropped from it
def
dropEntry
(
datasetId
:
Any
,
partition
:
Int
)
{
datasetId
match
{
//TODO - do we really want to use '!!' when nobody checks returned future? '!' seems to enough here.
case
(
cache
.
keySpaceId
,
rddId
:
Int
)
=>
trackerActor
!!
DroppedFromCache
(
rddId
,
partition
,
Utils
.
getHost
)
}
}
...
...
This diff is collapsed.
Click to expand it.
core/src/test/scala/spark/CacheTrackerSuite.scala
0 → 100644
+
97
−
0
View file @
3a1bcd40
package
spark
import
org.scalatest.FunSuite
import
collection.mutable.HashMap
class
CacheTrackerSuite
extends
FunSuite
{
test
(
"CacheTrackerActor slave initialization & cache status"
)
{
System
.
setProperty
(
"spark.master.port"
,
"1345"
)
val
initialSize
=
2L
<<
20
val
tracker
=
new
CacheTrackerActor
tracker
.
start
()
tracker
!?
SlaveCacheStarted
(
"host001"
,
initialSize
)
assert
(
tracker
!?
GetCacheStatus
==
Seq
((
"host001"
,
2097152L
,
0L
)))
tracker
!?
StopCacheTracker
}
test
(
"RegisterRDD"
)
{
System
.
setProperty
(
"spark.master.port"
,
"1345"
)
val
initialSize
=
2L
<<
20
val
tracker
=
new
CacheTrackerActor
tracker
.
start
()
tracker
!?
SlaveCacheStarted
(
"host001"
,
initialSize
)
tracker
!?
RegisterRDD
(
1
,
3
)
tracker
!?
RegisterRDD
(
2
,
1
)
assert
(
getCacheLocations
(
tracker
)
==
Map
(
1
->
List
(
List
(),
List
(),
List
()),
2
->
List
(
List
())))
tracker
!?
StopCacheTracker
}
test
(
"AddedToCache"
)
{
System
.
setProperty
(
"spark.master.port"
,
"1345"
)
val
initialSize
=
2L
<<
20
val
tracker
=
new
CacheTrackerActor
tracker
.
start
()
tracker
!?
SlaveCacheStarted
(
"host001"
,
initialSize
)
tracker
!?
RegisterRDD
(
1
,
2
)
tracker
!?
RegisterRDD
(
2
,
1
)
tracker
!?
AddedToCache
(
1
,
0
,
"host001"
,
2L
<<
15
)
tracker
!?
AddedToCache
(
1
,
1
,
"host001"
,
2L
<<
11
)
tracker
!?
AddedToCache
(
2
,
0
,
"host001"
,
3L
<<
10
)
assert
(
tracker
!?
GetCacheStatus
==
Seq
((
"host001"
,
2097152L
,
72704L
)))
assert
(
getCacheLocations
(
tracker
)
==
Map
(
1
->
List
(
List
(
"host001"
),
List
(
"host001"
)),
2
->
List
(
List
(
"host001"
))))
tracker
!?
StopCacheTracker
}
test
(
"DroppedFromCache"
)
{
System
.
setProperty
(
"spark.master.port"
,
"1345"
)
val
initialSize
=
2L
<<
20
val
tracker
=
new
CacheTrackerActor
tracker
.
start
()
tracker
!?
SlaveCacheStarted
(
"host001"
,
initialSize
)
tracker
!?
RegisterRDD
(
1
,
2
)
tracker
!?
RegisterRDD
(
2
,
1
)
tracker
!?
AddedToCache
(
1
,
0
,
"host001"
,
2L
<<
15
)
tracker
!?
AddedToCache
(
1
,
1
,
"host001"
,
2L
<<
11
)
tracker
!?
AddedToCache
(
2
,
0
,
"host001"
,
3L
<<
10
)
assert
(
tracker
!?
GetCacheStatus
==
Seq
((
"host001"
,
2097152L
,
72704L
)))
assert
(
getCacheLocations
(
tracker
)
==
Map
(
1
->
List
(
List
(
"host001"
),
List
(
"host001"
)),
2
->
List
(
List
(
"host001"
))))
tracker
!?
DroppedFromCache
(
1
,
1
,
"host001"
,
2L
<<
11
)
assert
(
tracker
!?
GetCacheStatus
==
Seq
((
"host001"
,
2097152L
,
68608L
)))
assert
(
getCacheLocations
(
tracker
)
==
Map
(
1
->
List
(
List
(
"host001"
),
List
()),
2
->
List
(
List
(
"host001"
))))
tracker
!?
StopCacheTracker
}
/**
* Helper function to get cacheLocations from CacheTracker
*/
def
getCacheLocations
(
tracker
:
CacheTrackerActor
)
=
tracker
!?
GetCacheLocations
match
{
case
h
:
HashMap
[
_
,
_
]
=>
h
.
asInstanceOf
[
HashMap
[
Int
,
Array
[
List
[
String
]]]].
map
{
case
(
i
,
arr
)
=>
(
i
->
arr
.
toList
)
}
}
}
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