[jboss-user] [Clustering/JBoss] - Re: get partition(cluster)

bstansberry@jboss.com do-not-reply at jboss.com
Wed Mar 14 13:23:07 EDT 2007


I haven't looked at it carefully, but what you wrote seems valid. FYI, here's how org.jboss.ha.jmx.HAServiceMBeanSupport finds its partition.  I know this query works and finds the partition. This could be modified to exclude matching on an expected partition name, etc. 


  |    protected HAPartition findHAPartitionWithName(String name) throws Exception
  |    {
  |       log.debug("findHAPartitionWithName, name="+name);
  |       HAPartition result = null;
  |       QueryExp classEQ = Query.eq(Query.classattr(),
  |                Query.value(ClusterPartition.class.getName()));
  |       QueryExp matchPartitionName = Query.match(Query.attr("PartitionName"),
  |          Query.value(name));
  |       QueryExp exp = Query.and(classEQ, matchPartitionName);
  |       Set mbeans = this.getServer().queryMBeans(null, exp);
  |       if (mbeans != null && mbeans.size() > 0)
  |       {
  |          ObjectInstance inst = (ObjectInstance) (mbeans.iterator().next());
  |          ClusterPartitionMBean cp =
  |             (ClusterPartitionMBean) MBeanProxyExt.create(
  |                ClusterPartitionMBean.class,
  |                inst.getObjectName(),
  |                this.getServer());
  |          result = cp.getHAPartition();
  |       }
  | 
  |       if( result == null )
  |       {
  |          String msg = "Failed to find HAPartition with PartitionName="+name;
  |          throw new InstanceNotFoundException(msg);
  |       }
  |       return result;
  |    }

There's no general facility that lists all the deployed partitions; the JMX query approach is what you have to do.

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

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



More information about the jboss-user mailing list