CS5233 Components Models and Engineering

Similar documents
Meeting #47. JMX Java Management Extensions. Dominik Dorn Dominik Dorn - JMX

Chapter 1. JOnAS and JMX, registering and manipulating MBeans

Manage and Monitor your JVM with JMX

Oracle WebLogic Server

Java Management Extensions Instrumentation and Agent Specification, v1.0

Moving beyond hardware

JMX Java Management extension

OSGi Service Platform in Integrated Management Environments Telefonica I+D, DIT-UPM, Telvent. copyright 2004 by OSGi Alliance All rights reserved.

Java Mission Control

Brekeke PBX Web Service

Module 13 Implementing Java EE Web Services with JAX-WS

Oracle Java SE and Oracle Java Embedded Products

Manual. Programmer's Guide for Java API

Network Communication

Getting Started with the Internet Communications Engine

Networks and Services

ADF Code Corner. 92. Caching ADF Web Service results for in-memory filtering. Abstract: twitter.com/adfcodecorner

IBM WebSphere Application Server

A technical guide for monitoring Adobe LiveCycle ES deployments

CS506 Web Design and Development Solved Online Quiz No. 01

An Oracle White Paper Sep Embedding Oracle WebLogic Server

Configuring and Integrating JMX

Overview of Web Services API

Crash Course in Java

Web Services API Developer Guide

Java Memory Model: Content

Stock Trader System. Architecture Description

Monitoring Tomcat with JMX

CHAPTER 1 - JAVA EE OVERVIEW FOR ADMINISTRATORS

Exception Handling In Web Development DevelopIntelligence LLC

Java Troubleshooting and Performance

<Insert Picture Here> Java EE 7: the New Cloud Platform

CS 111 Classes I 1. Software Organization View to this point:

Enterprise Application Management with Spring

A SERVICE ORIENTED ARCHITECTURE FOR DATA-DRIVEN DECISION SUPPORT SYSTEMS. Ian James Cottingham A THESIS. Presented to the Faculty of

OSGi Remote Management

Creating a Simple, Multithreaded Chat System with Java

Tomcat 5 New Features

Zebra and MapReduce. Table of contents. 1 Overview Hadoop MapReduce APIs Zebra MapReduce APIs Zebra MapReduce Examples...

Introduction to Sun ONE Application Server 7

Extending Desktop Applications to the Web

Oracle WebLogic Server 11g Administration

Configurable JMX-based Monitoring Tool for JBoss on top of Eclipse Rich Client Platform

<Insert Picture Here> Java EE 7: the New Cloud Platform

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. Oct 2003 Presented to Gordon College CS 311

Data Flow Static Code Analysis Best Practices

Intruduction to Groovy & Grails programming languages beyond Java

Introduction to Object-Oriented Programming

Using jvmstat and visualgc to Solve Memory Management Problems

jmonitor: Java Runtime Event Specification and Monitoring Library

Consuming a Web Service(SOAP and RESTful) in Java. Cheat Sheet For Consuming Services in Java

Remote Method Invocation in JAVA

ITDUMPS QUESTION & ANSWER. Accurate study guides, High passing rate! IT dumps provides update free of charge in one year!

Built-in Concurrency Primitives in Java Programming Language. by Yourii Martiak and Mahir Atmis

