shoal
  1. shoal
  2. SHOAL-14

MasterNode treats both master announcement and master response with the same message type

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: GMS
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      14

      Description

      This causes master node responses to be treated as announcements by recipients.

        Activity

        Hide
        shreedharganapathy added a comment -

        Mo Checked in the following fix for this issue:

        User: hamada
        Date: 2007/01/12 12:32:30

        Modified:
        shoal/gms/src/java/com/sun/enterprise/jxtamgmt/MasterNode.java

        Log:
        Fixes a bug where a master node response was typed as an announcement
        Hardens seq ID parsing to avoid potential bugs

        File Changes:

        Directory: /shoal/gms/src/java/com/sun/enterprise/jxtamgmt/
        ===========================================================

        File [changed]: MasterNode.java
        Url:
        https://shoal.dev.java.net/source/browse/shoal/gms/src/java/com/sun/enterprise/jxtamgmt/MasterNode.java?r1=1.14&r2=1.15
        Delta lines: +24 -17
        ---------------------
        — MasterNode.java 12 Jan 2007 19:24:13 -0000 1.14
        +++ MasterNode.java 12 Jan 2007 20:32:28 -0000 1.15
        @@ -95,7 +95,7 @@
        private static final String CCNTL = "CCNTL";
        private static final String MASTERNODE = "MN";
        private static final String MASTERQUERY = "MQ";

        • private static final String NODERESPONSE = "NR";
          + private static final String MASTERNODERESPONSE = "NR";
          private static final String NAMESPACE = "MASTER";
          private static final String NODEADV = "NAD";
          private static final String ROUTEADV = "ROUTE";
          @@ -237,10 +237,15 @@
          *
        • @param masterID the MasterNode ID
        • @return a message containing a MasterResponse element
          + * @param announcement if true, creates an anouncement type message,
          otherwise it creates a response type.
          */
        • private Message createMasterResponse(final ID masterID) {
          + private Message createMasterResponse(boolean announcement, final ID masterID) {
          final Message msg = createSelfNodeAdvertisement();
        • final MessageElement el = new StringMessageElement(MASTERNODE,
          masterID.toString(), null);
          + String type = MASTERNODE;
          + if (!announcement) { + type = MASTERNODERESPONSE; + }

          + final MessageElement el = new StringMessageElement(type,
          masterID.toString(), null);
          msg.addMessageElement(NAMESPACE, el);
          LOG.log(Level.FINER, "Created a Master Response Message with masterId =
          " + masterID.toString());
          return msg;
          @@ -389,7 +394,8 @@
          msgElement = msg.getMessageElement(NAMESPACE, VIEW_CHANGE_EVENT);
          if (msgElement != null) {
          if (seqID <= clusterViewManager.getMasterViewID()) {

        • LOG.log(Level.FINER, "Received an older clusterView
          sequence. discarding old view");
          + LOG.log(Level.FINER, MessageFormat.format("Received an
          older clusterView sequence {0}." +
          + " Current sequence :{1} discarding out of
          sequence view", seqID, clusterViewManager.getMasterViewID()));
          return true;
          }
          final ClusterViewEvent cvEvent =
          @@ -427,7 +433,7 @@
          */
          boolean processMasterNodeResponse(final Message msg,
          final SystemAdvertisement source) throws
          IOException {
          - MessageElement msgElement = msg.getMessageElement(NAMESPACE, NODERESPONSE);
          + MessageElement msgElement = msg.getMessageElement(NAMESPACE,
          MASTERNODERESPONSE);
          if (msgElement != null) {
          LOG.log(Level.FINE, "Received a MasterNode Response from Name :" +
          source.getName());
          clusterViewManager.setMaster(source, true);
          @@ -443,7 +449,8 @@
          if (msgElement != null) {
          long seqID = getLongFromMessage(msg, NAMESPACE, MASTERVIEWSEQ);
          if (seqID <= clusterViewManager.getMasterViewID()) {
          - LOG.log(Level.FINER, "Received an older clusterView
          sequence. discarding old view");
          + LOG.log(Level.FINER, MessageFormat.format("Received an
          older clusterView sequence {0}

          ." +
          + " Current sequence :

          {1} discarding out of
          sequence view", seqID, clusterViewManager.getMasterViewID()));
          return true;
          }
          final ClusterViewEvent cvEvent = (ClusterViewEvent)
          @@ -486,7 +493,8 @@
          if (msgElement != null && cvEvent != null) {
          long seqID = getLongFromMessage(msg, NAMESPACE, MASTERVIEWSEQ);
          if (seqID <= clusterViewManager.getMasterViewID()) {
          - LOG.log(Level.FINER, "Received an older clusterView
          sequence. discarding old view");
          + LOG.log(Level.FINER, MessageFormat.format("Received an
          older clusterView sequence {0}." +
          + " Current sequence :{1}

          discarding out of
          sequence view", seqID, clusterViewManager.getMasterViewID()));
          return true;
          }
          final ArrayList<SystemAdvertisement> newLocalView =
          @@ -538,7 +546,7 @@
          if (isMaster() && masterAssigned)

          { final ClusterViewEvent cvEvent = new ClusterViewEvent( ADD_EVENT, adv); - sendNewView(cvEvent, createMasterResponse(myID), true); + sendNewView(cvEvent, createMasterResponse(false, myID), true); clusterViewManager.notifyListeners(cvEvent); }

          return true;
          @@ -620,12 +628,6 @@
          if (processChangeEvent(msg, adv))

          { return; }

          -

        • // generate the node add event
        • if (isMaster() && masterAssigned) { - final ClusterViewEvent cvEvent = new ClusterViewEvent(ADD_EVENT, adv); - sendNewView(cvEvent, createMasterResponse(myID), true); - }

          } catch (IOException e)

          { e.printStackTrace(); LOG.log(Level.WARNING, e.getLocalizedMessage()); @@ -637,7 +639,7 @@ }

        private void announceMaster(SystemAdvertisement adv) {

        • final Message msg = createMasterResponse(adv.getID());
          + final Message msg = createMasterResponse(true, adv.getID());
          final ClusterViewEvent cvEvent = new ClusterViewEvent(
          ClusterViewEvents.MASTER_CHANGE_EVENT,
          adv);
          @@ -873,11 +875,16 @@
        • @param message The message to retrieve from
        • @param nameSpace The namespace of the element to get.
        • @param elemName Name of the Element.
        • * @return The long value
          + * @return The long value, -1 if element does not exist in the message
        • @throws NumberFormatException If the String does not contain a parsable int.
          */
          private static long getLongFromMessage(Message message, String nameSpace,
          String elemName) throws NumberFormatException
          Unknown macro: {+ String seqStr = message.getMessageElement(nameSpace, elemName).toString();+ if (seqStr != null) { return Long.parseLong(message.getMessageElement(nameSpace, elemName).toString()); + } else { + return -1; + } }

          }

        Show
        shreedharganapathy added a comment - Mo Checked in the following fix for this issue: User: hamada Date: 2007/01/12 12:32:30 Modified: shoal/gms/src/java/com/sun/enterprise/jxtamgmt/MasterNode.java Log: Fixes a bug where a master node response was typed as an announcement Hardens seq ID parsing to avoid potential bugs File Changes: Directory: /shoal/gms/src/java/com/sun/enterprise/jxtamgmt/ =========================================================== File [changed] : MasterNode.java Url: https://shoal.dev.java.net/source/browse/shoal/gms/src/java/com/sun/enterprise/jxtamgmt/MasterNode.java?r1=1.14&r2=1.15 Delta lines: +24 -17 --------------------- — MasterNode.java 12 Jan 2007 19:24:13 -0000 1.14 +++ MasterNode.java 12 Jan 2007 20:32:28 -0000 1.15 @@ -95,7 +95,7 @@ private static final String CCNTL = "CCNTL"; private static final String MASTERNODE = "MN"; private static final String MASTERQUERY = "MQ"; private static final String NODERESPONSE = "NR"; + private static final String MASTERNODERESPONSE = "NR"; private static final String NAMESPACE = "MASTER"; private static final String NODEADV = "NAD"; private static final String ROUTEADV = "ROUTE"; @@ -237,10 +237,15 @@ * @param masterID the MasterNode ID @return a message containing a MasterResponse element + * @param announcement if true, creates an anouncement type message, otherwise it creates a response type. */ private Message createMasterResponse(final ID masterID) { + private Message createMasterResponse(boolean announcement, final ID masterID) { final Message msg = createSelfNodeAdvertisement(); final MessageElement el = new StringMessageElement(MASTERNODE, masterID.toString(), null); + String type = MASTERNODE; + if (!announcement) { + type = MASTERNODERESPONSE; + } + final MessageElement el = new StringMessageElement(type, masterID.toString(), null); msg.addMessageElement(NAMESPACE, el); LOG.log(Level.FINER, "Created a Master Response Message with masterId = " + masterID.toString()); return msg; @@ -389,7 +394,8 @@ msgElement = msg.getMessageElement(NAMESPACE, VIEW_CHANGE_EVENT); if (msgElement != null) { if (seqID <= clusterViewManager.getMasterViewID()) { LOG.log(Level.FINER, "Received an older clusterView sequence. discarding old view"); + LOG.log(Level.FINER, MessageFormat.format("Received an older clusterView sequence {0}." + + " Current sequence :{1} discarding out of sequence view", seqID, clusterViewManager.getMasterViewID())); return true; } final ClusterViewEvent cvEvent = @@ -427,7 +433,7 @@ */ boolean processMasterNodeResponse(final Message msg, final SystemAdvertisement source) throws IOException { - MessageElement msgElement = msg.getMessageElement(NAMESPACE, NODERESPONSE); + MessageElement msgElement = msg.getMessageElement(NAMESPACE, MASTERNODERESPONSE); if (msgElement != null) { LOG.log(Level.FINE, "Received a MasterNode Response from Name :" + source.getName()); clusterViewManager.setMaster(source, true); @@ -443,7 +449,8 @@ if (msgElement != null) { long seqID = getLongFromMessage(msg, NAMESPACE, MASTERVIEWSEQ); if (seqID <= clusterViewManager.getMasterViewID()) { - LOG.log(Level.FINER, "Received an older clusterView sequence. discarding old view"); + LOG.log(Level.FINER, MessageFormat.format("Received an older clusterView sequence {0} ." + + " Current sequence : {1} discarding out of sequence view", seqID, clusterViewManager.getMasterViewID())); return true; } final ClusterViewEvent cvEvent = (ClusterViewEvent) @@ -486,7 +493,8 @@ if (msgElement != null && cvEvent != null) { long seqID = getLongFromMessage(msg, NAMESPACE, MASTERVIEWSEQ); if (seqID <= clusterViewManager.getMasterViewID()) { - LOG.log(Level.FINER, "Received an older clusterView sequence. discarding old view"); + LOG.log(Level.FINER, MessageFormat.format("Received an older clusterView sequence {0}." + + " Current sequence :{1} discarding out of sequence view", seqID, clusterViewManager.getMasterViewID())); return true; } final ArrayList<SystemAdvertisement> newLocalView = @@ -538,7 +546,7 @@ if (isMaster() && masterAssigned) { final ClusterViewEvent cvEvent = new ClusterViewEvent( ADD_EVENT, adv); - sendNewView(cvEvent, createMasterResponse(myID), true); + sendNewView(cvEvent, createMasterResponse(false, myID), true); clusterViewManager.notifyListeners(cvEvent); } return true; @@ -620,12 +628,6 @@ if (processChangeEvent(msg, adv)) { return; } - // generate the node add event if (isMaster() && masterAssigned) { - final ClusterViewEvent cvEvent = new ClusterViewEvent(ADD_EVENT, adv); - sendNewView(cvEvent, createMasterResponse(myID), true); - } } catch (IOException e) { e.printStackTrace(); LOG.log(Level.WARNING, e.getLocalizedMessage()); @@ -637,7 +639,7 @@ } private void announceMaster(SystemAdvertisement adv) { final Message msg = createMasterResponse(adv.getID()); + final Message msg = createMasterResponse(true, adv.getID()); final ClusterViewEvent cvEvent = new ClusterViewEvent( ClusterViewEvents.MASTER_CHANGE_EVENT, adv); @@ -873,11 +875,16 @@ @param message The message to retrieve from @param nameSpace The namespace of the element to get. @param elemName Name of the Element. * @return The long value + * @return The long value, -1 if element does not exist in the message @throws NumberFormatException If the String does not contain a parsable int. */ private static long getLongFromMessage(Message message, String nameSpace, String elemName) throws NumberFormatException Unknown macro: {+ String seqStr = message.getMessageElement(nameSpace, elemName).toString();+ if (seqStr != null) { return Long.parseLong(message.getMessageElement(nameSpace, elemName).toString()); + } else { + return -1; + } } }

          People

          • Assignee:
            hamada
            Reporter:
            shreedharganapathy
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: