Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Clustering Enterprise JavaBeans

As illustrated in Figure 25.21, in a nonclustered WebLogic Server environment, a client such as a servlet or JSP uses the Home interface of the EJBHome object to locate and create an instance of the bean (EJBObject). After receiving a reference to the bean instance, the client is then able to invoke the methods of the EJBObject via the bean's Remote interface.

As illustrated in Figure 25.22, in a WebLogic cluster environment, the load-balancing and failover mechanisms for EJBs, as well as RMI objects, are implemented using replica-aware stubs for the Home and Remote interfaces. These replica-aware stubs are generated through the compilation process of a cluster-aware EJB, as defined in the weblogic-ejb-jar.xml file. The weblogic.ejbc utility passes the cluster-aware interfaces through the rmic compiler, which then generates the replica-aware stubs for the respective EJB.

Figure 25.21Figure 25.21 The Home and Remote interfaces of an EJB in a nonclustered WebLogic Server environment.

Figure 25.22Figure 25.22 Creating and interacting with a clustered EJB.

NOTE

Replica-aware stubs for the RMI object are created explicitly using the command-line options to the rmic utility.

The following section describes the replica-aware stubs for the Home and Remote interfaces in more detail.

The Replica-Aware Home and Remote Stubs

When you deploy a clustered EJB to a clustered WebLogic Server, the replica-aware Home stub of the bean is bound to the server's local JNDI tree. The clustered server then updates the clusterwide JNDI tree by sending a JNDI announcement to other server members of the WebLogic cluster via a multicast broadcast message.

NOTE

Stateless session, stateful session, and entity EJBs can have replica-aware Home stubs.

When clients connect to a WebLogic cluster and look up a clustered EJB, they obtain a replica-aware stub for that EJBHome object. However, instead of representing a single EJBHome object, this replica-aware stub contains the following:

  • The logic required to locate the replicas (EJBHome objects) on any clustered server instance on which the EJB was deployed

  • The load-balancing logic for distributing the workload among those clustered server instances on which the replicas are located

  • The failover logic, to transparently retry the call to another replica, if the stub intercepts an exception

TIP

To ensure scalability and high availability for your clustered EJBs, you should deploy them homogeneously to your WebLogic cluster.

When a client invokes the create() method, the replica-aware Home stub routes the call to one of the EJBHome object replicas it is aware of via the replica handler. The replica then creates an instance of the bean and returns a replica-aware Remote (EJBObject) stub, which contains the logic to locate replicas (EJBObject objects) on any clustered server instance on which the EJB is deployed. However, unlike EJBHome objects, which can all use replica-aware Home stubs, only stateful and stateless session EJBs can leverage replica-aware Remote stubs.

The Load-Balancing and Failover Algorithms Employed by the Replica-Aware Stubs

Because all Home stubs are replica aware, the replica handler can provide the following load-balancing and failover algorithms for routing calls to the EJBHome object:

  • Round-robin load balancing—Is the default load-balancing strategy for replica-aware stubs if no algorithm is specified. This is a simple and predictable load-balancing strategy in which the replica handler cycles through a list of clustered server instances that host the target replicas for a specific stub.

  • Weight-based load balancing—Improves the round-robin strategy by allowing you to factor a pre-assigned weight between 1 and 100 to each clustered server. This weight value determines what proportion of the overall workload a server will bear relative to other servers. The higher the weight value, the more likely a server will be chosen by the replica handler. For example, you can assign a higher weight value to those servers that have a greater processing capability.

  • Random load balancing—Distributes replica requests randomly among targeted server hosts. This approach should be used only if the other load-balancing strategies do not meet your requirements and you have a homogeneous WebLogic cluster environment.

  • CAUTION

    The random load balancing algorithm does not guarantee an even distribution scheme across your servers because it is totally statistically based.

  • Parameter-based routing—Is a Call Router class created by a developer and associated with a replica-aware stub to provide custom parameter-based routing of your replica requests. The Call Router class is called before the replica request is invoked and passed the parameters of the request. The Call Router examines these parameters and returns the name of the server where the replica request should be made based on its programmed routing logic. See the BEA WebLogic Server documentation for more information on how to implement a Call Router class.

