2010-06-06 5 views
3

"연결 할당 오류"또는 "연결 종료"와 같은 오류가 발생할 때마다 연결 풀 모니터링 정보가 server.log에 제공되는 설정을 찾으려고합니다.JDBC 연결 풀 모니터링 GlassFish

내가 이것에 대해 이야기하는 일부 blog entries을 찾았지만 GUI 프레젠테이션에서 언급했습니다. 그러나 연결 풀 모니터링 설정 정보가 로그에 표시되도록 연결 풀 자체에 대한 설정이 필요합니다.

그런 설정을 아는 사람이 있습니까?

썬 응용 프로그램 서버 8.X에 그것은 perf-monitor

답변

2

이 당신을 도울 수 있다면 나도 몰라 될하는 데 사용 ....하지만 당신은 JMX를 통해 모니터링 정보를 연결 풀을 심문 할 수 있습니다. 이 코드 코드는 응용 프로그램 서버의 모든 연결 풀에 대해 max-pool-size 및 사용 된 연결 수를 인쇄합니다 (MBeans에서 가져올 수있는 더 많은 내용이로드됩니다).

MBeanServerConnection conn = getMbeanServerConnection(); 

    //search the jmx register for the specified beans 
    Set<ObjectInstance> connectorPoolSet = conn.queryMBeans(new ObjectName("*:type=jdbc-connection-pool,*"), null); 
    Map<String , ObjectName> configMap = new HashMap<String, ObjectName>(); 
    Map<String , ObjectName> monitorMap = new HashMap<String, ObjectName>(); 

    //get a map of each config & monitor object found for the search 
    for(ObjectInstance oi : connectorPoolSet) { 
     String name = oi.getObjectName().getKeyProperty("name"); 

     //if the category of the mbean is config - put it in the config map - else if it is monitor 
     //place it in the monitor map. 
     String category = oi.getObjectName().getKeyProperty("category"); 
     if("config".equalsIgnoreCase(category)) { 
      configMap.put(name, oi.getObjectName()); 
     } else if("monitor".equalsIgnoreCase(category)){ 
      monitorMap.put(name, oi.getObjectName()); 
     } 
    } 

    //iterate the pairs of config & monitor mbeans found 
    for(String name : configMap.keySet()) { 

     ObjectName configObjectName = configMap.get(name); 
     ObjectName monitorObjectName = monitorMap.get(name); 
     if(monitorObjectName == null) { 
      //no monitor found - throw an exception or something 
     } 

     int maxPoolSizeVal = getAttributeValue(conn, configObjectName, "max-pool-size"); 
     int connectionsInUse = getAttributeValue(conn, monitorObjectName, "numconnused-current"); 

     System.out.println(name + " -> max-pool-size : " + maxPoolSizeVal); 
     System.out.println(name + " -> connections in use : " + connectionsInUse); 


    }