You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by su...@apache.org on 2017/07/03 17:03:16 UTC

[1/3] incubator-trafodion git commit: [TRAFODION-2664] Instance will be down when the zookeeper on name node has been down

Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 5899ba2e1 -> be7e21186


[TRAFODION-2664] Instance will be down when the zookeeper on name node has been down


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

Branch: refs/heads/master
Commit: 7e1408c5584ae587e4d1198fa0bcf95a4c43c2cc
Parents: c401633
Author: Eason <hf...@gmail.com>
Authored: Thu Jun 29 10:25:07 2017 +0800
Committer: Eason <hf...@gmail.com>
Committed: Thu Jun 29 10:25:07 2017 +0800

----------------------------------------------------------------------
 core/sqf/monitor/linux/zclient.cxx | 38 ++++++++++++++++++++-------------
 core/sqf/monitor/linux/zclient.h   |  1 +
 2 files changed, 24 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7e1408c5/core/sqf/monitor/linux/zclient.cxx
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/zclient.cxx b/core/sqf/monitor/linux/zclient.cxx
index 8525853..db604e4 100644
--- a/core/sqf/monitor/linux/zclient.cxx
+++ b/core/sqf/monitor/linux/zclient.cxx
@@ -472,6 +472,22 @@ void CZClient::CheckMyZNode( void )
     TRACE_EXIT;
 }
 
+int CZClient::zoo_exists_retry(zhandle_t *zh, const char *path, int watch, struct Stat *stat)
+{
+    int retries = 0;
+    int rc;
+    rc = zoo_exists(zh, path, watch, stat);
+
+    // retry when loss zconnection, this may caused by one zookeeper server down
+    while ( rc == ZCONNECTIONLOSS && retries < ZOOKEEPER_RETRY_COUNT)
+    {
+        sleep(ZOOKEEPER_RETRY_WAIT);
+        retries++;
+        rc = zoo_exists(zh, path, watch, stat);
+    }
+    return rc;
+}
+
 int CZClient::GetClusterZNodes( String_vector *nodes )
 {
     const char method_name[] = "CZClient::GetClusterZNodes";
@@ -500,7 +516,7 @@ int CZClient::GetClusterZNodes( String_vector *nodes )
                         , method_name, __LINE__, trafCluster.c_str() );
         }
         // Verify the existence of the parent ZCLIENT_CLUSTER_ZNODE
-        rc = zoo_exists( ZHandle, trafCluster.c_str( ), 0, &stat );
+        rc = zoo_exists_retry( ZHandle, trafCluster.c_str( ), 0, &stat );
         if ( rc == ZNONODE )
         {
             if (retries > 10)
@@ -565,7 +581,7 @@ int CZClient::GetZNodeData( string &monZnode, string &nodeName, int &pnid )
         trace_printf( "%s@%d monZnode=%s\n"
                     , method_name, __LINE__, monZnode.c_str() );
     }
