@ -17,12 +17,7 @@
package org.apache.dolphinscheduler.dao.utils ;
package org.apache.dolphinscheduler.dao.utils ;
import org.apache.dolphinscheduler.common.enums.DbType ;
import static org.apache.dolphinscheduler.dao.MonitorDBDao.VARIABLE_NAME ;
import org.apache.dolphinscheduler.common.enums.Flag ;
import org.apache.dolphinscheduler.dao.MonitorDBDao ;
import org.apache.dolphinscheduler.dao.entity.MonitorRecord ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
import java.sql.Connection ;
import java.sql.Connection ;
import java.sql.ResultSet ;
import java.sql.ResultSet ;
@ -30,7 +25,12 @@ import java.sql.SQLException;
import java.sql.Statement ;
import java.sql.Statement ;
import java.util.Date ;
import java.util.Date ;
import static org.apache.dolphinscheduler.dao.MonitorDBDao.VARIABLE_NAME ;
import org.apache.dolphinscheduler.common.enums.DbType ;
import org.apache.dolphinscheduler.common.enums.Flag ;
import org.apache.dolphinscheduler.dao.MonitorDBDao ;
import org.apache.dolphinscheduler.dao.entity.MonitorRecord ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
/ * *
/ * *
* mysql performance
* mysql performance
@ -55,26 +55,28 @@ public class MysqlPerformance extends BaseDBPerformance{
try {
try {
pstmt = conn . createStatement ( ) ;
pstmt = conn . createStatement ( ) ;
ResultSet rs1 = pstmt . executeQuery ( "show global variables" ) ;
try ( ResultSet rs1 = pstmt . executeQuery ( "show global variables" ) ) {
while ( rs1 . next ( ) ) {
while ( rs1 . next ( ) ) {
if ( rs1 . getString ( VARIABLE_NAME ) . toUpperCase ( ) . equals ( "MAX_CONNECTIONS" ) ) {
if ( rs1 . getString ( VARIABLE_NAME ) . equalsIgnoreCase ( "MAX_CONNECTIONS" ) ) {
monitorRecord . setMaxConnections ( Long . parseLong ( rs1 . getString ( "value" ) ) ) ;
monitorRecord . setMaxConnections ( Long . parseLong ( rs1 . getString ( "value" ) ) ) ;
}
}
}
}
}
ResultSet rs2 = pstmt . executeQuery ( "show global status" ) ;
try ( ResultSet rs2 = pstmt . executeQuery ( "show global status" ) ) {
while ( rs2 . next ( ) ) {
while ( rs2 . next ( ) ) {
if ( rs2 . getString ( VARIABLE_NAME ) . toUpperCase ( ) . equals ( "MAX_USED_CONNECTIONS" ) ) {
if ( rs2 . getString ( VARIABLE_NAME ) . equalsIgnoreCase ( "MAX_USED_CONNECTIONS" ) ) {
monitorRecord . setMaxUsedConnections ( Long . parseLong ( rs2 . getString ( "value" ) ) ) ;
monitorRecord . setMaxUsedConnections ( Long . parseLong ( rs2 . getString ( "value" ) ) ) ;
} else if ( rs2 . getString ( VARIABLE_NAME ) . toUpperCase ( ) . equals ( "THREADS_CONNECTED" ) ) {
} else if ( rs2 . getString ( VARIABLE_NAME ) . equalsIgnoreCase ( "THREADS_CONNECTED" ) ) {
monitorRecord . setThreadsConnections ( Long . parseLong ( rs2 . getString ( "value" ) ) ) ;
monitorRecord . setThreadsConnections ( Long . parseLong ( rs2 . getString ( "value" ) ) ) ;
} else if ( rs2 . getString ( VARIABLE_NAME ) . toUpperCase ( ) . equals ( "THREADS_RUNNING" ) ) {
} else if ( rs2 . getString ( VARIABLE_NAME ) . equalsIgnoreCase ( "THREADS_RUNNING" ) ) {
monitorRecord . setThreadsRunningConnections ( Long . parseLong ( rs2 . getString ( "value" ) ) ) ;
monitorRecord . setThreadsRunningConnections ( Long . parseLong ( rs2 . getString ( "value" ) ) ) ;
}
}
}
}
}
} catch ( Exception e ) {
} catch ( Exception e ) {
monitorRecord . setState ( Flag . NO ) ;
monitorRecord . setState ( Flag . NO ) ;
logger . error ( "SQLException " + e ) ;
logger . error ( "SQLException " , e ) ;
} finally {
} finally {
try {
try {
if ( pstmt ! = null ) {
if ( pstmt ! = null ) {