2 Replies Latest reply on Nov 2, 2004 7:36 AM by dave_dave

    MBean not running setCurrentState on restart

    dave_dave Newbie

      Hi,

      I am new to clustering and not sure if I am missing something - I have read the clustering documents, looked at the jboss source code and trawled the forum and cannot seem to figure this out.
      I have an Mbean that setCurrentState does not get called on when the node it is running on gets restarted. There are 2 nodes (N1 and N2) in the cluster.

      When Node N1 is shut down (after running in the cluster) and then restarted, the getCurrentState method runs on N2, but the setCurrentState method does not run on N1.
      Am I supposed to call the setCurrentState method myself in the startService method, am I missing a dependency in the xml file, or is there something wrong?

      The class is as follows :

      public class StateSyncTest extends HAServiceMBeanSupport implements HANotificationBroadcasterExampleMBean, HAPartition.HAPartitionStateTransfer {
      Collection receivedMessages = new LinkedList();
      String currentWord;


      protected void startService() throws Exception {
      super.startService();
      addNotificationListener(notificationListener,null, null);
      getMyPartition().subscribeToStateTransferEvents("BIGBOBBY", this);
      }


      private HAPartition getMyPartition() {
      HAPartition partition = null;
      try {
      InitialContext context = new InitialContext();
      partition = (HAPartition) context.lookup("/HAPartition/DefaultPartition");
      } catch (NamingException e) {
      log.error(e.getMessage());
      }
      return partition;
      }


      public Serializable getCurrentState() {
      return "initial state";
      }

      public void setCurrentState(Serializable newState) {
      setCurrentWord((String) newState);
      }

      public String getCurrentWord() {
      return currentWord;
      }

      public void setCurrentWord(String currentWord) {
      this.currentWord = currentWord;
      }
      }


      MY xml is as follows:

      jboss:service=DefaultPartition


      Thanks in advance,
      Dave_dave

        • 1. Re: MBean not running setCurrentState on restart
          dave_dave Newbie

          Sorry, the above should be:

          Class code is:

          public class StateSyncTest extends HAServiceMBeanSupport implements HANotificationBroadcasterExampleMBean, HAPartition.HAPartitionStateTransfer {
          Collection receivedMessages = new LinkedList();
          String currentWord;
          
          
          protected void startService() throws Exception {
          super.startService();
          addNotificationListener(notificationListener,null, null);
          getMyPartition().subscribeToStateTransferEvents("BIGBOBBY", this);
          }
          
          
          private HAPartition getMyPartition() {
          HAPartition partition = null;
          try {
          InitialContext context = new InitialContext();
          partition = (HAPartition) context.lookup("/HAPartition/DefaultPartition");
          } catch (NamingException e) {
          log.error(e.getMessage());
          }
          return partition;
          }
          
          
          public Serializable getCurrentState() {
          return "initial state";
          }
          
          public void setCurrentState(Serializable newState) {
          setCurrentWord((String) newState);
          }
          
          public String getCurrentWord() {
          return currentWord;
          }
          
          public void setCurrentWord(String currentWord) {
          this.currentWord = currentWord;
          }
          }


          My xml is as follows:

          <mbean code="com.mm.mbean.HANotificationBroadcasterExample" name="mm.mbean:service=HANotificationBroadcasterExample">
           <depends>jboss:service=DefaultPartition</depends>
           </mbean>



          I am using jboss 4.0.0 and java 1.5



          • 2. Re: MBean not running setCurrentState on restart
            dave_dave Newbie

            Does no reply mean that I am doing something that is obviously stupid?