trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lium...@apache.org
Subject [1/2] incubator-trafodion git commit: [TRAFODION-2480] monitor should not check hostname strictly
Date Tue, 21 Feb 2017 09:45:41 GMT
Repository: incubator-trafodion
Updated Branches:
  refs/heads/master d3509da65 -> 3fabd688d


[TRAFODION-2480] monitor should not check hostname strictly


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/001cc3a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/001cc3a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/001cc3a0

Branch: refs/heads/master
Commit: 001cc3a01d79a0ba91dfc5ce51dfea243fc33c52
Parents: 554cd32
Author: Eason <hfutmkby@gmail.com>
Authored: Mon Feb 13 15:22:42 2017 +0800
Committer: Eason <hfutmkby@gmail.com>
Committed: Mon Feb 13 15:22:42 2017 +0800

----------------------------------------------------------------------
 core/sqf/monitor/linux/pnode.cxx       |  2 +-
 core/sqf/monitor/linux/pnodeconfig.cxx | 54 +++++++++++++++++++++++++++--
 core/sqf/monitor/linux/pnodeconfig.h   |  1 +
 core/sqf/monitor/linux/shell.cxx       |  8 ++---
 4 files changed, 58 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/001cc3a0/core/sqf/monitor/linux/pnode.cxx
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/pnode.cxx b/core/sqf/monitor/linux/pnode.cxx
index d5c8555..e1f620a 100755
--- a/core/sqf/monitor/linux/pnode.cxx
+++ b/core/sqf/monitor/linux/pnode.cxx
@@ -2146,7 +2146,7 @@ CNode *CNodeContainer::GetNode(char *name )
 
     while (node)
     {
-        if ( strcmp( node->GetName(), name) == 0 )
+        if ( CPNodeConfigContainer::hostnamecmp( node->GetName(), name) == 0 )
         { 
             break;
         }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/001cc3a0/core/sqf/monitor/linux/pnodeconfig.cxx
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/pnodeconfig.cxx b/core/sqf/monitor/linux/pnodeconfig.cxx
index 6647601..f91c9d1 100755
--- a/core/sqf/monitor/linux/pnodeconfig.cxx
+++ b/core/sqf/monitor/linux/pnodeconfig.cxx
@@ -282,7 +282,7 @@ int CPNodeConfigContainer::GetPNid( char *nodename )
 
     for (int i = 0; i < pnodesCount_; i++ )
     {
-        if ( strcmp( pnodeConfig_[i]->GetName(), nodename ) == 0 )
+        if ( CPNodeConfigContainer::hostnamecmp( pnodeConfig_[i]->GetName(), nodename
) == 0 )
         {
             pnid = pnodeConfig_[i]->GetPNid();
         }
@@ -382,7 +382,7 @@ void CPNodeConfigContainer::GetSpareNodesConfigSet( const char *name
                             , spareNodeConfig->GetName()
                             , tempSpareSet.size() );
             }
-            if ( strcmp( pNodeconfig->GetName(), name ) == 0 )
+            if ( CPNodeConfigContainer::hostnamecmp( pNodeconfig->GetName(), name ) ==
0 )
             {
                 foundInSpareSet = true;
                 spareSet = tempSpareSet;
@@ -409,3 +409,53 @@ void CPNodeConfigContainer::GetSpareNodesConfigSet( const char *name
 
     TRACE_EXIT;
 }
+
+int CPNodeConfigContainer::hostnamecmp(const char *p_str1, 
+				       const char *p_str2)
+{
+  static bool sb_first_time = true;
+  static bool sb_strict_hostname_check = false;
+  if (sb_first_time) {
+    sb_first_time = false;
+    char *lv_envvar=getenv("MON_STRICT_HOSTNAME_CHECK");
+    
+    if (lv_envvar && (atoi(lv_envvar) == 1)) {
+      sb_strict_hostname_check = true;
+    }
+  }
+
+  if (!p_str1) return 1;
+  if (!p_str2) return 1;
+
+  int lv_ret = strcmp(p_str1, p_str2);
+  if (lv_ret == 0) {
+    return lv_ret;
+  }
+  if (sb_strict_hostname_check) {
+    return lv_ret;
+  }
+
+  char lv_str1_to_cmp[1024];
+  char lv_str2_to_cmp[1024];
+  memset(lv_str1_to_cmp, 0, 1024);
+  memset(lv_str2_to_cmp, 0, 1024);
+
+  char *lp_str1_dot = strchr((char *) p_str1, '.');
+  if (lp_str1_dot) {
+    memcpy(lv_str1_to_cmp, p_str1, lp_str1_dot - p_str1);
+  }
+  else {
+    strcpy(lv_str1_to_cmp, p_str1);
+  }
+
+  char *lp_str2_dot = strchr((char *) p_str2, '.');
+  if (lp_str2_dot) {
+    memcpy(lv_str2_to_cmp, p_str2, lp_str2_dot - p_str2);
+  }
+  else {
+    strcpy(lv_str2_to_cmp, p_str2);
+  }
+
+  return strcmp(lv_str1_to_cmp, lv_str2_to_cmp);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/001cc3a0/core/sqf/monitor/linux/pnodeconfig.h
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/pnodeconfig.h b/core/sqf/monitor/linux/pnodeconfig.h
index f4c7fb1..d4e59c2 100755
--- a/core/sqf/monitor/linux/pnodeconfig.h
+++ b/core/sqf/monitor/linux/pnodeconfig.h
@@ -38,6 +38,7 @@ public:
     CPNodeConfigContainer( void );
     ~CPNodeConfigContainer( void );
 
+    static int hostnamecmp(const char *p_str1, const char *p_str2);
     CPNodeConfig *AddPNodeConfig( int pnid, char *name, bool spare );
     void          DeletePNodeConfig( CPNodeConfig *pnodeConfig );
     inline CPNodeConfig *GetFirstPNodeConfig( void ) { return ( head_ ); }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/001cc3a0/core/sqf/monitor/linux/shell.cxx
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/shell.cxx b/core/sqf/monitor/linux/shell.cxx
index f4a754d..30be688 100755
--- a/core/sqf/monitor/linux/shell.cxx
+++ b/core/sqf/monitor/linux/shell.cxx
@@ -2144,7 +2144,7 @@ int get_pnid_by_node_name( char *node_name )
     pnodeConfig = ClusterConfig.GetFirstPNodeConfig();
     for ( ; pnodeConfig; pnodeConfig = pnodeConfig->GetNext() )
     {
-        if ( strcmp( node_name, pnodeConfig->GetName() ) == 0 )
+        if ( CPNodeConfigContainer::hostnamecmp( node_name, pnodeConfig->GetName() ) ==
0 )
         {
             return( pnodeConfig->GetPNid() );
         }
@@ -2286,7 +2286,7 @@ bool get_spare_set_state( char *node_name, STATE &spare_set_state
)
                                 , method_name, __LINE__, MyName
                                 , spareNodeConfig->GetName() );
 
-                if ( strcmp( spareNodeConfig->GetName(), node_name ) == 0 )
+                if ( CPNodeConfigContainer::hostnamecmp( spareNodeConfig->GetName(), node_name
) == 0 )
                 {
                     if ( trace_settings & TRACE_SHELL_CMD )
                         trace_printf( "%s@%d [%s] Skipping member node=%s\n"
@@ -2657,7 +2657,7 @@ int get_node_name( char *node_name )
     pnodeConfig = ClusterConfig.GetFirstPNodeConfig();
     for ( ; pnodeConfig; pnodeConfig = pnodeConfig->GetNext() )
     {
-        if ( strcmp( node_name, pnodeConfig->GetName() ) == 0 )
+        if ( CPNodeConfigContainer::hostnamecmp( node_name, pnodeConfig->GetName() ) ==
0 )
         {
             return( 0 );
         }
@@ -4713,7 +4713,7 @@ bool start_monitor( char *cmd_tail, bool warmstart, bool reintegrate
)
     bool nodeInConfig = false;
     for ( i = 0; i < NumNodes; i++ )
     {
-        if ( strcmp( mynode, PNode[i]) == 0 )
+        if ( CPNodeConfigContainer::hostnamecmp( mynode, PNode[i]) == 0 )
         {
             nodeInConfig = true;
             break;


Mime
View raw message