revert old metric that can cause gc problems
This commit is contained in:
@@ -28,7 +28,6 @@ import reactor.core.publisher.Sinks.EmitResult.FAIL_ZERO_SUBSCRIBER
|
|||||||
import reactor.core.publisher.Sinks.EmitResult.OK
|
import reactor.core.publisher.Sinks.EmitResult.OK
|
||||||
import reactor.core.scheduler.Schedulers
|
import reactor.core.scheduler.Schedulers
|
||||||
import reactor.kotlin.core.publisher.toMono
|
import reactor.kotlin.core.publisher.toMono
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import java.util.concurrent.Future
|
import java.util.concurrent.Future
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
@@ -45,8 +44,6 @@ abstract class AbstractHead @JvmOverloads constructor(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val log = LoggerFactory.getLogger(AbstractHead::class.java)
|
private val log = LoggerFactory.getLogger(AbstractHead::class.java)
|
||||||
private val instances: MutableMap<String, AtomicInteger> = ConcurrentHashMap()
|
|
||||||
private val running: MutableMap<String, AtomicInteger> = ConcurrentHashMap()
|
|
||||||
private val executor = Executors.newSingleThreadScheduledExecutor()
|
private val executor = Executors.newSingleThreadScheduledExecutor()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,23 +57,13 @@ abstract class AbstractHead @JvmOverloads constructor(
|
|||||||
private val delayed = AtomicBoolean(false)
|
private val delayed = AtomicBoolean(false)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
||||||
val className = this.javaClass.simpleName
|
val className = this.javaClass.simpleName
|
||||||
|
|
||||||
Gauge.builder("stuck_head", delayed) {
|
Gauge.builder("stuck_head", delayed) {
|
||||||
if (it.get()) 1.0 else 0.0
|
if (it.get()) 1.0 else 0.0
|
||||||
}.tag("upstream", upstreamId).tag("class", className).register(Metrics.globalRegistry)
|
}.tag("upstream", upstreamId).tag("class", className).register(Metrics.globalRegistry)
|
||||||
Gauge.builder("current_head", forkChoice) {
|
Gauge.builder("current_head", forkChoice) {
|
||||||
it.getHead()?.height?.toDouble() ?: 0.0
|
it.getHead()?.height?.toDouble() ?: 0.0
|
||||||
}.tag("upstream", upstreamId).tag("class", className).register(Metrics.globalRegistry)
|
}.tag("upstream", upstreamId).tag("class", className).register(Metrics.globalRegistry)
|
||||||
|
|
||||||
instances.computeIfAbsent(className) {
|
|
||||||
AtomicInteger(0).also { toHeadCountMetric(it, "allocated") }
|
|
||||||
}.incrementAndGet()
|
|
||||||
}
|
|
||||||
|
|
||||||
protected fun finalize() {
|
|
||||||
instances[this.javaClass.simpleName]?.decrementAndGet()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun follow(source: Flux<BlockContainer>): Disposable {
|
fun follow(source: Flux<BlockContainer>): Disposable {
|
||||||
@@ -164,7 +151,6 @@ abstract class AbstractHead @JvmOverloads constructor(
|
|||||||
stopping = true
|
stopping = true
|
||||||
log.debug("Stop ${this.javaClass.simpleName} $upstreamId")
|
log.debug("Stop ${this.javaClass.simpleName} $upstreamId")
|
||||||
future?.let {
|
future?.let {
|
||||||
running[this.javaClass.simpleName]?.decrementAndGet()
|
|
||||||
it.cancel(true)
|
it.cancel(true)
|
||||||
}
|
}
|
||||||
future = null
|
future = null
|
||||||
@@ -183,10 +169,6 @@ abstract class AbstractHead @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}, 180, 30, TimeUnit.SECONDS
|
}, 180, 30, TimeUnit.SECONDS
|
||||||
)
|
)
|
||||||
|
|
||||||
running.computeIfAbsent(this.javaClass.simpleName) {
|
|
||||||
AtomicInteger(0).also { toHeadCountMetric(it, "running") }
|
|
||||||
}.incrementAndGet()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user