[KYUUBI #6866][FOLLOWUP] Prevent register gauge conflicts if both thrift binary SSL and thrift http SSL enabled
### Why are the changes needed?
Followup for https://github.com/apache/kyuubi/pull/6866
It would throw exception if both thrift binary SSL and thrift http SSL enabled
### How was this patch tested?
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #6872 from turboFei/duplicate_gauge.
Closes #6866
ea356766e [Wang, Fei] prevent conflicts
982f175fd [Wang, Fei] conflicts
Authored-by: Wang, Fei <fwang12@ebay.com>
Signed-off-by: Wang, Fei <fwang12@ebay.com>
(cherry picked from commit 164df8d466)
Signed-off-by: Wang, Fei <fwang12@ebay.com>
This commit is contained in:
parent
66ee406021
commit
cc6702da6a
@ -58,6 +58,10 @@ class MetricsSystem extends CompositeService("MetricsSystem") {
|
||||
meter.mark(value)
|
||||
}
|
||||
|
||||
def getGauge[T](name: String): Option[Gauge[T]] = {
|
||||
Option(registry.gauge(name))
|
||||
}
|
||||
|
||||
def registerGauge[T](name: String, value: => T, default: T): Unit = {
|
||||
registry.register(
|
||||
MetricRegistry.name(name),
|
||||
|
||||
@ -56,13 +56,15 @@ object SSLUtils extends Logging {
|
||||
keyStorePath.get,
|
||||
keyStorePassword.get,
|
||||
keyStoreType).foreach { expiration =>
|
||||
info(s"Thrift SSL Serve KeyStore ${keyStorePath.get} will expire at:" +
|
||||
info(s"Thrift SSL Server KeyStore ${keyStorePath.get} will expire at:" +
|
||||
s" ${Utils.getDateFromTimestamp(expiration)}")
|
||||
MetricsSystem.tracing { ms =>
|
||||
ms.registerGauge(
|
||||
MetricsConstants.THRIFT_SSL_CERT_EXPIRATION,
|
||||
expiration - System.currentTimeMillis(),
|
||||
0L)
|
||||
if (ms.getGauge(MetricsConstants.THRIFT_SSL_CERT_EXPIRATION).isEmpty) {
|
||||
ms.registerGauge(
|
||||
MetricsConstants.THRIFT_SSL_CERT_EXPIRATION,
|
||||
expiration - System.currentTimeMillis(),
|
||||
0L)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user