偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

基于JMX監(jiān)控下的JBoss數(shù)據(jù)庫(kù)連接池

開發(fā) 前端
JMX(Java Management Extensions, Java管理擴(kuò)展)是一個(gè)為應(yīng)用程序植入管理功能的框架。JMX是一套標(biāo)準(zhǔn)的代理和服務(wù),實(shí)際上,用戶可以在任何Java應(yīng)用程序中使用這些代理和服務(wù)實(shí)現(xiàn)管理。

一、JMX簡(jiǎn)介

JMX(Java Management Extensions,Java管理擴(kuò)展)是一個(gè)為應(yīng)用程序植入管理功能的框架。JMX是一套標(biāo)準(zhǔn)的代理和服務(wù),實(shí)際上,用戶可以在任何Java應(yīng)用程序中使用這些代理和服務(wù)實(shí)現(xiàn)管理。

Jboss的成功就在于采用了JMX,從零開始、模塊化開發(fā)了Jboss服務(wù)器和容器,實(shí)現(xiàn)了模塊化、嵌入式的技術(shù)架構(gòu)。JMX作為集成中心(總線),可以很方便的熱插拔新的模塊和組件。JMX服務(wù)可以通過HTTP、RMI、SNMP等多種協(xié)議進(jìn)行訪問,使其適合作為一個(gè)網(wǎng)絡(luò)管理、監(jiān)控平臺(tái)的技術(shù)架構(gòu)。

二、JMX構(gòu)架中的各層及相關(guān)的組件

1.工具層(Instrumentation Level)

(a)MBeans(標(biāo)準(zhǔn)的,動(dòng)態(tài)的,開放的和模型MBeans)

(b)通知模型:Notification、NotificationListener等類

(c)MBean元數(shù)據(jù)類:Attribute、Opreator等類

2.代理層(Agent Level)

(a)MBean Server

(b)代理服務(wù)。如jboss jmx-console下的HtmlAdaptorServer等。

MBean:是Managed Bean的簡(jiǎn)稱。在JMX中MBean代表一個(gè)被管理的資源實(shí)例,通過MBean中暴露的方法和屬性,外界可以獲取被管理的資源的狀態(tài)和操縱MBean的行為。事實(shí)上,MBean就是一個(gè)Java Object,同JavaBean模型一樣,外界使用自醒和反射來獲取Object的值和調(diào)用Object的方法,只是MBean更為復(fù)雜和高級(jí)一些。

MBeanServer:MBean生存在一個(gè)MBeanServer中。MBeanServer管理這些MBean,并且代理外界對(duì)它們的訪問。并且MBeanServer提供了一種注冊(cè)機(jī)制,是的外界可以通過名字來得到相應(yīng)的MBean實(shí)例。

JMX Agent:Agent只是一個(gè)Java進(jìn)程,它包括這個(gè)MBeanServer和一系列附加的MbeanService。當(dāng)然這些Service也是通過MBean的形式來發(fā)布。

Protocol Adapters and Connectors

JMX Agent通過各種各樣的Adapter和Connector來與外界(JVM之外)進(jìn)行通信。同樣外界(JVM之外)也必須通過某個(gè)Adapter和Connector來向JMX Agent發(fā)送管理或控制請(qǐng)求。

Adapter和Connector的區(qū)別在于:Adapter是使用某種Internet協(xié)議來與JMX Agent獲得聯(lián)系,Agent端會(huì)有一個(gè)對(duì)象(Adapter)來處理有關(guān)協(xié)議的細(xì)節(jié)。比如SNMP Adapter和HTTP Adapter。而Connector則是使用類似RPC的方式來訪問Agent,在Agent端和客戶端都必須有這樣一個(gè)對(duì)象來處理相應(yīng)的請(qǐng)求與應(yīng)答。比如RMI Connector。

JMX Agent可以帶有任意多個(gè)Adapter,因此可以使用多種不同的方式訪問Agent。#p#

三、監(jiān)控jboss數(shù)據(jù)庫(kù)連接池的實(shí)現(xiàn)

TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=400 align=center borderColorLight=#999999 border=1>
import java.util.Iterator; 
 
import java.util.Properties;

import java.util.Set;

import javax.management.MBeanInfo;

import javax.management.MBeanOperationInfo;

import javax.management.MBeanParameterInfo;

import javax.management.ObjectInstance;

import javax.management.ObjectName;

import javax.naming.InitialContext;

import org.jboss.jmx.adaptor.rmi.RMIAdaptor;

public class DataSourceManger {

public static void main(String[] args) {

// TODO 自動(dòng)生成方法存根

try {

// Get RMIAdaptor Object

Properties pro = new Properties();

pro.setProperty("java.naming.factory.initial",

"org.jnp.interfaces.NamingContextFactory");

pro.setProperty("java.naming.provider.url", "jnp://localhost:1099");

pro.setProperty("java.naming.factory.url.pkgs",

"org.jboss.naming:org.jnp.interfaces");

InitialContext ic = new InitialContext(pro);

RMIAdaptor server = (RMIAdaptor) ic.lookup("jmx/rmi/RMIAdaptor");

ObjectName name = new ObjectName(

"jboss.jca:name=jdbc/baosigpo,service=ManagedConnectionPool");

ObjectName lname = new ObjectName(

"jboss.jca:name=jdbc/baosigpo,service=LocalTxCM");

String AvailableConnectionCount = server.getAttribute(name,

"AvailableConnectionCount").toString();

System.out.println("===========avlide============"

+ AvailableConnectionCount);

String InUseConnectionCount = server.getAttribute(name,

"InUseConnectionCount").toString();

System.out.println("===========InUseConnectionCount============"

+ InUseConnectionCount);

String ConnectionCreatedCount = server.getAttribute(name,

"ConnectionCreatedCount").toString();

System.out.println("===========ConnectionCreatedCount============"

+ ConnectionCreatedCount);

String ConnectionDestroyedCount = server.getAttribute(name,

"ConnectionDestroyedCount").toString();

System.out

.println("===========ConnectionDestroyedCount============"

+ ConnectionDestroyedCount);

ConnectionDestroyedCount = server.getAttribute(name,

"ConnectionDestroyedCount").toString();

System.out

.println("===========ConnectionDestroyedCount============"

+ ConnectionDestroyedCount);

String[] argTypes = new String[0];

int i=0;

i=Integer.parseInt(AvailableConnectionCount);

Object opReturn=null;

if(i<1) {//監(jiān)控可用連接數(shù)。

StringBuffer sb=new StringBuffer();

sb.append("oper before DataSource Pool info : \r\n");

sb.append("AvailableConnectionCount="

+ AvailableConnectionCount);

sb.append("InUseConnectionCount="+InUseConnectionCount);

sb.append("ConnectionCreatedCount="

+ ConnectionCreatedCount);

sb.append("ConnectionDestroyedCount="

+ ConnectionDestroyedCount);

sb.append("\r\n");

//opReturn=server.invoke(name,"flush",argTypes,argTypes);

/*調(diào)用mbean的方法釋放連接 begin 本實(shí)現(xiàn)方法對(duì)應(yīng)jboss3.2.3

對(duì)于jboss4以后的版本只需調(diào)用

//opReturn=server.invoke(name,"flush",argTypes,argTypes);

**/

opReturn=server.invoke(name,"stop",argTypes,argTypes);

opReturn=server.invoke(name,"start",argTypes,argTypes);

opReturn=server.invoke(lname,"stop",argTypes,argTypes);

opReturn=server.invoke(lname,"start",argTypes,argTypes);

/*調(diào)用mbean的方法釋放連接 end **/

AvailableConnectionCount=server.getAttribute(name,

"AvailableConnectionCount").toString();

InUseConnectionCount=server.getAttribute(name,

"InUseConnectionCount").toString();

ConnectionCreatedCount=server.getAttribute(name,

"ConnectionCreatedCount").toString();

ConnectionDestroyedCount =server.getAttribute(name,

"ConnectionDestroyedCount").toString();

ConnectionDestroyedCount=server.getAttribute(name,

"ConnectionDestroyedCount").toString();

sb.append("oper afer DataSource Pool info :\r\n");

sb.append("AvailableConnectionCount="

+ AvailableConnectionCount);

sb.append("InUseConnectionCount="+InUseConnectionCount);

sb.append("ConnectionCreatedCount="

+ ConnectionCreatedCount);

sb.append("ConnectionDestroyedCount="

+ ConnectionDestroyedCount);

//writeLog(sb.toString()); 操作日志信息

System.out.println("===========op SUCCESS============");

}

}catch(Exception ex){

ex.printStackTrace();

}

}

}

【編輯推薦】

  1. JBoss應(yīng)用服務(wù)器5.0正式發(fā)布
  2. JBoss Web和Tomcat的區(qū)別
  3. JBoss推出Developer Studio 1.0和Tools 2.0
責(zé)任編輯:田超 來源: IT專家網(wǎng)論壇
相關(guān)推薦

2009-06-16 09:25:31

JBoss配置

2009-06-24 07:53:47

Hibernate數(shù)據(jù)

2010-03-18 15:09:15

python數(shù)據(jù)庫(kù)連接

2019-11-27 10:31:51

數(shù)據(jù)庫(kù)連接池內(nèi)存

2018-10-10 14:27:34

數(shù)據(jù)庫(kù)連接池MySQL

2017-06-22 14:13:07

PythonMySQLpymysqlpool

2011-05-19 09:53:33

數(shù)據(jù)庫(kù)連接池

2018-01-03 14:32:32

2009-07-17 13:32:49

JDBC數(shù)據(jù)庫(kù)

2021-08-12 06:52:01

.NET數(shù)據(jù)庫(kù)連接池

2020-04-30 14:38:51

數(shù)據(jù)庫(kù)連接池線程

2011-08-09 15:25:14

線程池數(shù)據(jù)庫(kù)連接池

2009-06-16 11:11:25

JBoss目錄數(shù)據(jù)庫(kù)連接

2009-07-03 17:37:54

JSP數(shù)據(jù)庫(kù)

2011-07-29 15:11:42

WeblogicOracle數(shù)據(jù)庫(kù)連接

2010-03-18 14:55:17

Python數(shù)據(jù)庫(kù)連接

2009-07-29 09:33:14

ASP.NET數(shù)據(jù)庫(kù)連

2025-01-16 10:30:49

2025-02-07 12:11:52

2009-06-15 13:56:02

linux下安裝JBo
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)