KT-57296 And backward compatibility with old Idea versions
This commit is contained in:
committed by
Space Team
parent
6af1c550b6
commit
37eefc2a05
+39
-1
@@ -38,6 +38,14 @@ interface KotlinBuildStatsMXBean {
|
||||
fun reportNumber(name: String, value: Long, subprojectName: String?, weight: Long?): Boolean
|
||||
|
||||
fun reportString(name: String, value: String, subprojectName: String?, weight: Long?): Boolean
|
||||
|
||||
//support Idea up to 2023.1 version, before KT-57371 fix
|
||||
|
||||
fun reportBoolean(name: String, value: Boolean, subprojectName: String?): Boolean
|
||||
|
||||
fun reportNumber(name: String, value: Long, subprojectName: String?): Boolean
|
||||
|
||||
fun reportString(name: String, value: String, subprojectName: String?): Boolean
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +173,7 @@ internal abstract class KotlinBuildStatsService internal constructor() : BuildAd
|
||||
internal class JMXKotlinBuildStatsService(private val mbs: MBeanServer, private val beanName: ObjectName) :
|
||||
KotlinBuildStatsService() {
|
||||
|
||||
private fun callJmx(method: String, type: String, metricName: String, value: Any, subprojectName: String?, weight: Long?): Any? {
|
||||
private fun callJmx_v2(method: String, type: String, metricName: String, value: Any, subprojectName: String?, weight: Long): Any? {
|
||||
return mbs.invoke(
|
||||
beanName,
|
||||
method,
|
||||
@@ -174,6 +182,24 @@ internal class JMXKotlinBuildStatsService(private val mbs: MBeanServer, private
|
||||
)
|
||||
}
|
||||
|
||||
private fun callJmx_v1(method: String, type: String, metricName: String, value: Any, subprojectName: String?): Any? {
|
||||
return mbs.invoke(
|
||||
beanName,
|
||||
method,
|
||||
arrayOf(metricName, value, subprojectName),
|
||||
arrayOf("java.lang.String", type, "java.lang.String")
|
||||
)
|
||||
}
|
||||
|
||||
//Temporary solution before KT-57371
|
||||
private fun callJmx(method: String, type: String, metricName: String, value: Any, subprojectName: String?, weight: Long?): Any? {
|
||||
return if (weight == null) {
|
||||
callJmx_v1(method, type, metricName, value, subprojectName)
|
||||
} else {
|
||||
callJmx_v2(method, type, metricName, value, subprojectName, weight)
|
||||
}
|
||||
}
|
||||
|
||||
override fun report(metric: BooleanMetrics, value: Boolean, subprojectName: String?, weight: Long?) =
|
||||
runSafe("report metric ${metric.name}") {
|
||||
callJmx("reportBoolean", "boolean", metric.name, value, subprojectName, weight)
|
||||
@@ -243,4 +269,16 @@ internal class DefaultKotlinBuildStatsService internal constructor(
|
||||
|
||||
override fun reportString(name: String, value: String, subprojectName: String?, weight: Long?): Boolean =
|
||||
report(StringMetrics.valueOf(name), value, subprojectName, weight)
|
||||
|
||||
override fun reportBoolean(name: String, value: Boolean, subprojectName: String?): Boolean =
|
||||
report(BooleanMetrics.valueOf(name), value, subprojectName, null)
|
||||
|
||||
|
||||
override fun reportNumber(name: String, value: Long, subprojectName: String?): Boolean =
|
||||
report(NumericalMetrics.valueOf(name), value, subprojectName, null)
|
||||
|
||||
|
||||
override fun reportString(name: String, value: String, subprojectName: String?): Boolean =
|
||||
report(StringMetrics.valueOf(name), value, subprojectName, null)
|
||||
|
||||
}
|
||||
|
||||
+15
@@ -50,6 +50,21 @@ class BuildStatServiceTest {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun reportBoolean(name: String, value: Boolean, subprojectName: String?): Boolean {
|
||||
callsCount.incrementAndGet()
|
||||
return true
|
||||
}
|
||||
|
||||
override fun reportNumber(name: String, value: Long, subprojectName: String?): Boolean {
|
||||
callsCount.incrementAndGet()
|
||||
return true
|
||||
}
|
||||
|
||||
override fun reportString(name: String, value: String, subprojectName: String?): Boolean {
|
||||
callsCount.incrementAndGet()
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
val beanName = ObjectName(KotlinBuildStatsService.JMX_BEAN_NAME)
|
||||
|
||||
Reference in New Issue
Block a user