1 Reply Latest reply on Nov 22, 2004 2:18 PM by xavierpayne2

    JBoss Clustering Rocks! But How do I get the Partition Name

    xavierpayne2

      First I want to say that the for Pay documentation (the entire suite) is freakin awesome and many of the posts I see in the forums could easily be answered by ponying up the dough for the entire documentation suite.

      In one day I was able to get a pretty good understanding of JBoss clustering and how it would impact my current components. Although our for pay docs were on 3.2 they applied to 4.0 rather well.

      Although the Pay docs regarding clustering were pretty sparse on technical (i.e. Code type stuff, Especially JMS) I found the forums and wiki filled the slack quite well. Between the three I was able to port our entire Infrastructure (about 15 entity beans, 30 Stateless Session beans, and 10 JMX services) from a JBoss 3.2.3 Standalone configuration to JBoss 4.0 Utilizing clustering (by myself) in only two weeks. Not only is it ported but it all ACTUALLY WORKS!

      The beauty is 99% of the changes were simple additions to the deployment descriptors (Excellent documentation for ejbs and entities) Although you may want to add a comment about the entities Requiring Remote interfaces in order to be cluster aware... That threw me and the error message was very vague. The forums saved me on that one.
      Other changes were updating our ant scripts to drop various wars and jars into the appropriate clustering directories. We also hade a few Lookups in our service locators change slightly for HA. The biggest change was needing to deploy one of our services as an HA Singleton since it does alot of local caching. The Wiki and the forums saved my life.
      the author of this post: http://www.jboss.org/index.html?module=bb&op=viewtopic&t=55794
      did an awesome job with his HASingleton how-to. I'd recommend posting his message verbatim on your wiki.

      The best part is our Client code (which uses remote ejb calls and JMS) is oblivious to the fact that we are clustering at all! ZERO client side code changes were necessary!!!!!! (We just had to change ip and port information in our .properties file).

      In short I think the JBoss team has done a fan-freakin-tastic job at implementing clustering.

      (see why I'm called DashV? VERBOSE).

      I do have one question I haven't been able to find the answer to...

      Is there a way in code (like say a JMX Service MBean) to figure out what partition the code is deployed into... Our infrastructure (which is build on top of JBoss) is required to register with an external monitoring service. And as it is currently implemented the monitoring service thinks every seperate JBoss instance is a different peice of infrastructure (We have an MBean service that generates a Unique id that is registered with the monitor.) I'd like to be able to give it the unique ID that we already generate and also the partition name so that we can enhance the monitoring component to be able to distinguish that other JBoss instances in fact represent the same infrastructure when they belong to the same Partition. Would there be any problems with grabbing the Partition name in my existing MBean service and using it in this way? Certainly the container for the MBean must know which partition the MBean belongs to...

      Thanks in advance and thanks for all you've done already!

        • 1. Re: JBoss Clustering Rocks! But How do I get the Partition N
          xavierpayne2

          Well. I re-read the Clustering docs and although it didn't give me the answer to my question directly, it did give me some things to think about which led to a solution. I don't know that it's THEE solution but it seems to work OK.

          For anyone else whos wondering here's how I am getting the partition name. I basically lookup the HASingletonDeployer web service and ask it what the value is of the "PartitionName" attribute for the service.

          I think this is returning me the partition that that particular service is aware of. I don't think this will work should I decide to create SubPartitions within the same JBoss instance. But for now since I am only using 1 partition name per jboss instance I think that it will work ok...

          The code is below for those that are curious:

          The jar to have in your classpath is:
          JBOSS_HOME/lib/jboss-jmx.jar

          ...

          import javax.management.MBeanServer;
          import javax.management.MBeanServerFactory;
          import javax.management.ObjectName;

          ...

          private String clusterPartitionName = null;
          private ObjectName serviceName = null;
          private MBeanServer localServer = null;

          localServer = (MBeanServer)
          MBeanServerFactory.findMBeanServer(null).iterator().nex();

          serviceName =
          new ObjectName("jboss.ha:service=HASingletonDeployer");

          try
          {
          clusterPartitionName =
          localServer.getAttribute(serviceName, "PartitionName").toString();
          }
          catch(Exception e)
          {
          System.out.println("an Exception Occured getting the PartitionName");
          e.printStackTrace();
          }


          ...

          Hope this helps someone.