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

    https://github.com/apache/incubator-hawq/pull/58#discussion_r43374972
  
    --- Diff: 
src/backend/resourcemanager/resourcebroker/resourcebroker_LIBYARN_proc.c ---
    @@ -1267,29 +1267,76 @@ int RB2YARN_connectToYARN(void)
     
     int RB2YARN_registerYARNApplication(void)
     {
    -   int yarnres = FUNCTION_SUCCEEDED;
    +   int retry = 5;
    +   int yarnres = FUNCTION_SUCCEEDED, result = FUNCTION_SUCCEEDED;
    +
        yarnres = createJob(LIBYARNClient,
                                            YARNAppName.Str,
                                                YARNQueueName.Str,
                                                &YARNJobID);
    -   if ( yarnres != FUNCTION_SUCCEEDED ) {
    +   if ( yarnres != FUNCTION_SUCCEEDED )
    +   {
                elog(WARNING, "YARN mode resource broker failed to create 
application "
                                          "in YARN resource manager. %s",
                                          getErrorMessage());
    +           return yarnres;
        }
    -   else {
    -           elog(LOG, "YARN mode resource broker created job in YARN 
resource "
    -                             "manager %s as new application %s assigned to 
queue %s.",
    -                             YARNJobID,
    -                             YARNAppName.Str,
    -                  YARNQueueName.Str);
     
    -           ResBrokerStartTime = gettime_microsec();
    +   elog(LOG, "YARN mode resource broker created job in YARN resource "
    +                     "manager %s as new application %s assigned to queue 
%s.",
    +                     YARNJobID,
    +                     YARNAppName.Str,
    +                     YARNQueueName.Str);
    +
    +   /* check if hawq is registered successfully in Hadoop Yarn.
    +    * if not, kill application from Hadoop Yarn.
    +    */
    +   LibYarnApplicationReport_t *applicationReport = NULL;
    +   while (retry > 0)
    +   {
    +           result = getApplicationReport(LIBYARNClient, YARNJobID, 
&applicationReport);
    +           if (result != FUNCTION_SUCCEEDED || applicationReport == NULL)
    +           {
    +                   if (retry > 0) {
    +                           retry--;
    +                           usleep(5*1000*1000L);
    +                           continue;
    +                   } else {
    +                           elog(WARNING, "YARN mode resource broker failed 
to get application report, "
    +                                                     "so kill it from 
Hadoop Yarn.");
    +                           result = forceKillJob(LIBYARNClient, YARNJobID);
    +                           if (result != FUNCTION_SUCCEEDED)
    +                                   elog(WARNING, "YARN mode resource 
broker kill job failed.");
    +                           return FUNCTION_FAILED;
    +                   }
    +           }
     
    -           elog(LOG, "YARN mode resource broker registered new "
    -                             "YARN application. Start time stamp 
"UINT64_FORMAT,
    -                             ResBrokerStartTime);
    +           if (applicationReport->progress < 0.5)
    +           {
    +                   if (retry > 0) {
    +                           retry--;
    +                           usleep(5*1000*1000L);
    +                           continue;
    +                   } else {
    +                           elog(WARNING, "YARN mode resource broker failed 
to register itself in Hadoop Yarn."
    +                                                     "Got progress:%f, and 
try to kill application from Hadoop Yarn",
    +                                                     
applicationReport->progress);
    +                           result = forceKillJob(LIBYARNClient, YARNJobID);
    +                           if (result != FUNCTION_SUCCEEDED)
    +                                   elog(WARNING, "YARN mode resource 
broker kill job failed.");
    +                           return FUNCTION_FAILED;
    +                   }
    +           }
    +           else
    +                   break;
    --- End diff --
    
    Suggest to add a pair of brackets for break;


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to