You can configure a cluster to use one of the preceding algorithms, with the exception of the parameter-based routing mechanism, using the Administration Console:

  1. From the left pane of the Administration Console, select the Clusters node.

  2. Select your cluster.

  3. On the Configuration, General tab, shown in Figure 25.23, perform the following tasks:

    • Default Load Algorithm—Select your load-balancing algorithm from the drop-down list.

    • Service Age Threshold—Enter a value that specifies the number of seconds by which the age of two conflicting services must differ before one is considered older than the other.

  4. Click Apply to save your changes.

Figure 25.23Figure 25.23 Selecting a load-balancing algorithm for EJB replicas.

The algorithm you select is maintained within the replica-aware stubs obtained for the clustered EJB objects.

WebLogic Server does not always perform load balancing for an EJB method call because it is more efficient to use a replica that is collocated with the Remote stub itself. This prevents additional overhead for calling a replica located on a remote server.

The Load-Balancing and Failover Mechanisms of Stateless Session Beans

By default, a stateless session bean's Home stub provides load balancing and failover for its method invocations to any clustered server where the bean is deployed. Because stateless session beans hold no state on behalf of their clients, stateless beans of the same type are identical in a WebLogic cluster. For this reason, a replica-aware Remote stub can also load-balance its method invocations to any clustered server where the bean is deployed.

By default, the Remote stub supports automatic failover of only those methods that occur after a method completes or if the method fails to connect to a server. If a method incurs a failure before it completes, the Remote stub does not automatically fail over the method invocation from one replica to another. Preventing automatic failover in this manner ensures a recovered method call is never able to duplicate persistent information, which could have been modified when the method initially failed.

If your stateless session bean contains idempotent methods, however, you can force the replica handler to retry a failed call without knowing whether the method actually completed on the failed server. Idempotent methods are those methods that typically do not persist their results and can be called repeatedly with the same arguments to produce the same result, irrespective of the location of the bean.

You can specify that a stateless session bean contains idempotent methods via the following clustering-descriptors in the bean's deployment descriptors:

  • At the bean level, you can set the stateless-bean-methods-are-idempotent parameter to true. This ensures automatic failover for all the methods of the bean.

  • At the method level, you can use the idempotent-methods deployment property.

NOTE

You do not need to specify the methods on the stateless session bean EJBHome object and read-only entity beans to be idempotent because they are automatically set to be idempotent by WebLogic Server.

The Load-Balancing and Failover Mechanisms of Stateful Session Beans

By default, a stateful session bean's Home stub provides load balancing and failover for its method invocations to any clustered server where the bean is deployed.

When the bean instance is created, however, the bean's hosting WebLogic Server selects a secondary WebLogic Server instance to host the replicated state of the EJB using the same rules as defined in replication groups for the HTTP Session state. The primary WebLogic Server hosts the actual instance of the bean. To minimize resource overhead, the secondary server stores only the replicated state of the primary bean for failover purposes; the secondary server does not create an instance of the bean. Replication groups were discussed earlier in this chapter.

The client receives a Remote stub that maintains a list of the primary and secondary server locations of the bean's state. However, all method calls to the bean are "pinned" to the primary state location; there is no load balancing of remote method calls. As a client modifies the primary state, the EJB container replicates the state from the primary to the secondary servers in the WebLogic cluster. This replication scheme is similar to that used by the HTTP session state and occurs immediately after the transaction commits or after each method invocation. To replicate the state of a stateful session EJB, ensure the bean is homogeneously deployed within the WebLogic cluster.

If the primary state location should fail, the secondary WebLogic Server creates a new bean instance using the replicated state, thus forming a new primary server location for the bean's method calls. The replica handler redirects subsequent requests to the bean to this new primary state. At the same time, a WebLogic Server is selected to hold the bean's replicated state (secondary), and the client's replica-aware Remote stub is updated with the new primary and secondary bean locations.

The Load-Balancing and Failover Mechanisms of Entity Beans

By default, an entity bean's Home stub provides load balancing and failover for its method invocations to any clustered server where the bean is deployed.

The load balancing and failover capabilities of the Remote stub depend on the read-write and read-only cache strategy employed by the entity bean as follows:

  • For read-write entity bean caches, the bean's remote method calls are "pinned" to the instance of the bean and cannot be load-balanced to other servers. Method calls fail over only if the request is made outside a transaction.

  • For read-only entity bean caches, each remote method call is load-balanced. However, failover does not automatically occur in the event of a recoverable call failure.

NOTE

The read-only cache exists locally on every server that accesses the bean.

  • + Share This
  • 🔖 Save To Your Account

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020