com.azure.cosmos.spark.diagnostics.DiagnosticsLoader.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-cosmos-spark_3-5_2-12 Show documentation
Show all versions of azure-cosmos-spark_3-5_2-12 Show documentation
OLTP Spark 3.5 Connector for Azure Cosmos DB SQL API
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.cosmos.spark.diagnostics
import com.azure.cosmos.spark.DiagnosticsConfig
import scala.collection.concurrent.TrieMap
private[spark] object DiagnosticsLoader {
private val defaultDiagnostics = new DefaultDiagnostics
private val providers = TrieMap[String, DiagnosticsProvider]()
providers.put(classOf[SimpleDiagnosticsProvider].getName, new SimpleDiagnosticsProvider)
providers.put(classOf[FeedDiagnosticsProvider].getName, new FeedDiagnosticsProvider)
providers.put(classOf[DetailedFeedDiagnosticsProvider].getName, new DetailedFeedDiagnosticsProvider)
def getDiagnosticsProvider(cfg: DiagnosticsConfig): DiagnosticsProvider = {
cfg.mode match {
case Some(value) =>
getDiagnosticsProvider(value)
case None =>
defaultDiagnostics
}
}
private def getDiagnosticsProvider(diagnosticsProviderName: String): DiagnosticsProvider = {
providers.get(diagnosticsProviderName) match {
case Some(provider) =>
provider
case None =>
this.synchronized {
providers.get(diagnosticsProviderName) match {
case Some(provider) =>
provider
case None =>
val provider: DiagnosticsProvider =
Class.forName(diagnosticsProviderName).asSubclass(classOf[DiagnosticsProvider]).getDeclaredConstructor().newInstance()
providers.put(diagnosticsProviderName, provider)
provider
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy