- 浏览: 236128 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
akka_li:
学习了!但是为什么后续的没有了?!
EJB4:RMI和RMI-IIOP -
springaop_springmvc:
apache lucene开源框架demo使用实例教程源代码下 ...
Lucene学习笔记(一)Lucene入门实例 -
qepipnu:
求solr 客户端 jar包
Solr学习笔记(三)Solr客户端开发实例 -
zhangbc:
是这问题,赞!
Oracle Start Up 2 Oracle 框架构件、启动、解决一个问题 -
feilian09:
查询 select hibernate jdbc 那个效率快
Hibernate,JDBC性能探讨
JMX Architecture Overview:
JMX technology provides a standard API for management and monitoring of resources. As http://kylinsoong.iteye.com/admin/blogs/794995 Part 3 depicted, the JMX architecture can be broken down into three levels: Instrumentation, Agent, Remote Management, As the following figure described:
Instrumentation Layer contains MBeans representing their manageable resources, such as applications, devices, or services, are instrumented using Java objects called Managed Beans (MBeans). MBeans expose their management interfaces, composed of attributes and operations, through a JMX agent for remote management and monitoring;
Agent Layer is the main component of a JMX agent is the MBean server. This is a core managed object server in which MBeans are registered. A JMX agent also includes a set of services for handling MBeans. JMX agents directly control resources and make them available to remote management agents;
Distributed Layer also named Remote Management layer, contain adapters and connectors make a JMX agent accessible from remote management applications outside the agent’s Java Virtual Machine (Java VM).
HelloWorld JMX way
1. Complete Instrumentation layer dev
The first step in developing the HelloWorld MBean is to write its Java interface. The interface declares three methods: one getter, one setter, and an additional method for printing the HelloWorld MBean’s greeting. Code view:
public interface HelloWorldMBean { public void setGreeting( String greeting ); public String getGreeting(); public void printGreeting(); }
Before we start HelloWroldMBean implemetation, we introduce JMX notification first, notification is the most imprtant feature of JMX, any managment system need notification mechanism, to add notification to our Helloworld mbean we need to extends the avax.management.NotificationBroadcasterSupport. Our MBean class:
public class HelloWorld extends NotificationBroadcasterSupport implements HelloWorldMBean { private String greeting = null; public HelloWorld() { this.greeting = "Hello World! I am a Standard MBean"; } public HelloWorld(String greeting) { this.greeting = greeting; } public void setGreeting(String greeting) { this.greeting = greeting; Notification notification = new Notification("jmx.demo.helloWorld.test" , this , -1 , System.currentTimeMillis() , greeting ); sendNotification(notification); } public String getGreeting() { return greeting; } public void printGreeting() { System.out.println(greeting); } }
2 Complete Agent Code
As step 1, we have our HelloWorldMbean, we need to make it available to use, to do so we must register it in a JMX Agent. Therefore we create HelloAgent class JMX agents are JMX components in the agent layer of JMX and are the containers for MBeans. The HelloAgent class performs 4 important tasks:
1> It creates an MBeanServer instance to contain MBeans.
2> It creates an HTML adapter to handle connections from HTML clients.
3> It registers a new instance of the HelloWorld MBean.
4> It handles the notification that HelloWorldMBean sent.
public class HelloAgent implements NotificationListener { private MBeanServer mbs = null; public HelloAgent() { // mbs = MBeanServerFactory.createMBeanServer("jmx.demo.HelloAgent"); mbs = ManagementFactory.getPlatformMBeanServer(); HtmlAdaptorServer adapter = new HtmlAdaptorServer(); HelloWorld hw = new HelloWorld(); ObjectName adapterName = null; ObjectName helloWorldName = null; try { helloWorldName = new ObjectName( "jmx.demo.HelloAgent:type=helloWorld,name=helloWorld" ); mbs.registerMBean( hw, helloWorldName ); hw.addNotificationListener(this, null, null); adapterName = new ObjectName("jmx.demo.HelloAgent:type=htmlAdapter,name=htmlAdapter,port=8000"); adapter.setPort(8000); mbs.registerMBean( adapter, adapterName ); adapter.start(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String args[]) throws InterruptedException { System.out.println("HelloAgent is running"); HelloAgent agent = new HelloAgent(); Thread.sleep(Long.MAX_VALUE); } public void handleNotification(Notification notification, Object handback) { System.out.println( "Receiving notification..." ); System.out.println( notification.getType() ); System.out.println( notification.getMessage() ); } }
3. Compete Distibuted layer Code
In this simple HelloWorld example we only Use HTML adapter to implement remote management, however, RMI connector implement remote management is more popular, I will explore into it in the later blogs. In this blog we will show Html adapter implement remote management in Test section.
HelloWorld Test
After starting the main method, we can through 2 methods test and manage HelloWrold
Method one:
Start a new command line, input 'jconsole' the following widget came out:
Clicking HelloAgent then you will get into Jconsole control interface and find both HelloWorld and htmlAdapter selection folder bar in the left menu tree:
Clicking reference method or change the attributes, the corresponding action will take place.
Method two:
Through http://127.0.0.1:8000/ we could find jmx.demo.HelloAgent from All Agent View List
Cliking helloWord we also can find the operation and attributes, through HTML interface we also can triger the response notification event.
评论
This cannot be accessed by other users.
try use this:http://kylinsoong.iteye.com/blog/794995
This cannot be accessed by other users.
发表评论
-
Java Nio Usage Demo & A example of use selectableChannel
2011-12-06 21:42 3616Primary purpose of this blog is ... -
JDK Source Code & java.nio
2011-11-10 23:26 2318java.nio is very useful and a p ... -
Oracle - Add Exist Validation Before Create Table
2011-11-07 13:49 1404Usually we need to check the ta ... -
JDK Source Code & java.rmi.server.RMISocketFactory
2011-10-31 23:14 2112Today's Source code analysing s ... -
Thinking in JDBC
2011-09-22 20:56 1817This blog will beas on a series ... -
Jboss-eap-5.1 Messaging
2011-08-02 21:50 2400This section I will concertate ... -
Jboss-eap-5.1 starting up note
2011-07-26 22:46 2543Jboss enterprise platform 5 hav ... -
EJB Security & JAAS Demo
2011-05-21 19:39 1575PROLOGUE: When deploying ... -
JBoss LoginInitialContext Factory Implementation
2011-05-15 16:05 1466Jboss has a series of imp ... -
Jboss Reference Exception Gallery
2011-04-27 14:08 28491. Unable to locate a login con ... -
Hibernate Annotation 的一个问题,给点意见
2011-03-10 12:43 22问题:org.hibernate.annotations. ... -
大家说说BBC的网站用的是什么技术做的
2011-02-22 05:01 1394最近在英国出差,发现这里的一些网站做的相当有特色,有些网站不是 ... -
Hibernate OneToMany 单向和双向配置对数据存取性能的比较
2011-02-08 17:06 22421. 开篇说明:今天是春 ... -
对Hibernate属性(CascadeType、JoinColumn、JoinTable、ForeignKey等)的研究
2010-12-26 15:45 16604本文列出几个“EJB 学习阶段总结:JBoss下发布一个Toy ... -
EJB 学习阶段总结:JBoss下发布一个Toy企业应用
2010-12-25 12:11 2548解释题目:为什 ... -
EJB7: Message Driven Bean
2010-12-21 22:42 2098在企业系统中需要使用 ... -
EJB6: EntityBean例子
2010-11-26 14:48 1441本例子描述向EJB容器(JBoss)部署http: ... -
JPA dev: 几个问题总结(续)
2010-11-25 18:02 24042. 如何由PoJo类生成数据库中的表 首先可以根据实体间关 ... -
JPA dev: 几个问题总结
2010-11-25 16:56 3350最近工作中遇到几个与JPA相关的问题,本文通过一个例子总结一下 ... -
JAXB学习
2010-11-24 22:35 01 什么是JAXB? JAXB全称Java Ar ...
相关推荐
NULL 博文链接:https://hintcnuie.iteye.com/blog/255815
此资源是用于开发人员或者测试人员在使用java mission control时,需要放置在Tomcat中的文件
JMX实战 书中不仅有对于基础知识的介绍,还有对于JMX开发中重大的体系架构问题的深入探讨,总结了大量JMX开发中的设计模式,并讨论了框架、安全性与性能等等。书中提供了几个典型的例子,兼顾各种开发平台,这些...
jmx快速上手 jmx快速上手 jmx快速上手 jmx快速上手
Description Resource Path Location Type Missing artifact com.sun.jmx:jmxri:jar:1.2.1 pom.xml /eshop-storm line 2 Maven Dependency Problem
Fiddler导出jmx文件,解决Fiddler导出文件中 没有jmx文件选项,各个版本fiddler都适用
为什么JMX那么受欢迎,JMX到底有那些优势只得人们去学习和理解,本文从JMX的基本架构、hellowold jmx以及spring对JMX的支持讲起,希望大家能通过本文对JMX有个基础的认识,并能通过本文为今后学习JMX打个基础
catalina-jmx-remote.jar放到tomcat/lib目录下 如果是windows版本,编辑TOMCAT_HOME/bin/catalina.bat,在开头加入下面几行: set CATALINA_OPTS=%CATALINA_OPTS% -Djava.rmi.server.hostname=JMX_HOST set CATALINA...
Hbase和Hadoop JMX监控实战
JMX小例子以及介绍 JMX小例子以及介绍 JMX小例子以及介绍
JMX与JMS的概念
jmx配置
activeMQ开启jmx固定rmi端口,穿透防火墙,用了一天的时间,踩了无数的坑,拿出来共享.
JBoss JMX实现架构 JBoss JMX实现架构
JMX一步一步来,从最基本的应用开始入手,快速应用开发。
java项目,自己做的项目利用jmx监控weblogic,tomcat,websphere源码
jmx的简单介绍和使用,包含一些简单的代码示例,看完基本能了解jmx并使用。
java实现Jmx实例,jmxdemo项目源码下载
Zabbix通过JMX方式监控java中间件 Zabbix2.0添加了支持用于监控JMX应用程序的服务进程,称为“Zabbix-Java-gateway”;它是用java写的一个程序。 工作原理: zabbix_server想知道一台主机上的特定的JMX值时,它向...