|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.
Amazon has gradually rolled out parts of its IoT offerings in the last year, but these are just the tip of the iceberg. In addition to optimizing their back-end AWS offerings, Amazon is laying the ground work to be a major force in IoT – especially in the connected home and office. Amazon is extending its reach by building on its dominant Cloud IoT platform, its Dash Button strategy, recently announced Replenishment Services, the Echo/Alexa voice recognition control platform, the 6-7 strategic...
Dec. 10, 2016 04:15 AM EST Reads: 571
According to Forrester Research, every business will become either a digital predator or digital prey by 2020. To avoid demise, organizations must rapidly create new sources of value in their end-to-end customer experiences. True digital predators also must break down information and process silos and extend digital transformation initiatives to empower employees with the digital resources needed to win, serve, and retain customers.
Dec. 10, 2016 04:15 AM EST Reads: 1,389
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...
Dec. 10, 2016 04:00 AM EST Reads: 5,318
IoT solutions exploit operational data generated by Internet-connected smart “things” for the purpose of gaining operational insight and producing “better outcomes” (for example, create new business models, eliminate unscheduled maintenance, etc.). The explosive proliferation of IoT solutions will result in an exponential growth in the volume of IoT data, precipitating significant Information Governance issues: who owns the IoT data, what are the rights/duties of IoT solutions adopters towards t...
Dec. 10, 2016 03:15 AM EST Reads: 500
Whether your IoT service is connecting cars, homes, appliances, wearable, cameras or other devices, one question hangs in the balance – how do you actually make money from this service? The ability to turn your IoT service into profit requires the ability to create a monetization strategy that is flexible, scalable and working for you in real-time. It must be a transparent, smoothly implemented strategy that all stakeholders – from customers to the board – will be able to understand and comprehe...
Dec. 10, 2016 02:15 AM EST Reads: 802
Complete Internet of Things (IoT) embedded device security is not just about the device but involves the entire product’s identity, data and control integrity, and services traversing the cloud. A device can no longer be looked at as an island; it is a part of a system. In fact, given the cross-domain interactions enabled by IoT it could be a part of many systems. Also, depending on where the device is deployed, for example, in the office building versus a factory floor or oil field, security ha...
Dec. 10, 2016 02:00 AM EST Reads: 643
An IoT product’s log files speak volumes about what’s happening with your products in the field, pinpointing current and potential issues, and enabling you to predict failures and save millions of dollars in inventory. But until recently, no one knew how to listen. In his session at @ThingsExpo, Dan Gettens, Chief Research Officer at OnProcess, discussed recent research by Massachusetts Institute of Technology and OnProcess Technology, where MIT created a new, breakthrough analytics model for s...
Dec. 10, 2016 01:30 AM EST Reads: 799
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
Dec. 10, 2016 01:00 AM EST Reads: 1,277
"We're a cybersecurity firm that specializes in engineering security solutions both at the software and hardware level. Security cannot be an after-the-fact afterthought, which is what it's become," stated Richard Blech, Chief Executive Officer at Secure Channels, in this SYS-CON.tv interview at @ThingsExpo, held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA.
Dec. 9, 2016 11:30 PM EST Reads: 1,163
In this strange new world where more and more power is drawn from business technology, companies are effectively straddling two paths on the road to innovation and transformation into digital enterprises. The first path is the heritage trail – with “legacy” technology forming the background. Here, extant technologies are transformed by core IT teams to provide more API-driven approaches. Legacy systems can restrict companies that are transitioning into digital enterprises. To truly become a lead...
Dec. 9, 2016 10:45 PM EST Reads: 582
Video experiences should be unique and exciting! But that doesn’t mean you need to patch all the pieces yourself. Users demand rich and engaging experiences and new ways to connect with you. But creating robust video applications at scale can be complicated, time-consuming and expensive. In his session at @ThingsExpo, Zohar Babin, Vice President of Platform, Ecosystem and Community at Kaltura, discussed how VPaaS enables you to move fast, creating scalable video experiences that reach your aud...
Dec. 9, 2016 10:00 PM EST Reads: 350
"Once customers get a year into their IoT deployments, they start to realize that they may have been shortsighted in the ways they built out their deployment and the key thing I see a lot of people looking at is - how can I take equipment data, pull it back in an IoT solution and show it in a dashboard," stated Dave McCarthy, Director of Products at Bsquare Corporation, in this SYS-CON.tv interview at @ThingsExpo, held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA.
Dec. 9, 2016 09:30 PM EST Reads: 1,292
What happens when the different parts of a vehicle become smarter than the vehicle itself? As we move toward the era of smart everything, hundreds of entities in a vehicle that communicate with each other, the vehicle and external systems create a need for identity orchestration so that all entities work as a conglomerate. Much like an orchestra without a conductor, without the ability to secure, control, and connect the link between a vehicle’s head unit, devices, and systems and to manage the ...
Dec. 9, 2016 08:00 PM EST Reads: 1,049
IoT is rapidly changing the way enterprises are using data to improve business decision-making. In order to derive business value, organizations must unlock insights from the data gathered and then act on these. In their session at @ThingsExpo, Eric Hoffman, Vice President at EastBanc Technologies, and Peter Shashkin, Head of Development Department at EastBanc Technologies, discussed how one organization leveraged IoT, cloud technology and data analysis to improve customer experiences and effici...
Dec. 9, 2016 06:45 PM EST Reads: 5,152
Everyone knows that truly innovative companies learn as they go along, pushing boundaries in response to market changes and demands. What's more of a mystery is how to balance innovation on a fresh platform built from scratch with the legacy tech stack, product suite and customers that continue to serve as the business' foundation. In his General Session at 19th Cloud Expo, Michael Chambliss, Head of Engineering at ReadyTalk, discussed why and how ReadyTalk diverted from healthy revenue and mor...
Dec. 9, 2016 06:15 PM EST Reads: 1,773
The 20th International Cloud Expo has announced that its Call for Papers is open. Cloud Expo, to be held June 6-8, 2017, at the Javits Center in New York City, brings together Cloud Computing, Big Data, Internet of Things, DevOps, Containers, Microservices and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding business opportunity. Submit your speaking proposal ...
Dec. 9, 2016 05:30 PM EST Reads: 2,384
The Internet of Things (IoT) promises to simplify and streamline our lives by automating routine tasks that distract us from our goals. This promise is based on the ubiquitous deployment of smart, connected devices that link everything from industrial control systems to automobiles to refrigerators. Unfortunately, comparatively few of the devices currently deployed have been developed with an eye toward security, and as the DDoS attacks of late October 2016 have demonstrated, this oversight can ...
Dec. 9, 2016 05:15 PM EST Reads: 1,488
You have great SaaS business app ideas. You want to turn your idea quickly into a functional and engaging proof of concept. You need to be able to modify it to meet customers' needs, and you need to deliver a complete and secure SaaS application. How could you achieve all the above and yet avoid unforeseen IT requirements that add unnecessary cost and complexity? You also want your app to be responsive in any device at any time. In his session at 19th Cloud Expo, Mark Allen, General Manager of...
Dec. 9, 2016 05:15 PM EST Reads: 1,905
Bert Loomis was a visionary. This general session will highlight how Bert Loomis and people like him inspire us to build great things with small inventions. In their general session at 19th Cloud Expo, Harold Hannon, Architect at IBM Bluemix, and Michael O'Neill, Strategic Business Development at Nvidia, discussed the accelerating pace of AI development and how IBM Cloud and NVIDIA are partnering to bring AI capabilities to "every day," on-demand. They also reviewed two "free infrastructure" pr...
Dec. 9, 2016 04:45 PM EST Reads: 1,330
As data explodes in quantity, importance and from new sources, the need for managing and protecting data residing across physical, virtual, and cloud environments grow with it. Managing data includes protecting it, indexing and classifying it for true, long-term management, compliance and E-Discovery. Commvault can ensure this with a single pane of glass solution – whether in a private cloud, a Service Provider delivered public cloud or a hybrid cloud environment – across the heterogeneous enter...
Dec. 9, 2016 04:45 PM EST Reads: 1,878