1 Reply Latest reply on Jun 18, 2008 9:41 AM by Damien

    Best way to get master node (HASingletonDeployer with Barrie

    Damien Newbie

      Hi all,

      I'm using Jboss AS 4.05GA and I was wondering how to contact the master node in order to add new schedules on a ScheduleProvider.

      I have 3 nodes in a Farm, and at one moment, there is only one node managing Schedules
      See my conf:


      <mbean code="com.myproject.business.mbean.MyDBScheduleProvider"
       name="com.myproject.business.mbean:service=MyDBScheduleProvider">
       <depends>com.myproject.business.mbean:service=MyScheduleManager</depends>
       <depends>com.myproject.business.mbean:service=TaskScheduler</depends>
       <depends >jboss:service=partition_prod</depends>
       <depends>jboss.ha:service=HASingletonDeployer,type=Barrier</depends>
       <depends>jboss.j2ee:module=lypsoEJB.jar,service=EJB3</depends>
       <attribute name="ScheduleManagerName">com.myproject.business.mbean:service=MyScheduleManager</attribute>
       <attribute name="DataSourceName">java:mysql-ds</attribute>
       <attribute name="SQLStatement">SELECT target, method_name, method_signature, start_date, period,
       repetitions, date_format FROM Schedule where start_date>NOW()</attribute>
       </mbean>
       <mbean code="com.myproject.business.mbean.TaskScheduler"
       name="com.myproject.business.mbean:service=TaskScheduler">
       <depends>jboss.j2ee:ear=lypso-0.5.9-SNAPSHOT.ear,jar=lypsoEJB.jar,name=WSListenerSessionBean,service=EJB3</depends>
       </mbean>
       <mbean code="com.myproject.business.mbean.MyScheduleManager"
       name="com.myproject.business.mbean:service=MyScheduleManager">
       <depends >jboss:service=partition_prod</depends>
       <attribute name="StartAtStartup">true</attribute>
      </mbean>


      I saw on other post, that is possible to get all IP address of a farm with getting property "CurrentView" from service jboss:service=default_partition, and taking the first, which is normaly the master node.
      Is it the right way on Jboss 4.05GA ?

        • 1. Re: Best way to get master node (HASingletonDeployer with Ba
          Damien Newbie

           

          MBeanServer server = MBeanServerLocator.locateJBoss();
          ClusterPartitionMBean cluster = (ClusterPartitionMBean) MBeanProxyExt.create(ClusterPartitionMBean.class, "jboss:service=default_partition", server);
           Vector<String> nodes = cluster.getCurrentView();
           String jnpNodes = new String("");
           for (String node : nodes) {
           jnpNodes+="jnp://"+node+",";
           }
          
           InitialContext ctx = new InitialContext();
           ctx.addToEnvironment(ctx.PROVIDER_URL, jnpNodes);
           MBeanServerConnection conn = (MBeanServerConnection) ctx.lookup("jmx/invoker/RMIAdaptor");
           conn.invoke(.....)


          Is it good ??