From c80b422e02195c8c00773162406394cfe7a74bdd Mon Sep 17 00:00:00 2001 From: Ray Matharu Date: Mon, 2 Dec 2019 13:37:37 -0800 Subject: [PATCH 1/4] Adding metric that is 0 when container-starting, 1 when started. --- .../main/scala/org/apache/samza/container/SamzaContainer.scala | 1 + .../scala/org/apache/samza/container/SamzaContainerMetrics.scala | 1 + 2 files changed, 2 insertions(+) diff --git a/samza-core/src/main/scala/org/apache/samza/container/SamzaContainer.scala b/samza-core/src/main/scala/org/apache/samza/container/SamzaContainer.scala index d15c1090f2..5b182abc0f 100644 --- a/samza-core/src/main/scala/org/apache/samza/container/SamzaContainer.scala +++ b/samza-core/src/main/scala/org/apache/samza/container/SamzaContainer.scala @@ -764,6 +764,7 @@ class SamzaContainer( containerListener.afterStart() } metrics.containerStartupTime.set((System.nanoTime() - startTime)/1000000) + metrics.containerStarted.set(1) if (taskInstances.size > 0) runLoop.run else diff --git a/samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala b/samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala index 1beb3dd752..78c97a551f 100644 --- a/samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala +++ b/samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala @@ -46,6 +46,7 @@ class SamzaContainerMetrics( val diskQuotaBytes = newGauge("disk-quota-bytes", Long.MaxValue) val executorWorkFactor = newGauge("executor-work-factor", 1.0) val physicalMemoryMb = newGauge[Double]("physical-memory-mb", 0.0F) + val containerStarted = newCounter("container-started") val taskStoreRestorationMetrics: util.Map[TaskName, Gauge[Long]] = new util.HashMap[TaskName, Gauge[Long]]() From 5347922b8427504f14d58bec4720f720f45f9caa Mon Sep 17 00:00:00 2001 From: Ray Matharu Date: Mon, 2 Dec 2019 13:37:37 -0800 Subject: [PATCH 2/4] Adding metric that is 0 when container-starting, 1 when started. Making the new metric a gauge --- .../org/apache/samza/container/SamzaContainerMetrics.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala b/samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala index 78c97a551f..6ca1161398 100644 --- a/samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala +++ b/samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala @@ -46,7 +46,7 @@ class SamzaContainerMetrics( val diskQuotaBytes = newGauge("disk-quota-bytes", Long.MaxValue) val executorWorkFactor = newGauge("executor-work-factor", 1.0) val physicalMemoryMb = newGauge[Double]("physical-memory-mb", 0.0F) - val containerStarted = newCounter("container-started") + val containerStarted = newGauge[Long]("container-started", 0L) val taskStoreRestorationMetrics: util.Map[TaskName, Gauge[Long]] = new util.HashMap[TaskName, Gauge[Long]]() From 6e9f2517519cec17b9ac2319be2278521c9877fc Mon Sep 17 00:00:00 2001 From: Ray Matharu Date: Mon, 2 Dec 2019 15:19:48 -0800 Subject: [PATCH 3/4] EMpty commit to trigger build From af2d442df99b6c49b10d03e8b52a9993a4854f3a Mon Sep 17 00:00:00 2001 From: Ray Matharu Date: Mon, 2 Dec 2019 23:47:36 -0800 Subject: [PATCH 4/4] Adding mock-metric in test --- .../scala/org/apache/samza/container/TestSamzaContainer.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/samza-core/src/test/scala/org/apache/samza/container/TestSamzaContainer.scala b/samza-core/src/test/scala/org/apache/samza/container/TestSamzaContainer.scala index 78136bf03c..4d5007db0b 100644 --- a/samza-core/src/test/scala/org/apache/samza/container/TestSamzaContainer.scala +++ b/samza-core/src/test/scala/org/apache/samza/container/TestSamzaContainer.scala @@ -77,6 +77,7 @@ class TestSamzaContainer extends AssertionsForJUnit with MockitoSugar { MockitoAnnotations.initMocks(this) setupSamzaContainer(Some(this.applicationContainerContext)) when(this.metrics.containerStartupTime).thenReturn(mock[Gauge[Long]]) + when(this.metrics.containerStarted).thenReturn(mock[Gauge[Long]]) } @Test