Browse Source

Thor duplicate port check

Added a validation check to ensure that

a. no two thors have thor masters on the same node and share the same master port.
b. no two thors have thor slaves on the same node and share the same slave port.
The thor masterport and slaveport attributes are optional and are not generated by default. Empty master and slave ports also trigger
the validation error.

Fixes gh-1945

Signed-off-by: Sridhar Meda <sridhar.meda@lexisnexis.com>
Sridhar Meda 13 years ago
parent
commit
a12ee6a27b
1 changed files with 29 additions and 0 deletions
  1. 29 0
      initfiles/componentfiles/configxml/thor.xsl

+ 29 - 0
initfiles/componentfiles/configxml/thor.xsl

@@ -104,6 +104,35 @@
   </xsl:template>
 
   <xsl:template match="ThorCluster">
+    <xsl:variable name="masterport" select="@masterport"/>
+    <xsl:variable name="slaveport" select="@slaveport"/>
+    <xsl:variable name="masternode" select="ThorMasterProcess/@computer"/>
+    <xsl:for-each select="/Environment/Software/ThorCluster[@name!=string($process)]">
+      <xsl:variable name="thismasterport" select="@masterport"/>
+      <xsl:variable name="thisthor" select="@name"/>
+        <xsl:for-each select="ThorMasterProcess[@computer=$masternode]">
+          <xsl:if test="string($thismasterport)=string($masterport)">
+            <xsl:message terminate="yes">
+              There cannot be more than one ThorCluster ('<xsl:value-of select="$process"/>' and '<xsl:value-of select="$thisthor"/>') with the same thor master '"<xsl:value-of select="$masternode"/>' and same thor master port '<xsl:value-of select="$masterport"/>!
+            </xsl:message>
+          </xsl:if>
+        </xsl:for-each>
+    </xsl:for-each>
+
+    <xsl:for-each select="ThorSlaveProcess">
+      <xsl:variable name="slavenode" select="@computer"/>
+      <xsl:for-each select="/Environment/Software/ThorCluster[@name!=string($process)]">
+        <xsl:variable name="thisslaveport" select="@slaveport"/>
+        <xsl:if test="string($thisslaveport)=string($slaveport)">
+            <xsl:if test="count(ThorSlaveProcess[@computer=$slavenode]) > 0">
+              <xsl:message terminate="yes">
+                There cannot be more than one ThorCluster ('<xsl:value-of select="$process"/>' and '<xsl:value-of select="@name"/>') with the same thor slave '"<xsl:value-of select="$slavenode"/>' and thor slave port '<xsl:value-of select="$slaveport"/>'!
+              </xsl:message>
+          </xsl:if>
+        </xsl:if>
+      </xsl:for-each>
+    </xsl:for-each>
+
     <Thor>
       <xsl:attribute name="name">
         <xsl:value-of select="@name"/>