[jboss-user] [Clustering/JBoss] - Wrong targets come to LoadBalancePolicy

kkrivopustov do-not-reply at jboss.com
Fri Apr 20 00:56:56 EDT 2007


Hello
I'm using cluster on JBoss 4.0.4.GA and I want to implement a custom load-balancing policy. Unfortunately I faced a problem with the wrong list of targets in FamilyClusterInfo. Below I'll try to explain the situation.
I have 2 EJB3 stateless beans FooBean and BarBean annotated with @Clustered(partition = "ShamrockPartition", loadBalancePolicy = MyLoadBalancePolicy.class)
The policy is simple:

  | public class MyLoadBalancePolicy extends FirstAvailableIdenticalAllProxies {
  | 
  |     public Object chooseTarget(FamilyClusterInfo clusterFamily) {
  |         return super.chooseTarget(clusterFamily);
  |     }
  | 
  |     public Object chooseTarget(FamilyClusterInfo clusterFamily, Invocation routingDecision) {
  |         System.out.println("Family: " + clusterFamily.getFamilyName() 
  |             + ", View: " + clusterFamily.getCurrentViewId() + ", Targets: " + clusterFamily.getTargets());
  |         return super.chooseTarget(clusterFamily, routingDecision);
  |     }
  | }
I deploy application onto 2 servers and then start them. A client is simply invokes each bean many times consequently. Here is the output:

  | Family: FooBeansocketShamrockPartition, View: 0, Targets: [InvokerLocator [socket://192.168.3.71:3873/], InvokerLocator [socket://192.168.3.65:3873/]]
  | Family: BarBeansocketShamrockPartition, View: 0, Targets: [InvokerLocator [socket://192.168.3.71:3873/]]
  | iteration 0 success
  | Family: FooBeansocketShamrockPartition, View: 0, Targets: [InvokerLocator [socket://192.168.3.71:3873/], InvokerLocator [socket://192.168.3.65:3873/]]
  | Family: BarBeansocketShamrockPartition, View: 0, Targets: [InvokerLocator [socket://192.168.3.71:3873/]]
  | iteration 1 success
  | Family: FooBeansocketShamrockPartition, View: 0, Targets: [InvokerLocator [socket://192.168.3.71:3873/], InvokerLocator [socket://192.168.3.65:3873/]]
  | Family: BarBeansocketShamrockPartition, View: 0, Targets: [InvokerLocator [socket://192.168.3.71:3873/]]
  | iteration 2 success
  | 
As you can see, there is always wrong targets for bean BarBean. If I restart servers, the situation changes, but usually one of the beans or both have wrong targets. 
The only thing which help is hot redeploy of the application, after that all beans have correct targets.

I've investigated a little and found that method FamilyClusterInfoImpl.updateClusterInfo() is executed with correct targets after each bean invocation and it updates the FamilyClusterInfo. 
But when FamilyClusterInfo is obtained from ClusteringTargetsRepository, it is updated again by old incorrect values. If I comment out the line (comment "should not happen: possible if redeploy after undeploy fails" is not mine)

  |          family.updateClusterInfo (targets, viewId); // should not happen: possible if redeploy after undeploy fails
  | 
everithing works fine and client output looks correct:

  | Family: FooBeansocketShamrockPartition, View: 0, Targets: [InvokerLocator [socket://192.168.3.71:3873/], InvokerLocator [socket://192.168.3.65:3873/]]
  | Family: BarBeansocketShamrockPartition, View: 0, Targets: [InvokerLocator [socket://192.168.3.71:3873/]]
  | iteration 0 success
  | Family: FooBeansocketShamrockPartition, View: -1211536571, Targets: [InvokerLocator [socket://192.168.3.71:3873/], InvokerLocator [socket://192.168.3.65:3873/]]
  | Family: BarBeansocketShamrockPartition, View: -1211536571, Targets: [InvokerLocator [socket://192.168.3.71:3873/], InvokerLocator [socket://192.168.3.65:3873/]]
  | iteration 1 success
  | Family: FooBeansocketShamrockPartition, View: -1211536571, Targets: [InvokerLocator [socket://192.168.3.71:3873/], InvokerLocator [socket://192.168.3.65:3873/]]
  | Family: BarBeansocketShamrockPartition, View: -1211536571, Targets: [InvokerLocator [socket://192.168.3.71:3873/], InvokerLocator [socket://192.168.3.65:3873/]]
  | iteration 2 success
  | 

I will appreciate very much any information regarding this...

Konstantin


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4039124#4039124

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4039124



More information about the jboss-user mailing list