|By Lucas McGregor||
|November 3, 2003 12:00 AM EST||
The promise of J2EE was to build more robust, scalable, and secure enterprise systems. J2EE promised that we could do it quickly and easily since J2EE is supposed to take the complexity out of building powerful distributed systems. But as with the J2EE spec itself, these systems usually suffer through management only as an afterthought.
Many management systems focus on proprietary interfaces that react to specific events. They offer solutions in which your management is tied up with the system you are managing. JMX4ODP decouples testing and management from the target system and focuses on using reusable components that are bound and deployed using XML configurations.
This article walks you through the process of setting up a basic service monitor and event handler for a common J2EE n-tier system. Developers of J2EE systems will be able to use JMX4ODP to create testing suites to help them develop more reliable systems. J2EE application administrators will be able to use JMX4ODP to simplify and regulate the management of deployed systems.
JMX4ODP is built from open standards technologies because they offer a better return on their investment by leveraging the work and experience of the community. Open standards also leverage your work and experience; for example, if your project has been tested in the past, you probably have someone on staff who already has JUnit experience. If you don't, learning JUnit will be useful for future projects.
JUnit and JMX are the two core foundations for JMX4ODP's approach to management. JUnit is becoming the de facto standard for unit testing. JUnit support is common in most IDE and test suites. JMX is Java's official answer to system management. Groups like JBoss are pushing JMX even further to make it a key piece in building complex infrastructures. JMX support is common in major J2EE application servers. IBM has even integrated JMX functionality with its popular Tivoli suite.
What You Need
To implement the examples in this article, make sure you have the following libraries available:
JUnit as a Diagnostics Tool
JUnit bills itself as a regression-testing suite for code objects, but it's not much of a leap to see it as a tool for distributed system diagnostics. JUnit runs tests by instantiating objects, invoking their methods with known inputs, and checking the output against expected returns.
Distributed systems are built over time as a collection of services - some standardized, some proprietary. Each service can be treated as an object for JUnit to test. In a typical J2EE installation, you have HTTP daemons, servlet engines, JNDI trees, RMI-enabled EJB containers, and databases accessed via JDBC.
Figure 1 illustrates these services as extensions of common protocols or as classes of objects to test. Since a system has a limited number of supported protocols, you can save a lot of coding by creating a base test class for each protocol and extending it as needed. The JMX4ODP's org.jmx4odp.junit DiagnosticWorkers package contains classes for testing HTTP, RMI, and JDBC services.
JUnit Test for Services
The JMX4ODP test classes follow the JUnit "assert" pattern. Each possible test method name starts with "assert," allowing developers to easily identify testing methods versus utility methods. Each method is stateless, allowing multiple testing objects to utilize the same underlying protocol test object, e.g., the HttpClientTest object contains methods for acquiring an HttpURLConnection and testing the connection for HTTP statuses and content.
By extending these basic service test classes to encapsulate a series of stateful tests, we get objects that are simply beans that contain a set of tests to run on a service. For example, you could extend the HTTP protocol test class to create an object that checks if you can reach a URL. You could then extend this class to make a test that checks a secured URL.
JMX4ODP's org.jmx4odp.junitDiagnosticWorkers package contains tests for three basic services: HTTP, RMI, and JDBC. Each is implemented as a stateful bean that you instantiate, set parameters for, and then hand over to JUnit to run.
To test HTTP services with BasicHttpUrlTest, set the URL you want to check and hand the object to JUnit, which will invoke each method that starts with the word "test." BasicHttpUrlTest's only test method is "test_URLOk," which checks the URL for a returned HTTP: 200 OK.
BasicEjbTest tests EJB services. It can use the settings in your jndi.properties to connect to your JNDI tree, or you can set them programmatically. You must set the JNDI name of the EJB. It contains one test, "test_AccessEJB," which tries to retrieve a RemoteObject from the JNDI tree by the set name and invoke getEJBMetaData upon it.
The BasicJDBCTest is more complicated. You need to set the JDBC URL, a test SQL select statement, and the database username and password. You can set an optional record threshold, which defaults to 1. This test object checks for two things before giving the service a green light. First, it runs "test_Can- Connect" to check if JDBC can connect to the database. Second, it runs "test_ SelectGood" to ensure that the test SQL select statement returns at least as many records as the threshold is set to.
Building Your TestSuite
JUnit has the ability to hierarchically arrange tests using TestSuite objects, but TestSuites are maintained programmatically, which is a big maintenance hit. JMX4ODP uses the org.jmx4odp. junitDiagnosticWorkers.SuiteAssembler object to translate an XML file into a TestSuite object, which cuts all the coding from maintenance.
Figure 2 shows the TestSuite XML entities used by the SuiteAssembler. TestSuite objects can hold either another TestSuite or TestCase. A TestCase is one of the stateful test beans. You invoke the get/set methods for service and test properties such as URLs and thresholds with the INVOKE element, which can take arguments of java.lang.String, boolean, and int. A TestSuitexml to test Yahoo's Web servers would look like:
<TESTSUITE name="Web Servers" >
<TESTCASE name="Yahoo" className=\
<INVOKE method="setUrl" >
SuiteAssembler will parse the XML and generate a TestSuite called "Web Servers" that contains a single BasicHttpUrlTest test bean called "Yahoo". It then hands the TestSuite over to JUnit, which will run the BasicHttpUrlTest.test_UrlOk method to see if a connection to www.yahoo.com returns an HTTP 200:OK. If Yahoo is unreachable or returns a different status, JUnit will display a failure.
You can use JUnit's junit.swingui .TestRunner to run JUnit tests in a graphical interface. Pass TestRunner the name of your test class as an argument. The JMX4ODP SuiteAssembler will load a TestSuite.xml file in the working directory. If you use the example TestSuite.xml and type:
> java junit.swingui.TestRunner
in the same directory, JUnit will parse the file, try to connect to www.yahoo.com, and display the results.
At this point you could simply build a TestSuite.xml file to check all the services you want and just use JUnit to run on-demand diagnostics of all your systems. If the line is green, the servers are clean. This would certainly be handy at 3 a.m. when you get the "the site is acting weird" phone call.
Already you can quickly and repeatedly run a set of known tests on your site and identify problems. However, this is a reactive instead of proactive solution. We now need to automate these tests and feed the results to a system that can use them.
Using Tests to Manage with JMX
Before JMX, there was no Java standard way for starting, stopping, monitoring, and managing components. If you're not familiar with JMX, there are some great books, such as JMX: Managing J2EE with Java Management Extensions by Marc Fleury, Juha Lindfors, and The JBoss Group.
JMX is a powerful and convenient way of building loosely coupled systems. The JMX agent is a bean container for specialized management beans called MBeans. The agent allows you to instantiate new MBeans, register existing MBeans, bind MBeans together, and send and receive notifications.
Many J2EE engines and management packages have adopted JMX as a core feature, because it's flexible and extensible. J2EE programmers are familiar with component-based programming, and JMX capitalizes on that to create component-based management systems that are scalable. JSR 160 (www.jcp.org/en/jsr/detail?id=160) is extending the core JMX specification to include remoting functionality, which is used by JMX4ODP to connect clients and other agents to each other via RMI.
org.jmx4odp.junitRunner.Event Runner is an MBean that implements a JUnit TestRunner. It serves as the bridge between your JUnit diagnostic setup and JMX management. It will fetch a Test- Suitexml from a given URL, use the SuiteAssembler to construct a TestSuite, hand it to a JUnit TestRunner to run all the tests, and broadcast any failures or errors as notifications to any registered listeners. The EventRunner will then sleep for the specified time and do it all over again.
You can think of JMX4ODP as a reflex system for your J2EE system. JUnit test objects act as live nerves gathering information about the state of objects and services in your system. The JMX agent is like a spinal cord, transmitting these impulses between the brain and muscles. The Event- Runner MBean, the system's brain, coordinates all the JUnit tests and keeps them running regularly. Now you just need to add some muscle to complete the system.
Muscle takes the form of JMX NotificationListener MBeans. Any MBean that implements the javax. management.NotificationListener interface can register itself with the EventRunner to receive failure and error notifications. The Notification- Listener will receive a javax. management. Notification object that contains attributes including timestamp, type, and message. The type of message can be set via the two EventRunner methods: setErrorTopic(String s) and setFailureTopic(String s). The event runner will broadcast the message as an error type if an error occurred while trying to run the test. It will use the failure topic if the test was unsuccessful. The event notification message will be formatted like TestFailure.getName() + ": " + failure.toString(); if failure.to String() returns a null, it will use failure. thrownException().toString().
A NotificationListener can register with the EventRunner and be activated upon these events. It can use the Notification.getMessage() to learn which test failed and how. We'll use the org.jmx4odp.notificationWorkers.Notifi cationMailer as a simple starting place. This MBean uses the javax.mail.* package to e-mail JMX notifications. By registering the Notification Mailer with the EventRunner, you have a failure notification system that will alert your sysadmin when a problem occurs.
All this needs to be set up programmatically which is a maintenance issue. JMX's MLet object can be used to make a JMX agent load MBeans specified in an XML file, but it doesn't include the ability to invoke functions on instantiated MBeans. To overcome this, JMX- 4ODP uses its org.jmx4odp. j4oNet.Xml- Executor object to load and access MBeans in an agent.
Figure 3 shows the XML entities used by the XmlExecutor. Listing 1 shows the beginning of such a file.
Everything is a child of the EXECUTEXML element. The JMXREMOTE element tells XmlExecutor to connect to the JMX agent's RMIAdaptor. TRY groups elements together, so if one fails, it will skip the rest in the group so you don't have to wait for each element to fail. Use CREATEMBEAN to tell the JMX agent to instantiate a new MBean. COMMAND is the big advantage of XmlExecutor; it allows you to invoke methods on existing MBeans.
JMX4ODP ships with org.jmx4odp. j4oNet.BaseServer as its JMX agent. It takes the HTMLAdaptor port and the RMIAdaptor port as its two arguments.
> java org.jmx4odp.j4oNet.BaseServer 80801099
to start the BaseServer. Now point a Web browser to localhost:8080 to see an HTML interface of your MBeans. JMXREMOTE will use port 1099.
Now that you have a JMX agent with an RMIAdaptor running, you can create an XML Execute.xml file that will tell XmlExecutor to:
1. Create an EventRunnerMBean.
2. Invoke EventRunner.setFailureTopic to set the failure Notification type.
3. Invoke EventRunner.setErrorTopic to set the error Notification type.
4. Invoke EventRunner.SetSuiteAssemblerConfig to give the URL for your TestSuite.xml.
5. Invoke EventRunner.setSleepCount to set how many milliseconds to sleep between test cycles.
6. Create a NotificationMailer MBean.
7. Invoke NotificationMailer.setSmtpHost to set the host name of your mail gateway.
8. Invoke NotificationMailer.setSmtpUser and setSmtpPassword to set the username and password for your SMTP user if needed.
9. Invoke NotificationMailer.setSmtpPort if your gateway uses anything other than port 25.
10. Invoke NotificationMailer.setFrom Address to the address you want the notification e-mails to come from.
11. Invoke NotificationMailer.setSubject to set the e-mail subject line.
12. Invoke NotificationMailer.addTo Address to add an address to which to send notification e-mails.
13. Invoke NotificationMailer.setActive to activate the mailer; otherwise it will ignore all notifications while inactive.
14. Invoke NotificationMailer.add ListenedToObject to ."MONITOR: name=EventRunner,NotificationLogger=true," which will tell Notification Mailer to listen to the Notification Logger created by the EventRunner.
15. Invoke EventRunner.startDaemon to start the testing cycle.
Figure 4 illustrates how JMX4ODP combines the JUnit tests and JMX management components to create a management system. If you use the example TestSuite.xml, you're testing if you can reach Yahoo. If this test fails, a JUnit event will be broadcast to all registered listeners. Your only listener right now is an MBean that will send out the event as an e-mail. If you start up a Web browser to http://localhost:8080, you'll see your JMX agent's HTMLAdaptor and all the new MBeans you started.
We've Only Just Begun...
The most obvious ways to expand JMX4ODP is to:
The example we just used showed how to create an alert system. However, you could easily create a NotificationListener MBean that alters the system's state instead of telling your sysadmin to do it. For example, if your JBDC tester finds that your primary database has gone down, you could have a NotificationListener automatically start the failover procedure. Other possible directions would include automating start-up and shut-down via custom NotificationListeners; or monitoring log file size, network traffic, or response time via custom JUnit test beans.
JMX and JUnit allow for loosely coupled designs that are modular, making it trivial to add and rearrange tests and responses. To add new actions, register new NotificationListeners. To change your test plans, update an XML file. Maintenance of your management suite should not be a full-time job. Your diagnostics and testing systems are no longer a coupled part of the target system. Once you've created common components, they can be used to manage new systems as they're developed.
By using the JMX4ODP mode of design, management isn't an afterthought, but neither is it a burden of intense design or the lock-in of proprietary solutions. Management becomes another one of those things you get free when you use J2EE.
|bruno sarrant 11/18/03 03:48:47 AM EST|
It is one thing to build single industrial IoT applications, but what will it take to build the Smart Cities and truly society-changing applications of the future? The technology won’t be the problem, it will be the number of parties that need to work together and be aligned in their motivation to succeed. In his session at @ThingsExpo, Jason Mondanaro, Director, Product Management at Metanga, discussed how you can plan to cooperate, partner, and form lasting all-star teams to change the world and it starts with business models and monetization strategies.
Jul. 28, 2015 04:30 PM EDT Reads: 1,737
The Internet of Everything (IoE) brings together people, process, data and things to make networked connections more relevant and valuable than ever before – transforming information into knowledge and knowledge into wisdom. IoE creates new capabilities, richer experiences, and unprecedented opportunities to improve business and government operations, decision making and mission support capabilities.
Jul. 28, 2015 04:00 PM EDT Reads: 185
The Internet of Things is not only adding billions of sensors and billions of terabytes to the Internet. It is also forcing a fundamental change in the way we envision Information Technology. For the first time, more data is being created by devices at the edge of the Internet rather than from centralized systems. What does this mean for today's IT professional? In this Power Panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists addressed this very serious issue of profound change in the industry.
Jul. 28, 2015 03:00 PM EDT Reads: 1,233
Discussions about cloud computing are evolving into discussions about enterprise IT in general. As enterprises increasingly migrate toward their own unique clouds, new issues such as the use of containers and microservices emerge to keep things interesting. In this Power Panel at 16th Cloud Expo, moderated by Conference Chair Roger Strukhoff, panelists addressed the state of cloud computing today, and what enterprise IT professionals need to know about how the latest topics and trends affect their organization.
Jul. 28, 2015 02:00 PM EDT Reads: 1,149
SYS-CON Events announced today that HPM Networks will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. For 20 years, HPM Networks has been integrating technology solutions that solve complex business challenges. HPM Networks has designed solutions for both SMB and enterprise customers throughout the San Francisco Bay Area.
Jul. 28, 2015 11:45 AM EDT Reads: 387
For IoT to grow as quickly as analyst firms’ project, a lot is going to fall on developers to quickly bring applications to market. But the lack of a standard development platform threatens to slow growth and make application development more time consuming and costly, much like we’ve seen in the mobile space. In his session at @ThingsExpo, Mike Weiner, Product Manager of the Omega DevCloud with KORE Telematics Inc., discussed the evolving requirements for developers as IoT matures and conducted a live demonstration of how quickly application development can happen when the need to comply wit...
Jul. 28, 2015 11:15 AM EDT Reads: 163
Converging digital disruptions is creating a major sea change - Cisco calls this the Internet of Everything (IoE). IoE is the network connection of People, Process, Data and Things, fueled by Cloud, Mobile, Social, Analytics and Security, and it represents a $19Trillion value-at-stake over the next 10 years. In her keynote at @ThingsExpo, Manjula Talreja, VP of Cisco Consulting Services, discussed IoE and the enormous opportunities it provides to public and private firms alike. She will share what businesses must do to thrive in the IoE economy, citing examples from several industry sectors.
Jul. 28, 2015 11:00 AM EDT Reads: 2,024
Growth hacking is common for startups to make unheard-of progress in building their business. Career Hacks can help Geek Girls and those who support them (yes, that's you too, Dad!) to excel in this typically male-dominated world. Get ready to learn the facts: Is there a bias against women in the tech / developer communities? Why are women 50% of the workforce, but hold only 24% of the STEM or IT positions? Some beginnings of what to do about it! In her Opening Keynote at 16th Cloud Expo, Sandy Carter, IBM General Manager Cloud Ecosystem and Developers, and a Social Business Evangelist, d...
Jul. 27, 2015 09:00 PM EDT Reads: 2,032
Explosive growth in connected devices. Enormous amounts of data for collection and analysis. Critical use of data for split-second decision making and actionable information. All three are factors in making the Internet of Things a reality. Yet, any one factor would have an IT organization pondering its infrastructure strategy. How should your organization enhance its IT framework to enable an Internet of Things implementation? In his session at @ThingsExpo, James Kirkland, Red Hat's Chief Architect for the Internet of Things and Intelligent Systems, described how to revolutionize your archit...
Jul. 27, 2015 05:30 PM EDT Reads: 1,350
There will be 150 billion connected devices by 2020. New digital businesses have already disrupted value chains across every industry. APIs are at the center of the digital business. You need to understand what assets you have that can be exposed digitally, what their digital value chain is, and how to create an effective business model around that value chain to compete in this economy. No enterprise can be complacent and not engage in the digital economy. Learn how to be the disruptor and not the disruptee.
Jul. 27, 2015 10:00 AM EDT Reads: 2,017
Akana has released Envision, an enhanced API analytics platform that helps enterprises mine critical insights across their digital eco-systems, understand their customers and partners and offer value-added personalized services. “In today’s digital economy, data-driven insights are proving to be a key differentiator for businesses. Understanding the data that is being tunneled through their APIs and how it can be used to optimize their business and operations is of paramount importance,” said Alistair Farquharson, CTO of Akana.
Jul. 27, 2015 09:00 AM EDT Reads: 176
Business as usual for IT is evolving into a "Make or Buy" decision on a service-by-service conversation with input from the LOBs. How does your organization move forward with cloud? In his general session at 16th Cloud Expo, Paul Maravei, Regional Sales Manager, Hybrid Cloud and Managed Services at Cisco, discusses how Cisco and its partners offer a market-leading portfolio and ecosystem of cloud infrastructure and application services that allow you to uniquely and securely combine cloud business applications and services across multiple cloud delivery models.
Jul. 27, 2015 08:00 AM EDT Reads: 1,889
The enterprise market will drive IoT device adoption over the next five years. In his session at @ThingsExpo, John Greenough, an analyst at BI Intelligence, division of Business Insider, analyzed how companies will adopt IoT products and the associated cost of adopting those products. John Greenough is the lead analyst covering the Internet of Things for BI Intelligence- Business Insider’s paid research service. Numerous IoT companies have cited his analysis of the IoT. Prior to joining BI Intelligence, he worked analyzing bank technology for Corporate Insight and The Clearing House Payment...
Jul. 26, 2015 09:00 PM EDT Reads: 1,539
In his keynote at 16th Cloud Expo, Rodney Rogers, CEO of Virtustream, discussed the evolution of the company from inception to its recent acquisition by EMC – including personal insights, lessons learned (and some WTF moments) along the way. Learn how Virtustream’s unique approach of combining the economics and elasticity of the consumer cloud model with proper performance, application automation and security into a platform became a breakout success with enterprise customers and a natural fit for the EMC Federation.
Jul. 26, 2015 08:00 AM EDT Reads: 2,131
"Optimal Design is a technology integration and product development firm that specializes in connecting devices to the cloud," stated Joe Wascow, Co-Founder & CMO of Optimal Design, in this SYS-CON.tv interview at @ThingsExpo, held June 9-11, 2015, at the Javits Center in New York City.
Jul. 25, 2015 02:00 PM EDT Reads: 377
SYS-CON Events announced today that CommVault has been named “Bronze Sponsor” of SYS-CON's 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. A singular vision – a belief in a better way to address current and future data management needs – guides CommVault in the development of Singular Information Management® solutions for high-performance data protection, universal availability and simplified management of data on complex storage networks. CommVault's exclusive single-platform architecture gives companies unp...
Jul. 25, 2015 01:00 PM EDT Reads: 1,932
Electric Cloud and Arynga have announced a product integration partnership that will bring Continuous Delivery solutions to the automotive Internet-of-Things (IoT) market. The joint solution will help automotive manufacturers, OEMs and system integrators adopt DevOps automation and Continuous Delivery practices that reduce software build and release cycle times within the complex and specific parameters of embedded and IoT software systems.
Jul. 25, 2015 12:15 PM EDT Reads: 408
"ciqada is a combined platform of hardware modules and server products that lets people take their existing devices or new devices and lets them be accessible over the Internet for their users," noted Geoff Engelstein of ciqada, a division of Mars International, in this SYS-CON.tv interview at @ThingsExpo, held June 9-11, 2015, at the Javits Center in New York City.
Jul. 25, 2015 12:00 PM EDT Reads: 1,516
Internet of Things is moving from being a hype to a reality. Experts estimate that internet connected cars will grow to 152 million, while over 100 million internet connected wireless light bulbs and lamps will be operational by 2020. These and many other intriguing statistics highlight the importance of Internet powered devices and how market penetration is going to multiply many times over in the next few years.
Jul. 25, 2015 09:00 AM EDT Reads: 1,475
SYS-CON Events announced today that Dyn, the worldwide leader in Internet Performance, will exhibit at SYS-CON's 17th International Cloud Expo®, which will take place on November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Dyn is a cloud-based Internet Performance company. Dyn helps companies monitor, control, and optimize online infrastructure for an exceptional end-user experience. Through a world-class network and unrivaled, objective intelligence into Internet conditions, Dyn ensures traffic gets delivered faster, safer, and more reliably than ever.
Jul. 24, 2015 11:00 PM EDT Reads: 2,039