|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.
SYS-CON Events announced today that SOA Software, an API management leader, will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. SOA Software is a leading provider of API Management and SOA Governance products that equip business to deliver APIs and SOA together to drive their company to meet its business strategy quickly and effectively. SOA Software’s technology helps businesses to accelerate their digital channels with APIs, drive partner adoption, monetize their assets, and achieve a...
Oct. 31, 2014 07:15 PM EDT Reads: 2,117
SYS-CON Events announced today that Aria Systems, the recurring revenue expert, has been named "Bronze Sponsor" of SYS-CON's 15th International Cloud Expo®, which will take place on November 4-6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Aria Systems helps leading businesses connect their customers with the products and services they love. Industry leaders like Pitney Bowes, Experian, AAA NCNU, VMware, HootSuite and many others choose Aria to power their recurring revenue business and deliver exceptional experiences to their customers.
Oct. 31, 2014 06:30 PM EDT Reads: 2,192
SYS-CON Events announced today that AgilePoint, the leading provider of Microsoft-centric Business Process Management software, will exhibit at SYS-CON's 2nd International @ThingsExpo which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. AgilePoint is the leading provider of Microsoft-based Business Process Management (BPM) software products, has 1,300+ on-premise and cloud deployments in 25+ countries and provides the same advanced BPM feature set as J2EE vendors like IBM and Appian for the Microsoft .NET native environment. AgilePoint customer...
Oct. 31, 2014 05:00 PM EDT Reads: 1,338
The Internet of Things (IoT) promises to evolve the way the world does business; however, understanding how to apply it to your company can be a mystery. Most people struggle with understanding the potential business uses or tend to get caught up in the technology, resulting in solutions that fail to meet even minimum business goals. In his session at Internet of @ThingsExpo, Jesse Shiah, CEO / President / Co-Founder of AgilePoint Inc., will show what is needed to leverage the IoT to transform your business. He will discuss opportunities and challenges ahead for the IoT from a market and tec...
Oct. 31, 2014 04:00 PM EDT Reads: 1,625
SYS-CON Events announced today that Utimaco will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Utimaco is a leading manufacturer of hardware based security solutions that provide the root of trust to keep cryptographic keys safe, secure critical digital infrastructures and protect high value data assets. Only Utimaco delivers a general-purpose hardware security module (HSM) as a customizable platform to easily integrate into existing software solutions, embed business logic and build s...
Oct. 31, 2014 03:00 PM EDT Reads: 1,979
One of the biggest challenges when developing connected devices is identifying user value and delivering it through successful user experiences. In his session at Internet of @ThingsExpo, Mike Kuniavsky, Principal Scientist, Innovation Services at PARC, will describe an IoT-specific approach to user experience design that combines approaches from interaction design, industrial design and service design to create experiences that go beyond simple connected gadgets to create lasting, multi-device experiences grounded in people’s real needs and desires.
Oct. 31, 2014 02:00 PM EDT Reads: 1,845
SYS-CON Events announced today that TeleStax, the main sponsor of Mobicents, will exhibit at Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. TeleStax provides Open Source Communications software and services that facilitate the shift from legacy SS7 based IN networks to IP based LTE and IMS networks hosted on private (on-premise), hybrid or public clouds. TeleStax products include Restcomm, JSLEE, SMSC Gateway, USSD Gateway, SS7 Resource Adaptors, SIP Servlets, Rich Multimedia Services, Presence Services/RCS, Diame...
Oct. 31, 2014 09:00 AM EDT Reads: 1,714
Samsung VP Jacopo Lenzi, who headed the company's recent SmartThings acquisition under the auspices of Samsung's Open Innovaction Center (OIC), answered a few questions we had about the deal. This interview was in conjunction with our interview with SmartThings CEO Alex Hawkinson. IoT Journal: SmartThings was developed in an open, standards-agnostic platform, and will now be part of Samsung's Open Innovation Center. Can you elaborate on your commitment to keep the platform open? Jacopo Lenzi: Samsung recognizes that true, accelerated innovation cannot be driven from one source, but requires a...
Oct. 31, 2014 09:00 AM EDT Reads: 3,393
The Internet of Things will greatly expand the opportunities for data collection and new business models driven off of that data. In her session at Internet of @ThingsExpo, Esmeralda Swartz, CMO of MetraTech, will discuss how for this to be effective you not only need to have infrastructure and operational models capable of utilizing this new phenomenon, but increasingly service providers will need to convince a skeptical public to participate. Get ready to show them the money! Speaker Bio: Esmeralda Swartz, CMO of MetraTech, has spent 16 years as a marketing, product management, and busin...
Oct. 31, 2014 09:00 AM EDT Reads: 2,350
Things are being built upon cloud foundations to transform organizations. This CEO Power Panel at 15th Cloud Expo, moderated by Roger Strukhoff, Cloud Expo and @ThingsExpo conference chair, will address the big issues involving these technologies and, more important, the results they will achieve. How important are public, private, and hybrid cloud to the enterprise? How does one define Big Data? And how is the IoT tying all this together?
Oct. 31, 2014 08:45 AM EDT Reads: 2,018
We certainly live in interesting technological times. And no more interesting than the current competing IoT standards for connectivity. Various standards bodies, approaches, and ecosystems are vying for mindshare and positioning for a competitive edge. It is clear that when the dust settles, we will have new protocols, evolved protocols, that will change the way we interact with devices and infrastructure. We will also have evolved web protocols, like HTTP/2, that will be changing the very core of our infrastructures. At the same time, we have old approaches made new again like micro-services...
Oct. 31, 2014 07:00 AM EDT Reads: 1,682
SYS-CON Events announces a new pavilion on the Cloud Expo floor where WebRTC converges with the Internet of Things. Pavilion will showcase WebRTC and the Internet of Things. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devices--computers, smartphones, tablets, and sensors – connected to the Internet by 2020. This number will continue to grow at a rapid pace for the next several decades.
Oct. 30, 2014 05:30 PM EDT Reads: 2,227
The only place to be June 9-11 is Cloud Expo & @ThingsExpo 2015 East at the Javits Center in New York City. Join us there as delegates from all over the world come to listen to and engage with speakers & sponsors from the leading Cloud Computing, IoT & Big Data companies. Cloud Expo & @ThingsExpo are the leading events covering the booming market of Cloud Computing, IoT & Big Data for the enterprise. Speakers from all over the world will be hand-picked for their ability to explore the economic strategies that utility/cloud computing provides. Whether public, private, or in a hybrid form, clo...
Oct. 30, 2014 05:30 PM EDT Reads: 1,496
SYS-CON Events announced today that Gridstore™, the leader in software-defined storage (SDS) purpose-built for Windows Servers and Hyper-V, will exhibit at SYS-CON's 15th International Cloud Expo®, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Gridstore™ is the leader in software-defined storage purpose built for virtualization that is designed to accelerate applications in virtualized environments. Using its patented Server-Side Virtual Controller™ Technology (SVCT) to eliminate the I/O blender effect and accelerate applications Gridsto...
Oct. 30, 2014 02:00 PM EDT Reads: 2,629
SYS-CON Events announced today that Red Hat, the world's leading provider of open source solutions, will exhibit at Internet of @ThingsExpo, which will take place on November 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA. Red Hat is the world's leading provider of open source software solutions, using a community-powered approach to reliable and high-performing cloud, Linux, middleware, storage and virtualization technologies. Red Hat also offers award-winning support, training, and consulting services. As the connective hub in a global network of enterprises, partners, a...
Oct. 30, 2014 12:15 PM EDT Reads: 2,092
As the Internet of Things unfolds, mobile and wearable devices are blurring the line between physical and digital, integrating ever more closely with our interests, our routines, our daily lives. Contextual computing and smart, sensor-equipped spaces bring the potential to walk through a world that recognizes us and responds accordingly. We become continuous transmitters and receivers of data. In his session at Internet of @ThingsExpo, Andrew Bolwell, Director of Innovation for HP’s Printing and Personal Systems Group, will discuss how key attributes of mobile technology – touch input, senso...
Oct. 30, 2014 12:00 PM EDT Reads: 1,789
The Internet of Things (IoT) is making everything it touches smarter – smart devices, smart cars and smart cities. And lucky us, we’re just beginning to reap the benefits as we work toward a networked society. However, this technology-driven innovation is impacting more than just individuals. The IoT has an environmental impact as well, which brings us to the theme of this month’s #IoTuesday Twitter chat. The ability to remove inefficiencies through connected objects is driving change throughout every sector, including waste management. BigBelly Solar, located just outside of Boston, is trans...
Oct. 30, 2014 11:00 AM EDT Reads: 2,206
Connected devices and the Internet of Things are getting significant momentum in 2014. In his session at Internet of @ThingsExpo, Jim Hunter, Chief Scientist & Technology Evangelist at Greenwave Systems, will examine three key elements that together will drive mass adoption of the IoT before the end of 2015. The first element is the recent advent of robust open source protocols (like AllJoyn and WebRTC) that facilitate M2M communication. The second is broad availability of flexible, cost-effective storage designed to handle the massive surge in back-end data in a world where timely analytics...
Oct. 30, 2014 08:00 AM EDT Reads: 1,651
Internet of @ThingsExpo Silicon Valley announced on Thursday its first 12 all-star speakers and sessions for its upcoming event, which will take place November 4-6, 2014, at the Santa Clara Convention Center in California. @ThingsExpo, the first and largest IoT event in the world, debuted at the Javits Center in New York City in June 10-12, 2014 with over 6,000 delegates attending the conference. Among the first 12 announced world class speakers, IBM will present two highly popular IoT sessions, which will take place November 4-6, 2014 at the Santa Clara Convention Center in Santa Clara, Calif...
Oct. 30, 2014 07:30 AM EDT Reads: 2,320
From a software development perspective IoT is about programming "things," about connecting them with each other or integrating them with existing applications. In his session at @ThingsExpo, Yakov Fain, co-founder of Farata Systems and SuranceBay, will show you how small IoT-enabled devices from multiple manufacturers can be integrated into the workflow of an enterprise application. This is a practical demo of building a framework and components in HTML/Java/Mobile technologies to serve as a platform that can integrate new devices as they become available on the market.
Oct. 29, 2014 02:15 PM EDT Reads: 2,090