Skip to content

Commit f9be1a4

Browse files
bsikandernoorul
authored andcommitted
feat(jobserver): Add JMX metric for job cache (spark-jobserver#944)
1 parent c9269b9 commit f9be1a4

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ spark-jobserver provides a RESTful interface for submitting and managing [Apache
66
This repo contains the complete Spark job server project, including unit tests and deploy scripts.
77
It was originally started at [Ooyala](http://www.ooyala.com), but this is now the main development repo.
88

9-
Other useful links: [Troubleshooting Tips](doc/troubleshooting.md), [Yarn tips](doc/yarn.md), [Mesos tips](doc/mesos.md).
9+
Other useful links: [Troubleshooting Tips](doc/troubleshooting.md), [Yarn tips](doc/yarn.md), [Mesos tips](doc/mesos.md), [JMX tips](doc/jmx.md).
1010

1111
Also see [Chinese docs / 中文](doc/chinese/job-server.md).
1212

doc/jmx.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#### JMX
2+
To read JMX metrics, you can use [jconsole](http://docs.oracle.com/javase/7/docs/technotes/guides/management/jconsole.html) if you have an option of GUI. Otherwise you can use a cli utility named `jmxcli`. Here are the steps
3+
4+
- `wget https://github.com/downloads/vladimirvivien/jmx-cli/jmxcli-0.1.2-bin.zip`
5+
- `unzip jmxcli-0.1.2-bin.zip -d <folder>`
6+
- `cd <folder>`
7+
- execute `java -jar cli.jar`
8+
- Do `ps` to list all the JVMs
9+
- Connect with JVM using `connect pid:<pid_id>`
10+
- Use `list` to see all the possible mbeans
11+
- To get the current value of a metric use for example
12+
```exec bean:"\"spark.jobserver\":name=\"job-cache-size\",type=\"JobCacheImpl\"" get:Value```

job-server/src/main/scala/spark/jobserver/JobCache.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory
1212
import spark.jobserver.io.{BinaryType, JobDAOActor}
1313
import spark.jobserver.japi.BaseJavaJob
1414
import spark.jobserver.util.{ContextURLClassLoader, JarUtils, LRUCache}
15+
import spark.jobserver.common.akka.metrics.YammerMetrics
1516

1617
import akka.pattern.ask
1718

@@ -25,13 +26,15 @@ import scala.concurrent.Await
2526
class JobCacheImpl(maxEntries: Int,
2627
dao: ActorRef,
2728
sparkContext: SparkContext,
28-
loader: ContextURLClassLoader) extends JobCache {
29+
loader: ContextURLClassLoader) extends JobCache with YammerMetrics {
2930
import scala.concurrent.duration._
3031

3132
private val cache = new LRUCache[(String, DateTime, String, BinaryType), BinaryJobInfo](maxEntries)
3233
private val logger = LoggerFactory.getLogger(getClass)
3334
implicit val daoAskTimeout: Timeout = Timeout(60 seconds)
3435

36+
val metricJobCache = gauge("job-cache-size", cache.size)
37+
3538
/**
3639
* Retrieves the given SparkJob class from the cache if it's there, otherwise use the DAO to retrieve it.
3740
* @param appName the appName under which the binary was uploaded

0 commit comments

Comments
 (0)