Github user zcorrea commented on a diff in the pull request:

    https://github.com/apache/trafodion/pull/1457#discussion_r171408158
  
    --- Diff: core/sqf/monitor/linux/zclient.cxx ---
    @@ -799,6 +896,67 @@ bool CZClient::IsZNodeExpired( const char *nodeName, 
int &zerr )
         return( expired );
     }
     
    +int CZClient::CreateMasterZNode(  const char *nodeName )
    +{
    +    const char method_name[] = "CZClient::CreateMasterZNode";
    +    TRACE_ENTRY;
    +
    +    int rc;
    +    int retries = 0;
    +    
    +    stringstream masterpath;
    +    masterpath.str( "" );
    +    masterpath << zkRootNode_.c_str() 
    +            << zkRootNodeInstance_.c_str() 
    +            << ZCLIENT_MASTER_ZNODE<< "/"
    +            << nodeName;
    +            
    +    string monZnode = masterpath.str( );
    +
    +    stringstream ss;
    +    ss.str( "" );
    +    ss <<nodeName << ":" << MyPNID;
    +    string monData = ss.str( ); 
    +
    +    if (trace_settings & (TRACE_INIT | TRACE_RECOVERY))
    +    {
    +        trace_printf( "%s@%d RegisterZNode(%s:%s)\n"
    +                    , method_name, __LINE__
    +                    , monZnode.c_str()
    +                    , monData.c_str() );
    +    }
    +
    +    rc = RegisterZNode( monZnode.c_str(), monData.c_str(), ZOO_EPHEMERAL );
    +    while ( ((rc == ZCONNECTIONLOSS) || (rc == ZOPERATIONTIMEOUT)) && 
retries < ZOOKEEPER_RETRY_COUNT)
    +    {
    +        sleep(ZOOKEEPER_RETRY_WAIT);
    +        retries++;
    +        rc = RegisterZNode( monZnode.c_str(), monData.c_str(), 
ZOO_EPHEMERAL );
    +    }
    +    
    +    if (rc != ZOK)
    +    {
    +        if (trace_settings & (TRACE_INIT | TRACE_RECOVERY))
    +        {
    +            trace_printf( "%s@%d Error (MasterMonitor) Create master node 
for %s with rc = %d)\n"
    +                    , method_name, __LINE__, monZnode.c_str( ), rc);
    +        }
    +        char buf[MON_STRING_BUF_SIZE];
    +        snprintf( buf, sizeof(buf)
    +                , "[%s], RegisterZNode(%s) failed with error %s\n"
    +                , method_name, monData.c_str(), zerror(rc) );
    +        mon_log_write(MON_ZCLIENT_CREATEMASTERZNODE, SQ_LOG_ERR, buf);
    +        return(rc); // Return the error
    --- End diff --
    
    Yes, good catch!


---

Reply via email to