-    rc = zoo_exists( ZHandle, monZnode.c_str( ), 0, &stat );
+    rc = zoo_exists_retry( ZHandle, monZnode.c_str( ), 0, &stat );
     if ( rc == ZNONODE )
     {
         // return the error
@@ -692,17 +708,9 @@ int CZClient::InitializeZClient( void )
     TRACE_ENTRY;
 
     int rc;
-    int retries = 0;
 
     rc = MakeClusterZNodes();
 
-    while ( rc != ZOK && retries < ZOOKEEPER_RETRY_COUNT)
-    {
-        sleep(ZOOKEEPER_RETRY_WAIT);
-        retries++;
-        rc = MakeClusterZNodes();
-    }
-
     if ( rc == ZOK )
     {
         rc = RegisterMyNodeZNode();
@@ -730,7 +738,7 @@ bool CZClient::IsZNodeExpired( const char *nodeName, int &zerr )
 
     zerr = ZOK;
 
-    rc = zoo_exists( ZHandle, monZnode.c_str( ), 0, &stat );
+    rc = zoo_exists_retry( ZHandle, monZnode.c_str( ), 0, &stat );
     if ( rc == ZNONODE )
     {
         expired = true;
@@ -800,7 +808,7 @@ int CZClient::MakeClusterZNodes( void )
     ss << zkRootNode_.c_str();
     string rootDir( ss.str( ) );
 
-    rc = zoo_exists( ZHandle, rootDir.c_str(), 0, &stat );
+    rc = zoo_exists_retry( ZHandle, rootDir.c_str(), 0, &stat );
     switch (rc)
     {
     case ZOK:
@@ -834,7 +842,7 @@ int CZClient::MakeClusterZNodes( void )
        << zkRootNodeInstance_.c_str();
     string instanceDir( ss.str( ) );
 
-    rc = zoo_exists( ZHandle, instanceDir.c_str( ), 0, &stat );
+    rc = zoo_exists_retry( ZHandle, instanceDir.c_str( ), 0, &stat );
     switch (rc)
     {
     case ZOK:
@@ -868,7 +876,7 @@ int CZClient::MakeClusterZNodes( void )
        << ZCLIENT_CLUSTER_ZNODE;
     string clusterDir( ss.str( ) );
 
-    rc = zoo_exists( ZHandle, clusterDir.c_str( ), 0, &stat );
+    rc = zoo_exists_retry( ZHandle, clusterDir.c_str( ), 0, &stat );
     switch (rc)
     {
     case ZOK:
@@ -1165,7 +1173,7 @@ int CZClient::SetZNodeWatch( string &monZnode )
         trace_printf( "%s@%d monZnode=%s\n"
                     , method_name, __LINE__, monZnode.c_str() );
     }
-    rc = zoo_exists( ZHandle, monZnode.c_str( ), 0, &stat );
+    rc = zoo_exists_retry( ZHandle, monZnode.c_str( ), 0, &stat );
     if ( rc == ZNONODE ||
          rc == ZCONNECTIONLOSS || 
          rc == ZOPERATIONTIMEOUT )

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7e1408c5/core/sqf/monitor/linux/zclient.h
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/zclient.h b/core/sqf/monitor/linux/zclient.h
index d6dc884..675275d 100644
--- a/core/sqf/monitor/linux/zclient.h
+++ b/core/sqf/monitor/linux/zclient.h
@@ -152,6 +152,7 @@ public:
     int     WatchNodeDelete( const char *nodeName );
 
 private:
+    int     zoo_exists_retry(zhandle_t *zh, const char *path, int watch, struct Stat *stat);
     void    CheckCluster( void );
     void    CheckMyZNode( void );
     int     GetClusterZNodes( String_vector *children );


[3/3] incubator-trafodion git commit: Merge [TRAFODION-2664] PR-1155 Instance will be down when the zookeeper on name node has been down

Posted by su...@apache.org.
Merge [TRAFODION-2664] PR-1155 Instance will be down when the zookeeper on name node has been down


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

Branch: refs/heads/master
Commit: be7e211866ceec00c66ec7cfff79ab6498051108
Parents: 5899ba2 e406680
Author: Suresh Subbiah <su...@apache.org>
Authored: Mon Jul 3 17:03:01 2017 +0000
Committer: Suresh Subbiah <su...@apache.org>
Committed: Mon Jul 3 17:03:01 2017 +0000

----------------------------------------------------------------------
 core/sqf/monitor/linux/zclient.cxx | 38 ++++++++++++++++++++-------------
 core/sqf/monitor/linux/zclient.h   |  1 +
 2 files changed, 24 insertions(+), 15 deletions(-)
----------------------------------------------------------------------



[2/3] incubator-trafodion git commit: change method function name to ZooExistRetry

Posted by su...@apache.org.
change method function name to ZooExistRetry


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

Branch: refs/heads/master
Commit: e406680639c25158216cf0566340ef873cb100c2
Parents: 7e1408c
Author: Eason <hf...@gmail.com>
Authored: Fri Jun 30 11:43:32 2017 +0800
Committer: Eason <hf...@gmail.com>
Committed: Fri Jun 30 11:43:32 2017 +0800

----------------------------------------------------------------------
 core/sqf/monitor/linux/zclient.cxx | 16 ++++++++--------
 core/sqf/monitor/linux/zclient.h   |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e4066806/core/sqf/monitor/linux/zclient.cxx
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/zclient.cxx b/core/sqf/monitor/linux/zclient.cxx
index db604e4..aca0a85 100644
--- a/core/sqf/monitor/linux/zclient.cxx
+++ b/core/sqf/monitor/linux/zclient.cxx
@@ -472,7 +472,7 @@ void CZClient::CheckMyZNode( void )
     TRACE_EXIT;
 }
 
-int CZClient::zoo_exists_retry(zhandle_t *zh, const char *path, int watch, struct Stat *stat)
+int CZClient::ZooExistRetry(zhandle_t *zh, const char *path, int watch, struct Stat *stat)
 {
     int retries = 0;
     int rc;
@@ -516,7 +516,7 @@ int CZClient::GetClusterZNodes( String_vector *nodes )
                         , method_name, __LINE__, trafCluster.c_str() );
         }
         // Verify the existence of the parent ZCLIENT_CLUSTER_ZNODE
-        rc = zoo_exists_retry( ZHandle, trafCluster.c_str( ), 0, &stat );
+        rc = ZooExistRetry( ZHandle, trafCluster.c_str( ), 0, &stat );
         if ( rc == ZNONODE )
         {
             if (retries > 10)
@@ -581,7 +581,7 @@ int CZClient::GetZNodeData( string &monZnode, string &nodeName, int &pnid )
         trace_printf( "%s@%d monZnode=%s\n"
                     , method_name, __LINE__, monZnode.c_str() );
     }
-    rc = zoo_exists_retry( ZHandle, monZnode.c_str( ), 0, &stat );
+    rc = ZooExistRetry( ZHandle, monZnode.c_str( ), 0, &stat );
     if ( rc == ZNONODE )
     {
         // return the error
@@ -738,7 +738,7 @@ bool CZClient::IsZNodeExpired( const char *nodeName, int &zerr )
 
     zerr = ZOK;
 
-    rc = zoo_exists_retry( ZHandle, monZnode.c_str( ), 0, &stat );
+    rc = ZooExistRetry( ZHandle, monZnode.c_str( ), 0, &stat );
     if ( rc == ZNONODE )
     {
         expired = true;
@@ -808,7 +808,7 @@ int CZClient::MakeClusterZNodes( void )
     ss << zkRootNode_.c_str();
     string rootDir( ss.str( ) );
 
-    rc = zoo_exists_retry( ZHandle, rootDir.c_str(), 0, &stat );
+    rc = ZooExistRetry( ZHandle, rootDir.c_str(), 0, &stat );
     switch (rc)
     {
     case ZOK:
@@ -842,7 +842,7 @@ int CZClient::MakeClusterZNodes( void )
        << zkRootNodeInstance_.c_str();
     string instanceDir( ss.str( ) );
 
-    rc = zoo_exists_retry( ZHandle, instanceDir.c_str( ), 0, &stat );
+    rc = ZooExistRetry( ZHandle, instanceDir.c_str( ), 0, &stat );
     switch (rc)
     {
     case ZOK:
@@ -876,7 +876,7 @@ int CZClient::MakeClusterZNodes( void )
        << ZCLIENT_CLUSTER_ZNODE;
     string clusterDir( ss.str( ) );
 
-    rc = zoo_exists_retry( ZHandle, clusterDir.c_str( ), 0, &stat );
+    rc = ZooExistRetry( ZHandle, clusterDir.c_str( ), 0, &stat );
     switch (rc)
     {
     case ZOK:
@@ -1173,7 +1173,7 @@ int CZClient::SetZNodeWatch( string &monZnode )
         trace_printf( "%s@%d monZnode=%s\n"
                     , method_name, __LINE__, monZnode.c_str() );
     }
-    rc = zoo_exists_retry( ZHandle, monZnode.c_str( ), 0, &stat );
+    rc = ZooExistRetry( ZHandle, monZnode.c_str( ), 0, &stat );
     if ( rc == ZNONODE ||
          rc == ZCONNECTIONLOSS || 
          rc == ZOPERATIONTIMEOUT )

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e4066806/core/sqf/monitor/linux/zclient.h
----------------------------------------------------------------------
diff --git a/core/sqf/monitor/linux/zclient.h b/core/sqf/monitor/linux/zclient.h
index 675275d..ea9bca3 100644
--- a/core/sqf/monitor/linux/zclient.h
+++ b/core/sqf/monitor/linux/zclient.h
@@ -152,7 +152,7 @@ public:
     int     WatchNodeDelete( const char *nodeName );
 
 private:
-    int     zoo_exists_retry(zhandle_t *zh, const char *path, int watch, struct Stat *stat);
+    int     ZooExistRetry(zhandle_t *zh, const char *path, int watch, struct Stat *stat);
     void    CheckCluster( void );
     void    CheckMyZNode( void );
     int     GetClusterZNodes( String_vector *children );