Hmm I have clustered a simple test MBean class at the moment it is called 
WorkflowControllerServiceMBean:  



  | public interface WorkflowControllerServiceMBean extends HAMBean {
  |    public void test();
  | }
  | 

I extracted the invoke() Method to a separate interface called HAMBean:


  | import org.jboss.system.ServiceMBean;
  | 
  | public interface HAMBean extends ServiceMBean {
  |     public Object invoke(Invocation invocation) throws Exception;
  | }
  | 

The implementation of the WorkflowControllerService just outputs some string to 
the console.


  | public class WorkflowControllerService 
  |          extends AbstractHAMBean implements WorkflowControllerServiceMBean {
  |     
  |     
  |     public void test() {
  |             System.out.println("TEST TEST TESTTEST TEST TESTTEST TEST 
TESTTEST TEST TEST");
  |     }       
  | 

The AbstractHAMBean class the WorkflowController extends contains the methods 
for setting up the method hashes and registering the service name hash in the 
Registry. It is more or less a copy and paste from 
http://cvs.sourceforge.net/viewcvs.py/jboss/jbosstest/src/main/org/jboss/test/jmx/ha/HAService.java?rev=1.2.6.1&view=markup


  | import org.jboss.ha.jmx.HAServiceMBeanSupport;
  | 
  | public class AbstractHAMBean extends HAServiceMBeanSupport implements 
HAMBean {
  | 
  |     protected Map marshalledInvocationMapping = null;
  | 
  |     public void startService() throws Exception {
  |             super.startService();                   
  |             log.info("Calculating Method Hashes for " + serviceName);
  |             Class[] ifs = this.getClass().getInterfaces();
  |             HashMap<Long,Method> tmpMap = new HashMap<Long,Method>();
  |             for (Class i : ifs) {
  |                     log.info("Adding Methods Interface: " + i.getName());
  |                     // Calulate method hashes for remote invocation
  |                     Method[] methods = i.getMethods();
  |                     for (int m = 0; m < methods.length; m++) {
  |                             Method method = methods[m];
  |                             Long hash = new 
Long(MarshalledInvocation.calculateHash(method));
  |                             //log.info("Adding Method: " + 
method.getName());
  |                             tmpMap.put(hash, method);
  |                     }
  |             }
  |             
  |             Registry.bind(new Integer(serviceName.hashCode()), serviceName);
  |             marshalledInvocationMapping = 
Collections.unmodifiableMap(tmpMap);
  |             
  |             log.info("Started MBean: " + serviceName);
  |     }
  | 
  |     public void stopService() throws Exception {
  |             super.stopService();
  |             Registry.unbind(new Integer(serviceName.hashCode()));
  |             log.info("Stopped MBean: " + serviceName);
  |     }
  | 
  |     /**
  |      * This is the "remote" entry point
  |      */ 
  |     public Object invoke(Invocation invocation) throws Exception {
  |             // Invoked remotely, inject method resolution
  |             if (invocation instanceof MarshalledInvocation) {
  |                     MarshalledInvocation mi = (MarshalledInvocation) 
invocation;
  |                     mi.setMethodMap(marshalledInvocationMapping);
  |             }
  |             Method method = invocation.getMethod();
  |             Object[] args = invocation.getArguments();
  | 
  |             // Setup any security context (only useful if something checks 
it, this
  |             // impl doesn't)
  |             Principal principal = invocation.getPrincipal();
  |             Object credential = invocation.getCredential();
  |             SecurityAssociation.setPrincipal(principal);
  |             SecurityAssociation.setCredential(credential);
  | 
  |             // Dispatch the invocation
  |             try {
  |                     return method.invoke(this, args);
  |             } catch (InvocationTargetException e) {
  |                     Throwable t = e.getTargetException();
  |                     if (t instanceof Exception) {
  |                             throw (Exception) t;
  |                     } else {
  |                             throw new UndeclaredThrowableException(t, 
method.toString());
  |                     }
  |             } finally {
  |                     // Clear the security context
  |                     SecurityAssociation.clear();
  |             }
  |     } 
  | 
  | }
  | 



The associated jboss-service.xml looks like this:


  | <?xml version="1.0" encoding="UTF-8"?>
  | 
  | <server>
  | 
  |    <!-- Create JRMPHA proxy for our service -->
  |    <mbean code="org.jboss.proxy.generic.ProxyFactoryHA" 
name="arsenal.at:service=ProxyFactoryHA,name=WorkflowControllerFactory,protocol=jrmpha">
  |       <!-- Use the default partition -->
  |       <depends 
optional-attribute-name="PartitionObjectName">jboss:service=DefaultPartition</depends>
  | 
  |       <!-- Use the standard JRMPInvoker from conf/jboss-service.xml -->
  |       <depends 
optional-attribute-name="InvokerName">jboss:service=invoker,type=jrmpha</depends>
  | 
  |       <!-- The load balancing policy -->
  |       <attribute 
name="LoadBalancePolicy">org.jboss.ha.framework.interfaces.RoundRobin</attribute>
  | 
  |       <!-- We depend on the HA-JNDI naming service -->
  |       <depends>jboss:service=HAJNDI</depends>      
  |       
  |       <!-- The target MBean -->
  |       <depends 
optional-attribute-name="TargetName">arsenal.at:service=WorkflowController</depends>
  | 
  |       <!-- Where to bind the proxy -->
  |       <attribute name="JndiName">WorkflowController</attribute>
  | 
  |       <!-- The interface exposed to the client -->
  |       <attribute 
name="ExportedInterface">at.arsenal.spirit.services.workflow.WorkflowControllerServiceMBean</attribute>
  | 
  |       <!-- Client side behaviour -->
  |       <attribute name="ClientInterceptors">
  |           <interceptors>
  |              
<interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
  |              
<interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
  |           </interceptors>
  |       </attribute>
  |    </mbean>
  | 
  |   <mbean 
code="at.arsenal.spirit.services.workflow.WorkflowControllerService" 
name="arsenal.at:service=WorkflowController">
  |       <depends>jboss:service=HAJNDI</depends>      
  |   </mbean>
  | </server>
  | 

The .sar with the MBean is deployed with farming on several nodes. Associated 
farm-service.xml: 


  | <?xml version="1.0" encoding="UTF-8"?>
  | <server>
  |     <mbean code="org.jboss.ha.framework.server.FarmMemberService"
  |             name="jboss:service=FarmMember,PartitionName=DefaultPartition">
  |                 
<depends>jboss:service=${jboss.partition.name:DefaultPartition}</depends>    
  |         <attribute name="PartitionName">DefaultPartition</attribute>
  |         <attribute name="ScanPeriod">5000</attribute>
  |         <attribute name="URLs">farm/</attribute>
  |          <attribute name="FilterInstance"
  |                 
attributeClass="org.jboss.deployment.scanner.DeploymentFilter"
  |                 serialDataType="javaBean">
  |                 <property name="prefixes">#,%,\,,.,_$</property>
  |                 <property 
name="suffixes">#,$,%,.BAK,.old,.orig,.rej,.bak,.sh,\,v,~</property>
  |                 <property 
name="matches">.make.state,.nse_depinfo,CVS,CVS.admin,RCS,RCSLOG,SCCS,TAGS,core,tags</property>
  |         </attribute>
  |         <attribute 
name="URLComparator">org.jboss.deployment.scanner.PrefixDeploymentSorter</attribute>
  |         <attribute 
name="Deployer">jboss.system:service=MainDeployer</attribute>             
  |     </mbean>
  | </server>
  | 

Thats the configuration which showed the behavior with all replicants 
disappearing when one node is shut down. It would be great if you could give me 
a hint if something is wrong with this setup. Thanks  :-)


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

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


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to