Repository: incubator-gearpump Updated Branches: refs/heads/master c176e4485 -> abe6f1047
fix GEARPUMP-35 Worker's JVM metrics is not shown correctly Project: http://git-wip-us.apache.org/repos/asf/incubator-gearpump/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-gearpump/commit/abe6f104 Tree: http://git-wip-us.apache.org/repos/asf/incubator-gearpump/tree/abe6f104 Diff: http://git-wip-us.apache.org/repos/asf/incubator-gearpump/diff/abe6f104 Branch: refs/heads/master Commit: abe6f1047bcff0a8b0ce5f846d717d28664ae2da Parents: c176e44 Author: huafengw <[email protected]> Authored: Tue Apr 26 17:56:30 2016 +0800 Committer: huafengw <[email protected]> Committed: Tue Apr 26 17:56:30 2016 +0800 ---------------------------------------------------------------------- daemon/src/main/scala/io/gearpump/cluster/worker/Worker.scala | 5 +++-- .../io/gearpump/integrationtest/checklist/RestServiceSpec.scala | 4 ++-- .../io/gearpump/integrationtest/minicluster/RestClient.scala | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-gearpump/blob/abe6f104/daemon/src/main/scala/io/gearpump/cluster/worker/Worker.scala ---------------------------------------------------------------------- diff --git a/daemon/src/main/scala/io/gearpump/cluster/worker/Worker.scala b/daemon/src/main/scala/io/gearpump/cluster/worker/Worker.scala index 1c22b05..f5e6919 100644 --- a/daemon/src/main/scala/io/gearpump/cluster/worker/Worker.scala +++ b/daemon/src/main/scala/io/gearpump/cluster/worker/Worker.scala @@ -105,11 +105,12 @@ private[cluster] class Worker(masterProxy: ActorRef) extends Actor with TimeOutS private def initializeMetrics(): Unit = { // Registers jvm metrics - Metrics(context.system).register(new JvmMetricsSet(s"worker${id}")) + val metricsSetName = "worker" + WorkerId.render(id) + Metrics(context.system).register(new JvmMetricsSet(metricsSetName)) historyMetricsService = if (metricsEnabled) { val historyMetricsService = { - context.actorOf(Props(new HistoryMetricsService("worker" + id, getHistoryMetricsConfig))) + context.actorOf(Props(new HistoryMetricsService(metricsSetName, getHistoryMetricsConfig))) } val metricsReportService = context.actorOf(Props( http://git-wip-us.apache.org/repos/asf/incubator-gearpump/blob/abe6f104/integrationtest/core/src/it/scala/io/gearpump/integrationtest/checklist/RestServiceSpec.scala ---------------------------------------------------------------------- diff --git a/integrationtest/core/src/it/scala/io/gearpump/integrationtest/checklist/RestServiceSpec.scala b/integrationtest/core/src/it/scala/io/gearpump/integrationtest/checklist/RestServiceSpec.scala index f4abde7..3ce8a5d 100644 --- a/integrationtest/core/src/it/scala/io/gearpump/integrationtest/checklist/RestServiceSpec.scala +++ b/integrationtest/core/src/it/scala/io/gearpump/integrationtest/checklist/RestServiceSpec.scala @@ -21,7 +21,7 @@ import scala.concurrent.duration._ import io.gearpump.cluster.MasterToAppMaster import io.gearpump.cluster.master.MasterStatus -import io.gearpump.cluster.worker.WorkerSummary +import io.gearpump.cluster.worker.{WorkerId, WorkerSummary} import io.gearpump.integrationtest.{TestSpecBase, Util} /** @@ -262,7 +262,7 @@ class RestServiceSpec extends TestSpecBase { restClient.queryWorkerMetrics(workerId, current = true).metrics.nonEmpty, "metrics available") val actual = restClient.queryWorkerMetrics(workerId, current = true) - actual.path shouldEqual s"worker$workerId" + actual.path shouldEqual s"worker${WorkerId.render(workerId)}" actual.metrics.foreach(metric => { metric.time should be > 0L metric.value should not be null http://git-wip-us.apache.org/repos/asf/incubator-gearpump/blob/abe6f104/integrationtest/core/src/main/scala/io/gearpump/integrationtest/minicluster/RestClient.scala ---------------------------------------------------------------------- diff --git a/integrationtest/core/src/main/scala/io/gearpump/integrationtest/minicluster/RestClient.scala b/integrationtest/core/src/main/scala/io/gearpump/integrationtest/minicluster/RestClient.scala index 087f188..72b0f84 100644 --- a/integrationtest/core/src/main/scala/io/gearpump/integrationtest/minicluster/RestClient.scala +++ b/integrationtest/core/src/main/scala/io/gearpump/integrationtest/minicluster/RestClient.scala @@ -179,7 +179,8 @@ class RestClient(host: String, port: Int) { def queryWorkerMetrics(workerId: WorkerId, current: Boolean): HistoryMetrics = { val args = if (current) "?readLatest=true" else "" - val resp = callApi(s"worker/${WorkerId.render(workerId)}/metrics/worker$workerId?$args") + val workerIdStr = WorkerId.render(workerId) + val resp = callApi(s"worker/$workerIdStr/metrics/worker$workerIdStr?$args") decodeAs[HistoryMetrics](resp) }
