|By Joe Bradley, David Raal||
|December 4, 2003 12:00 AM EST||
Service-oriented architectures (SOA) provide numerous benefits: reuse of business logic by many clients, location transparency of business logic, simplified unit testing, better scalability through distributed and load-balanced processing, and the composition of new services from existing services. Enterprise JavaBeans are a favorite platform on which to base service-oriented architectures because of their enterprise-class features.
As many new SOA applications are now developed on the J2EE platform, a problem arises: how to maintain 100% availability while deploying maintenance fixes and new versions of the services. Most application server vendors do not recommend hot deployment of applications in production; problems may occur with unloading classes, class loaders, and resources being used by existing deployments. Instead, the vendors recommend restarting the server or cluster of servers after a redeployment; however, the total time to redeploy, test, and restart a cluster of servers can be substantial. This downtime is unacceptable for many production sites due to loss of revenue and customer goodwill, and the mission-critical nature of the services.
A solution to this problem is to provide a mechanism for dynamically switching clients from a cluster of application servers running the old version to another cluster of application servers running the new version. We refer to this as dynamic cluster switching. This can be accomplished by some enhancements to commonly used J2EE patterns in conjunction with JMS-based messaging. The result is that most deployments of new releases can be made without interruption of services to the client.
Why bother with non-stop EJB services? We have all experienced the issues associated with EJB application upgrades and deployments, such as unexpected outages due to limited testing, poor fall-back strategies, and planned downtime for maintenance in the wee hours. For businesses selling commodity goods and services on the Web, downtime directly translates to lost revenue when customers can easily surf to other sites to buy the same product. With non-stop EJB services, you can reduce if not eliminate downtime while seamlessly rolling out new versions of your services. Imagine redeploying and upgrading your EJBs without impacting your clients and their Web sites, Web services, consumers, and business partners. If there are issues with the new software, fallback is low-risk and easy to accomplish. All of this occurs during peak traffic periods when using non-stop EJB services. This article describes how this was accomplished on a large consumer Web site handling over 15,000 concurrent sessions during peak times.
Dynamic Cluster Switching
This solution uses JMS messaging to control a plug-in used by clients of the EJB services. When it's time to release a new version of software, an alternate cluster of servers is deployed with the new code on the same hardware platform as the existing servers. A console or command-line program publishes a "cluster switch" message to the client plug-ins that subscribe to a JMS admin topic. The client plug-ins then start to open connections to the new cluster and allow connections to the old cluster to "die off" as sessions or connections are released. In a short time, all the client plug-ins are seamlessly connected to the new cluster. While this approach sounds simple at a high level, the implementation needs the confluence of many design patterns to be successful in practice.
A basic assumption to this solution is that the EJB services are deployed as their own J2EE application, independent of any Web components or J2EE application clients. In environments requiring performance, flexibility, scalability, and reliability, this is likely to be the case anyway.
The implementation of the solution uses several common design patterns and enhancements in combination with JMS messaging. The particular patterns used are Service Locator, Business Delegate, Publish/Subscribe Messaging, and Observer. Figure 1 provides a graphical depiction of how the various components and message flows work together to perform the cluster switch.
Business Delegates are the client's proxy to the services. They use a Service Locator to obtain an EJBHome object and subsequently create a remote reference to an EJB. To be able to create Business Delegates that point to a different cluster of servers, the Service Locator needs to change its provider URL where it looks up EJBHome objects. This can be accomplished by having the Service Locator receive an update configuration message on a JMS topic that contains the new provider URL.
Clients using existing Business Delegates are not affected and their existing remote references to EJBs continue to operate. As the sessions for these clients expire, the remote references are released and their Business Delegates are garbage collected. New Business Delegates that were created after the Service Locator received the update configuration message are in effect pointing to the cluster identified by the updated provider URL. This is because their EJB handle was created from EJBHome objects looked up at the updated URL.
A JMS subscriber receives update configuration messages and passes them on to a MultiCaster. The MultiCaster becomes the sole point in the client VM for receiving these messages and distributing them to interested components. When the client code first loads, the JMS subscriber is initialized and components, such as the Service Locator, register with the MultiCaster for the type of messages they wish to receive.
A simple command-line program can be used to generate the JMS message that initiates the cluster switch, or this functionality could be part of a more comprehensive management and monitoring console application. The publish-subscribe paradigm is important here because any number of clients can be dynamically reconfigured through their connection to a JMS topic. This approach supports the management of a dynamic and ever-changing set of clients connected to the EJB servers.
Figure 2 is a class diagram of implementations of the various components and patterns. The source code for this article can be downloaded from www.sys-con.com/java/sourcec.cfm. The code should be considered fragments, intended only to illustrate the points in this article since it's missing important features such as logging, exception handling, and configurability. The more important classes will now be discussed in detail.
The Service Locator pattern, as described in Core J2EE Patterns, abstracts all JNDI usage, hides the details of initial context creation as well as EJBHome lookup, and caches EJBHomes for performance reasons. The Service Locator is usually made a singleton so that all clients can access the same EJBHome cache.
For the Service Locator to receive update configuration messages, it must register with the MultiCaster when first loaded. When a message is received, the Service Locator replaces its local copy of the provider URL and the initial context factory class with those obtained from the message. Subsequently, it invalidates its current cache of EJBHome objects. Then, the next time a Business Delegate asks for the EJBHome, it won't be found in the cache and will be looked up at the new provider URL. Once looked up, the new EJBHome object will be placed in the cache.
The implementation of the Service Locator provided in the source code is named ClientServiceLocator. As the name indicates, there may be other Service Locators in an application for use in other layers of the architecture (e.g., Services, Foundation, etc.).
Business Delegate (BD)
The Business Delegate pattern hides the details of connecting to and using an EJB. Typically each business method in an EJB has a corresponding method in the Business Delegate that delegates client invocations to the EJB. The Business Delegate catches all the exceptions that can result from communicating with an EJB and turns them into application-specific exceptions. It allows clients to use the services as if they were local, and is thus a client-side proxy for a service. Business delegates can also be used to cache frequently requested data and provide other similar performance improvements to the services.
In addition to the normal responsibilities ascribed to the Business Delegate, the following additional responsibilities are required to support continuous availability of services:
1. The BD must automatically perform a client/server version compatibility check. The first time a remote reference is retrieved by a business delegate, the client version must be compared to the server version to ensure compatibility. If incompatible, the business delegate must return a specific exception on compatibility mismatch that can be caught by a client. The exception should be logged by the client in the form of an informative error message. This provides a quick indication to support personnel that the client view JAR file is out of date. Without this check, a serialization error will result if the client and server classes are incompatible, and the source of the error will not be obvious to support personnel.
2. The BD provides a create() and release() method for use by the client. Typically the Business Delegate Factory invokes the create method so the client doesn't need to. The client should always call the release method, however, when finished with a Business Delegate. For Web component clients (servlets and JSP pages), assuming the BD has been placed in the session, this can be accomplished by catching HTTP session timeouts with the HTTPSessionBindingListener interface. The release method not only invokes remove() on the Business Delegate's EJB remote reference, but a BusinessDelegateReleasedMsg is sent to the MultiCaster. The MultiCaster in turn notifies objects that have registered to receive this event, notably the Business Delegate Factories. The use of this event by the Business Delegate Factory is described in the next section.
The above responsibilities are implemented in the BusinessDelegate base class and should be extended by each Business Delegate in an application. All the business methods of each Business Delegate subclass typically invoke the inherited getService method to obtain the remote reference. Rather than store a remote reference to an EJB, which is not guaranteed to be serializable by the EJB specification, BusinessDelegate stores the EJB Handle. getService() reconstitutes the remote reference from the EJB Handle on each invocation in case the Business Delegate has been serialized to another server in the cluster between invocations.
Business Delegate Factory
A Business Delegate Factory is used primarily because it provides the flexibility to hand out other implementations of the Business Delegates depending on the type of client. It also enables a total count to be kept of the number of Business Delegates of each type that have been handed out, as well as a running count of the current number of outstanding Business Delegates.
A subclass of BusinessDelegateFactory should be created for each Business Delegate in an application and a singleton should be created for it. The singleton should register with the MultiCaster to receive Business Delegate release messages for the corresponding Business Delegate type. The management of the counters and the reporting of the counts is all inherited from the BusinessDelegateFactory base class. The specific mechanism for reporting the counts is outside the scope of this article but could be reported by a JMX agent or published to a JMS topic.
The MultiCaster is the central player in the implementation of the Observer pattern. Observers register with the MultiCaster, providing a filter implementation. When the MultiCaster is notified of an event, it applies all filters to it and notifies observers (subscribers) who have matching filters for the event.
The role of the MultiCaster is to deliver Business Delegate-released notifications to each subclass of BusinessDelegateFactory, as well as deliver update configuration messages to the Service Locator that was received on a JMS topic.
To receive notifications that a Business Delegate has been released, each subclass of BusinessDelegateFactory adds itself as an observer to the MultiCaster with a filter type of BusinessDelegateReleasedFilter. This filter type checks to see that the published object is of type BusinessDelegateReleasedMsg, and that the BD name in the message is the same as that with which the filter was constructed. This causes each BusinessDelegateFactory to receive release notifications only for the type of Business Delegates it creates.
To receive update configuration messages, the Service Locator adds itself as an observer to the MultiCaster with a filter type of UpdateServiceLocatorFilter. This filter type checks to see that the published object is of type ConfigureServiceLocatorMsg.
Two Levels of Client Redirection
The solution presented in this article redirects new clients of the services to the new version of the services. Existing clients using the old version are left to slowly bleed off as their sessions expire. A modification to the solution could be made to immediately switch all existing clients of the services to the new version as well. This would mean that every Business Delegate registering with the MultiCaster would receive Service Locator reconfigured messages, which the Service Locator would have to publish after reconfiguration was complete. This enhancement would also involve the additional complication of managing access to BD instances by multiple threads since the client thread using the BD would be distinct from the thread used by the MultiCaster to deliver event notifications to the BD.
Procedure for Cluster Switch
Now that the architecture of the solution that enables an application for dynamic cluster switching has been presented, we'll discuss the procedure for actually performing a switch. While the procedure might seem obvious, experience has shown the obvious approach is not necessarily the best.
Recall that one of the assumptions stated at the beginning of this article is that clients of the services are running in separate containers from the services. This means that those clients will be using a client view JAR file that has all the classes necessary to be a client of the services. Included in that client view JAR file are configuration resources that point the Business Delegates to a specific application server cluster (subsequently called the "primary" cluster). Assume the new version of the services is deployed to the "alternate" cluster and clients are switched there. It's not unreasonable to assume that at some point, days or weeks later, the client environment (such as a Web container) may need to be restarted. In that case, the clients will get their configuration from their existing client view JAR file, which is pointing to the primary cluster. But the latest services are running on the alternate cluster.
The procedure we've been using in production to solve this problem is as follows:
- Boot the alternate cluster.
- Deploy the old services to the alternate cluster.
- Run regression tests to verify the services are functioning as expected on the alternate cluster.
- . Issue a cluster switch to clients to point them to the alternate cluster.
- Enable trace-level logging in the old services in the primary cluster to ascertain when existing sessions have bled off the primary cluster. An admin console that is able to query and display the outstanding BD counts from the Business Delegate Factories can also be used as a cross check.
- Remove the old services from the primary cluster and deploy the new ones to it.
- Run regression tests against the new services on the primarycluster.
- Issue a cluster switch to clients to point them at the primary cluster.
- Monitor old services on the alternate cluster to determine when incoming traffic has stopped.
- Shut down the alternate cluster.
A caveat to dynamic cluster switching is that if a change in the public API of the services would cause a serialization or marshaling error between clients using old classes and the new services, the switch cannot be performed. Clients will have to shut down to upgrade their client view JAR files to the new version.
Minimizing the frequency of incompatible builds requires careful attention to application and object versioning. The Java Object Serialization Specification describes exactly what changes to a class make it incompatible with previous versions with regards to serialization. A technique that maximizes long term compatibility of class versions is to manually control their Stream Unique Identifier (SUID).
It's also recommended that a compatibility version number be added to the overall version number for the application. The version number must be made available to clients through the service API so that the BusinessDelegate base class can automatically retrieve it the first time a Business Delegate of each type is used. At that point, the version number in the client view JAR file is compared with the value returned from the service, and a difference in the compatibility number causes an exception to be thrown to the client. This mechanism can be seen in the BusinessDelegate code fragment in the source code.
This solution enables you to deploy new releases into production at leisure. A full regression test can be run on the newly deployed services before putting them into production. Care can be taken to assure that the deployment is perfect since there is no time pressure due to a production outage.
We have used the solution presented here to push a half-dozen new releases into production over the past six months at one of the top revenue-generating Web sites. At this particular site, 75% of the new releases of the services have been compatible builds for which this technique was successfully applied.
|John Jaster 12/26/03 05:34:50 PM EST|
with including sample code this article is pretty useless.
Big Data engines are powering a lot of service businesses right now. Data is collected from users from wearable technologies, web behaviors, purchase behavior as well as several arbitrary data points we’d never think of. The demand for faster and bigger engines to crunch and serve up the data to services is growing exponentially. You see a LOT of correlation between “Cloud” and “Big Data” but on Big Data and “Hybrid,” where hybrid hosting is the sanest approach to the Big Data Infrastructure pro...
Jul. 24, 2016 07:45 PM EDT Reads: 1,842
A critical component of any IoT project is what to do with all the data being generated. This data needs to be captured, processed, structured, and stored in a way to facilitate different kinds of queries. Traditional data warehouse and analytical systems are mature technologies that can be used to handle certain kinds of queries, but they are not always well suited to many problems, particularly when there is a need for real-time insights.
Jul. 24, 2016 07:30 PM EDT Reads: 1,684
"My role is working with customers, helping them go through this digital transformation. I spend a lot of time talking to banks, big industries, manufacturers working through how they are integrating and transforming their IT platforms and moving them forward," explained William Morrish, General Manager Product Sales at Interoute, in this SYS-CON.tv interview at 18th Cloud Expo, held June 7-9, 2016, at the Javits Center in New York City, NY.
Jul. 24, 2016 07:30 PM EDT Reads: 2,044
With 15% of enterprises adopting a hybrid IT strategy, you need to set a plan to integrate hybrid cloud throughout your infrastructure. In his session at 18th Cloud Expo, Steven Dreher, Director of Solutions Architecture at Green House Data, discussed how to plan for shifting resource requirements, overcome challenges, and implement hybrid IT alongside your existing data center assets. Highlights included anticipating workload, cost and resource calculations, integrating services on both sides...
Jul. 24, 2016 07:00 PM EDT Reads: 1,924
"We are a well-established player in the application life cycle management market and we also have a very strong version control product," stated Flint Brenton, CEO of CollabNet,, in this SYS-CON.tv interview at 18th Cloud Expo, held June 7-9, 2016, at the Javits Center in New York City, NY.
Jul. 24, 2016 06:45 PM EDT Reads: 1,751
Unless your company can spend a lot of money on new technology, re-engineering your environment and hiring a comprehensive cybersecurity team, you will most likely move to the cloud or seek external service partnerships. In his session at 18th Cloud Expo, Darren Guccione, CEO of Keeper Security, revealed what you need to know when it comes to encryption in the cloud.
Jul. 24, 2016 05:00 PM EDT Reads: 2,347
We're entering the post-smartphone era, where wearable gadgets from watches and fitness bands to glasses and health aids will power the next technological revolution. With mass adoption of wearable devices comes a new data ecosystem that must be protected. Wearables open new pathways that facilitate the tracking, sharing and storing of consumers’ personal health, location and daily activity data. Consumers have some idea of the data these devices capture, but most don’t realize how revealing and...
Jul. 24, 2016 05:00 PM EDT Reads: 2,019
What are the successful IoT innovations from emerging markets? What are the unique challenges and opportunities from these markets? How did the constraints in connectivity among others lead to groundbreaking insights? In her session at @ThingsExpo, Carmen Feliciano, a Principal at AMDG, will answer all these questions and share how you can apply IoT best practices and frameworks from the emerging markets to your own business.
Jul. 24, 2016 04:15 PM EDT Reads: 1,542
Ask someone to architect an Internet of Things (IoT) solution and you are guaranteed to see a reference to the cloud. This would lead you to believe that IoT requires the cloud to exist. However, there are many IoT use cases where the cloud is not feasible or desirable. In his session at @ThingsExpo, Dave McCarthy, Director of Products at Bsquare Corporation, will discuss the strategies that exist to extend intelligence directly to IoT devices and sensors, freeing them from the constraints of ...
Jul. 24, 2016 03:45 PM EDT Reads: 1,723
You think you know what’s in your data. But do you? Most organizations are now aware of the business intelligence represented by their data. Data science stands to take this to a level you never thought of – literally. The techniques of data science, when used with the capabilities of Big Data technologies, can make connections you had not yet imagined, helping you discover new insights and ask new questions of your data. In his session at @ThingsExpo, Sarbjit Sarkaria, data science team lead ...
Jul. 24, 2016 03:30 PM EDT Reads: 894
Extracting business value from Internet of Things (IoT) data doesn’t happen overnight. There are several requirements that must be satisfied, including IoT device enablement, data analysis, real-time detection of complex events and automated orchestration of actions. Unfortunately, too many companies fall short in achieving their business goals by implementing incomplete solutions or not focusing on tangible use cases. In his general session at @ThingsExpo, Dave McCarthy, Director of Products...
Jul. 24, 2016 03:15 PM EDT Reads: 1,669
Traditional IT, great for stable systems of record, is struggling to cope with newer, agile systems of engagement requirements coming straight from the business. In his session at 18th Cloud Expo, William Morrish, General Manager of Product Sales at Interoute, outlined ways of exploiting new architectures to enable both systems and building them to support your existing platforms, with an eye for the future. Technologies such as Docker and the hyper-convergence of computing, networking and sto...
Jul. 24, 2016 03:00 PM EDT Reads: 1,008
WebRTC is bringing significant change to the communications landscape that will bridge the worlds of web and telephony, making the Internet the new standard for communications. Cloud9 took the road less traveled and used WebRTC to create a downloadable enterprise-grade communications platform that is changing the communication dynamic in the financial sector. In his session at @ThingsExpo, Leo Papadopoulos, CTO of Cloud9, discussed the importance of WebRTC and how it enables companies to focus...
Jul. 24, 2016 02:30 PM EDT Reads: 761
With an estimated 50 billion devices connected to the Internet by 2020, several industries will begin to expand their capabilities for retaining end point data at the edge to better utilize the range of data types and sheer volume of M2M data generated by the Internet of Things. In his session at @ThingsExpo, Don DeLoach, CEO and President of Infobright, discussed the infrastructures businesses will need to implement to handle this explosion of data by providing specific use cases for filterin...
Jul. 24, 2016 02:00 PM EDT Reads: 1,188
IoT generates lots of temporal data. But how do you unlock its value? You need to discover patterns that are repeatable in vast quantities of data, understand their meaning, and implement scalable monitoring across multiple data streams in order to monetize the discoveries and insights. Motif discovery and deep learning platforms are emerging to visualize sensor data, to search for patterns and to build application that can monitor real time streams efficiently. In his session at @ThingsExpo, ...
Jul. 24, 2016 01:30 PM EDT Reads: 811
Early adopters of IoT viewed it mainly as a different term for machine-to-machine connectivity or M2M. This is understandable since a prerequisite for any IoT solution is the ability to collect and aggregate device data, which is most often presented in a dashboard. The problem is that viewing data in a dashboard requires a human to interpret the results and take manual action, which doesn’t scale to the needs of IoT.
Jul. 24, 2016 12:00 PM EDT Reads: 1,880
Internet of @ThingsExpo has announced today that Chris Matthieu has been named tech chair of Internet of @ThingsExpo 2016 Silicon Valley. The 6thInternet of @ThingsExpo will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA.
Jul. 24, 2016 12:00 PM EDT Reads: 1,890
SYS-CON Events announced today the Enterprise IoT Bootcamp, being held November 1-2, 2016, in conjunction with 19th Cloud Expo | @ThingsExpo at the Santa Clara Convention Center in Santa Clara, CA. Combined with real-world scenarios and use cases, the Enterprise IoT Bootcamp is not just based on presentations but with hands-on demos and detailed walkthroughs. We will introduce you to a variety of real world use cases prototyped using Arduino, Raspberry Pi, BeagleBone, Spark, and Intel Edison. Y...
Jul. 24, 2016 11:00 AM EDT Reads: 1,313
Much of IT terminology is often misused and misapplied. Modernization and transformation are two such terms. They are often used interchangeably even though they mean different things and have very different connotations. Indeed, it is somewhat safe to assume that in IT any transformative effort is likely to also have a modernizing effect, and thus, we can see these as levels of improvement efforts. However, many businesses are being led to believe if they don’t transform now they risk becoming ...
Jul. 24, 2016 11:00 AM EDT Reads: 1,114
CenturyLink has announced that application server solutions from GENBAND are now available as part of CenturyLink’s Networx contracts. The General Services Administration (GSA)’s Networx program includes the largest telecommunications contract vehicles ever awarded by the federal government. CenturyLink recently secured an extension through spring 2020 of its offerings available to federal government agencies via GSA’s Networx Universal and Enterprise contracts. GENBAND’s EXPERiUS™ Application...
Jul. 24, 2016 11:00 AM EDT Reads: 1,795