How To Run A Test File Extension On A Rexx (Unix) On A Microsoft Linux (Amd64) (Orchestra) (For Windows) (

Running and Testing Java EE Applications in Embedded Mode with JupEEter Framework

GlassFish v3. Building an ex tensible modular Java EE application server. Jerome Dochez and Ludovic Champenois Sun Microsystems, Inc.

CSE 308. Coding Conventions. Reference

STM32JAVA. Embedded Java Solutions for STM32

Amazon Glacier. Developer Guide API Version

Chapter 8 Implementing FSP Models in Java

e ag u g an L g ter lvin v E ram Neal G g ro va P Ja

Open Message Queue. Developer's Guide for JMX Clients Release 5.0

Division of Informatics, University of Edinburgh

LDAPCON Sébastien Bahloul

Network/Socket Programming in Java. Rajkumar Buyya

Welcome to the JReport Server Monitor User's Guide

Oracle Application Server 10g Web Services Frequently Asked Questions Oct, 2006

Advanced Java Client API

WebSphere Server Administration Course

IBM WebSphere Server Administration

JBS-102: Jboss Application Server Administration. Course Length: 4 days

.OR.AT.ATTORNEY.AUCTION.BARGAINS.BAYERN.BERLIN.BLACKFRIDAY.BOUTIQUE.BRUSSELS.BUILDERS

FUSE-ESB4 An open-source OSGi based platform for EAI and SOA

Hacking (and securing) JBoss AS

Oracle JRockit Mission Control Overview

Elements of Advanced Java Programming

JAVA Program For Processing SMS Messages

An Android-based Instant Message Application

CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus

Course Description. Course Audience. Course Outline. Course Page - Page 1 of 5

ELIXIR LOAD BALANCER 2

JAVA - EXCEPTIONS. An exception can occur for many different reasons, below given are some scenarios where exception occurs.

Java Management Extensions (JMX) and IBM FileNet System Monitor

Java Application Developer Certificate Program Competencies

CS3600 SYSTEMS AND NETWORKS

A FRAMEWORK FOR MANAGING RUNTIME ENVIRONMENT OF JAVA APPLICATIONS

Oracle WebLogic Foundation of Oracle Fusion Middleware. Lawrence Manickam Toyork Systems Inc

When the transport layer tries to establish a connection with the server, it is blocked by the firewall. When this happens, the RMI transport layer

Apache Jakarta Tomcat

Project SailFin: Building and Hosting Your Own Communication Server.

WEBLOGIC ADMINISTRATION

No no-argument constructor. No default constructor found

AVRO - SERIALIZATION

Transcription:

Prof. Dr. Th. Letschert CS5233 Components Models and Engineering - Komponententechnologien Master of Science (Informatik) Java Management Extensions: JMX Seite 1

JMX http://download.oracle.com/javase/tutorial/jmx/index.html JMX Java Management Extensions API for management and monitoring of applications, services,... and JVM Provides standard interface between a resources and its manager Usage: view or change configuration observe behavior notify of state changes JMX usually is supported by application servers or servlet containers Relevant Specifications JSR 3, Java Management Extensions (JMX) Specification, version 1.4 JSR 160, JMX Remote API JSR 255, Java Management Extensions (JMX) Specification, version 2.0 Status Package javax.management Introduced in Java 5 Considerable extension in Java 6 (based on JSR 3 / version 1.4) No modification in Java 7 JSR 255 postponed to Java 8 Seite 2

JMX / MBean MBeans and Manageable Resources Manageable Resource entity hardware or software (JVM, servlet, EJB, ) that is managed MBean represents a manageable resource provides management interface for the resource often is identified with the managed resource may be the managed resource itself if the managed resource is a Java object or a wrapper around legacy code or a proxy or... Seite 3

JMX / Standard MBean Standard MBean there are several types of MBeans, the simplest is the standard MBean XyClassMBean Standard MBean implements its own custom MBean interface <<implements>> MBean interface XyClass must have a name that ends in MBean must have a signature that exposes attributes and operations to the management application MBean immplementation must have a name that equals the interface's name without Mbean must implement operational code management code according to the interface the other kinds of MBeans are: MXBeans Dynamic MBeans Model MBeans Open MBeans Seite 4

JMX / Standard MBean Example: A manageable bounded Stack public class BoundedStack implements BoundedStackMBean { int length = 10; int top = -1; private int[] a = new int[length]; public interface BoundedStackMBean { public void push(int x) { a[++top] = x; public int pop() { return a[(top--)]; public void reset() { a = new int[length]; top = -1; void reset(); int getlength(); void resize(int length); List<Integer> getstate(); public int getlength() { return length; public void resize(int length) { this.length = length; this.top = -1; this.a = new int[length]; Management operations public List<Integer> getstate() { List<Integer> res = new ArrayList<Integer>(top+1); for (int i=0; i<=top; i++) { res.add(a[i]); return res; Seite 5

JMX / Agent JMX Agent An JMX agent manages one or more resources It connects resources to a management application An agent consists of MBean server (one) MBeans as resources (one or more) Connector or Protocol Adapter (one or more) WebBrowser HTTP resource (MBean) Protocol Adapter MBean Server Connector resource (MBean) Agent Seite 6 some JMX Protocol JMX compliant MgmtApp

JMX / Agent resource (MBean) JMX Agent example (1) MBean Server java.lang.management.managementfactory; javax.management.instancealreadyexistsexception; javax.management.mbeanregistrationexception; javax.management.mbeanserver; javax.management.malformedobjectnameexception; javax.management.notcompliantmbeanexception; javax.management.objectname; Protocol Adapter resource (MBean) Connector Agent public class StacksAgent { public static void main(string[] args) throws MalformedObjectNameException, NullPointerException, InstanceAlreadyExistsException, MbeanRegistrationException, NotCompliantMBeanException, InterruptedException { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer (); ObjectName name1 = new ObjectName("de.thmh.mni.stack1:type=BoundedStack,name=stack1"); ObjectName name2 = new ObjectName("de.thmh.mni.stack2:type=BoundedStack,name=stack2"); BoundedStack stackmbean1 = new BoundedStack(); BoundedStack stackmbean2 = new BoundedStack(); while(true) { Thread.sleep(1000); Thread.sleep(1000); Thread.sleep(1000); Thread.sleep(1000); Thread.sleep(1000); Thread.sleep(1000); Thread.sleep(1000); Thread.sleep(1000); mbs.registermbean(stackmbean1, name1); mbs.registermbean(stackmbean2, name2); Seite 7 stackmbean1.push(1); stackmbean2.push(2); stackmbean1.push(3); stackmbean2.push(4); stackmbean2.pop(); stackmbean1.pop(); stackmbean2.pop(); stackmbean1.pop();

JMX / Agent resource (MBean) MBean Server JMX Agent example (2) resource (MBean) jconsole: command line management application connects to the agent (on local machine) Protocol Adapter Connector Agent JMX compliant Mgmt-App <jdk-7>/bin/jconsole Seite 8

JMX / Dynamic MBean Dynamic MBean Dynamic and static MBeans publish their interfaces. Whereas for static MBeans this is done automatically (JMX libraries do it using refection), for dynamic MBeans you have to code the publishing. Dynamic MBeans are used if manage resources with interfaces not known in advance and have to be determined at run-time must implement javax.management.dynamicmbean operational code management code publishing that provides access to operational code Seite 9

JMX / Dynamic MBean Example (1) java.util.arraylist; java.util.list; javax.management.attribute; javax.management.attributelist; javax.management.attributenotfoundexception; javax.management.dynamicmbean; javax.management.invalidattributevalueexception; javax.management.mbeanexception; javax.management.mbeaninfo; javax.management.mbeanoperationinfo; javax.management.mbeanparameterinfo; javax.management.reflectionexception; public class BoundedStack implements DynamicMBean { int length = 10; int top = -1; private int[] a = new int[length]; // Operations public void push(int x) { if (top >= length) { throw new IllegalStateException(); a[++top] = x; public int pop() { if (top < 0) { throw new IllegalStateException(); return a[(top--)]; Seite 10

JMX / Dynamic MBean Example (2) // Management public void reset() { a = new int[length]; top = -1; public int getlength() { return length; public void resize(int length) { if (length < 0) { throw new IllegalArgumentException(); this.length = length; this.top = -1; this.a = new int[length]; public List<Integer> getstate() { List<Integer> res = new ArrayList<Integer>(top+1); for (int i=0; i<=top; i++) { res.add(a[i]); return res; Seite 11

JMX / Dynamic MBean Example (3a) //Publishing code public MBeanInfo getmbeaninfo() { MBeanOperationInfo[] opers = { new MBeanOperationInfo( "reset", //name of method "Reset the stack", //description null, //parameters "void", //return type MbeanOperationInfo.ACTION //has an effect but does not return any information ), new MBeanOperationInfo( "getlength", //name of method "Get stack length", //description null, //parameters "int", //return type MBeanOperationInfo.INFO //INFO: no effect returns information ), new MBeanOperationInfo( "resize", //name of method "Resize the stack", //description new MBeanParameterInfo[] {//parameters new MBeanParameterInfo( "length", //parameter name "int", //parameter type "The new size") //description, "int", //return type MBeanOperationInfo.INFO //INFO: no effect returns information ), new MBeanOperationInfo( "getstate", //name of method "Get stack state", //description null, //parameters "List<Integer>", //return type MBeanOperationInfo.INFO //INFO: no effect returns information ) Seite 12 ;

JMX / Dynamic MBean Example (3b) //public MBeanInfo getmbeaninfo() { continued return new MBeanInfo( this.getclass().getname(), "BoundedStack MBean", null, null, opers, null); //The name of the Java class of the MBean described by this MBeanInfo. //A human readable description of the MBean //The list of exposed attributes of the MBean //The list of public constructors of the MBean //The list of operations of the MBean //The list of notifications emitted Seite 13

JMX / Dynamic MBean Example (3c) public Object invoke(string name, Object[] args, String[] signature) throws MBeanException, ReflectionException { if (name.equals("reset") && (args == null args.length == 0) && (signature == null signature.length == 0)) { try { reset(); return null; catch (Exception e) { throw new MbeanException(e); if (name.equals("getlength") && (args == null args.length == 0) && (signature == null signature.length == 0)) { try { return getlength(); catch (Exception e) { throw new MbeanException(e); if (name.equals("resize") && (args.length == 1) && (signature.length == 1 && signature[0].equals("int"))) { try { resize((integer)args[0]); catch (Exception e) { throw new MbeanException(e); if (name.equals("getstate") && (args == null args.length == 0) && (signature == null signature.length == 0)){ try { return getstate(); catch (Exception e) { throw new MbeanException(e); throw new ReflectionException(new NoSuchMethodException(name)); Seite 14

JMX / Dynamic MBean Example (3d) public Object getattribute(string arg0) throws AttributeNotFoundException, MBeanException, ReflectionException { throw new AttributeNotFoundException(); public AttributeList getattributes(string[] arg0) { return new AttributeList(); public void setattribute(attribute arg0) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { throw new AttributeNotFoundException(); public AttributeList setattributes(attributelist arg0) { return new AttributeList(); Seite 15

JMX / Dynamic MBean Example (4a).../jdk1.6.0_23/bin/jconsole Seite 16

JMX / Dynamic MBean Example (4b) Seite 17

JMX and many things more see: JSR-000003 JavaTM Management Extensions (JMXTM) Evaluation 1.4 Maintenence Release 3 http://www.jcp.org/en/jsr/detail?id=3 Seite 18