Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2021 10:09 AM
We are using an internal metastore implementation. ie the metastore is hosted at the Dataricks side. However, we believe the metastore instance made available for my workspace is not adequate enough to handle the load. How can I monitor the number of connections made from the clusters to the Hive metatore.
Labels:
- Labels:
-
Connections
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2021 10:10 AM
Use the below code snippet from a notebook
%scala
import java.sql.Connection
import java.sql.DriverManager
import java.sql.ResultSet
import java.sql.SQLException
/**
* For details on what this query means, checkout https://dev.mysql.com/doc/refman/8.0/en/processlist-table.html
**/
def printConnections: Unit = {
val metastoreURL = spark.sparkContext.hadoopConfiguration.get("javax.jdo.option.ConnectionURL")
val metastoreUser = spark.sparkContext.hadoopConfiguration.get("javax.jdo.option.ConnectionUserName")
val metastorePassword = spark.sparkContext.hadoopConfiguration.get("javax.jdo.option.ConnectionPassword")
val connection = DriverManager.getConnection(metastoreURL, metastoreUser, metastorePassword)
val statement = connection.createStatement()
val resultSet = statement.executeQuery("SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY Host")
val rsmd = resultSet.getMetaData();
val columnsNumber = rsmd.getColumnCount();
(1 to columnsNumber).foreach { i =>
print(rsmd.getColumnName(i) + "\t\t\t\t\t\t\t")
}
println();
while (resultSet.next()) {
var cumulativeLength = 0
(1 to columnsNumber).foreach { i =>
val data = if (resultSet.getString(i) != null) resultSet.getString(i).trim() else ""
print(data + "\t\t\t\t\t\t");
}
println();
}
statement.close
connection.close
}
printConnections