Пример #1
0
lListElem *cuser_get_via_gdi(sge_gdi_ctx_class_t *ctx, lList **answer_list, const char *name) 
{
   lListElem *ret = NULL;

   DENTER(TOP_LAYER, "cuser_get_via_gdi");

   if (name != NULL) {
      lList *gdi_answer_list = NULL;
      lEnumeration *what = NULL;
      lCondition *where = NULL;
      lList *cuser_list = NULL;

      what = lWhat("%T(ALL)", CU_Type);
      where = lWhere("%T(%I==%s)", CU_Type, CU_name, name);
      gdi_answer_list = ctx->gdi(ctx, SGE_USER_MAPPING_LIST, SGE_GDI_GET, 
                                &cuser_list, where, what);
      lFreeWhat(&what);
      lFreeWhere(&where);

      if (!answer_list_has_error(&gdi_answer_list)) {
         ret = lFirst(cuser_list);
      } else {
         answer_list_replace(answer_list, &gdi_answer_list);
      }
   } 

   DRETURN(ret);
}
/****** SCHEDD/order_remove_order_and_immediate()*******************************
*  NAME
*     order_remove_order_and_immediate() -- add a remove order for the job task
*
*  SYNOPSIS
*     int order_remove_order_and_immediate(lListElem *job, lListElem *ja_task,
                                 order_t *orders)
*
*  FUNCTION
*     Generates an order of type ORT_remove_immediate_job for the given job
*     task.  Also removes the ORT_start_job order for this task from the order
*     list.
*
*  INPUTS
*     lListElem *job       - The job to remove  (JB_Type)
*     lListElem *ja_task   - The task to remove (JAT_Type)
*     order_t *orders      - The order structurestructure  for this scheduler pass be removed
*
*  RESULT
*     int - Error code: 0 = OK, 1 = Errors
*
*  NOTES
*     MT-NOTE: order_remove_order_and_immediate() is MT safe
*
*******************************************************************************/
static void 
order_remove_order_and_immediate( lListElem *job, lListElem *ja_task, order_t *orders) 
{
   /* The possibility exists that this task is part of an array task, that it
    * already has earned an order to be scheduled, and that one or more other
    * tasks in this same job were not scheduled, resulting in this delete
    * order.  In this case, we have to remove the schedule order before we add
    * the delete order.  Otherwise, the qmaster will think we're trying to do
    * an ORT_remove_immediate_job on a non-idle task. */   

   /* Warning: we have a problem, if we send start orders during the dispatch run. We
    * might have started a array task of an immediate array job without verifying, that
    * the whole job can run
    */  
   lList *orderList = orders->jobStartOrderList;
   lCondition *where = lWhere("%T(%I==%u && %I==%u && %I==%u)", OR_Type,
                      OR_type, ORT_start_job,
                      OR_job_number, lGetUlong(job, JB_job_number),
                      OR_ja_task_number, lGetUlong(ja_task, JAT_task_number));
   lListElem *ep = lFindFirst (orderList, where);
   
   DENTER(TOP_LAYER, "order_remove_order_and_immediate");
   
   if (ep != NULL) {
      DPRINTF (("Removing job start order for job task "sge_u32"."sge_u32"\n",
                lGetUlong(job, JB_job_number),
                lGetUlong(ja_task, JAT_task_number)));
      lRemoveElem(orderList, &ep);
   }
   
   order_remove_immediate(job, ja_task, orders);
   lFreeWhere(&where);
   
   DEXIT;
}
/****** SCHEDD/remove_immediate_jobs()******************************************
*  NAME
*     remove_immediate_jobs() -- test for and remove immediate jobs which can't
*                                be scheduled
*
*  SYNOPSIS
*     int remove_immediate_jobs(lList *pending_job_list,
                                lList *running_job_list, order_t *orders)
*
*  FUNCTION
*     Goes through all jobs in the pending list to see if any are immediate and
*     not idle.  If any are, they are removed.  This is done by generating an
*     order of type ORT_remove_immediate_job.  If any array jobs are removed,
*     the running list is checked for tasks belonging to the job, which are
*     also removed.  This is done by removing the ORT_start_job orders and
*     adding an order of type ORT_remove_immediate_job.
*
*  INPUTS
*     lList *pending_job_list   - The list of pending jobs for this scheduler
*                                 pass (JB_Type)
*     lList *running_job_list   - The list of running jobs for this scheduler
*                                 pass (JB_Type)
*     order_t *orders           - The order structure for this scheduler pass
*
*  RESULT
*     int - Error code: 0 = OK, 1 = Errors -- always returns 0
*
*  NOTES
*     MT-NOTE: remove_immediate_jobs() is MT safe
*
*******************************************************************************/
int remove_immediate_jobs(lList *pending_job_list, lList *running_job_list, order_t *orders) 
{
   lListElem *next_job, *job, *ep; 
   lList* lp;

   DENTER (TOP_LAYER, "remove_immediate_jobs");

   next_job = lFirst (pending_job_list);
   
   while ((job = next_job)) {
      lCondition *where = NULL;
      next_job = lNext(job);
      
      /* skip non immediate .. */
      if (!JOB_TYPE_IS_IMMEDIATE(lGetUlong(job, JB_type))) {
         continue;
      }

      /* .. and non idle jobs */
      if ((lp = lGetList(job, JB_ja_tasks)) && 
            (ep = lFirst(lp)) && 
            lGetUlong(ep, JAT_status)==JIDLE) {
         continue;    
      }

      /* Prepare search condition for running list */
      where = lWhere("%T(%I==%u)", JB_Type, JB_job_number, lGetUlong(job, JB_job_number));
      
      /* Remove the job from the pending list */
      remove_immediate_job(pending_job_list, job, orders, 0);
      
      /* If the job also exists in the running list, we need to remove it there
       * as well since array jobs are all or nothing. */
      if ((job = lFindFirst(running_job_list, where)) != NULL) {
         remove_immediate_job(running_job_list, job, orders, 1);
      }
      
      lFreeWhere(&where);
   }

   DEXIT;
   return 0;
}
Пример #4
0
/*-------------------------------------------------------------------------*/
void updateQueueList(void)
{
   lList *qlp = NULL;
   lList *hl = NULL;
   lList *rl = NULL;
   lList *cl = NULL;
   lEnumeration *whatall = NULL;
   lCondition *where = NULL;
   static Boolean filter_on = False;
   
   DENTER(GUI_LAYER, "updateQueueList");

   cl = qmonMirrorList(SGE_CE_LIST);
   /*
   ** copy of host list
   */
   hl = lCopyList("HL", qmonMirrorList(SGE_EH_LIST));

   /* 
   **
   ** select a subset of the whole queue list (->where) 
   ** and get the list sorted 
   **
   */
#ifdef FIXME   
   where = lWhere("%T(%I!=%s)", QU_Type, QU_qname, QU_TEMPLATE);
   whatall = lWhat("%T(ALL)", QU_Type);
#else   
   whatall = lWhat("%T(ALL)", CQ_Type);
#endif  
   qlp = lSelect("SQL", qmonMirrorList(SGE_CQ_LIST), where, whatall); 
   lFreeWhere(&where);
   lFreeWhat(&whatall);

#ifdef FIXME
   /*
   ** additional filtering
   */
   rl = qmonQFilterRequest();
   if (rl) {
      if (!filter_on) {
         setButtonLabel(queue_customize, "@{Customize +}");
         filter_on = True;
      }
      match_queue(&qlp, rl, cl, hl);
   }  
   else {
      if (filter_on) {
         setButtonLabel(queue_customize, "@{Customize}");
         filter_on = False;
      }
   }
   
   /*
   ** sort the queues according to sequence number and alphabetically
   */
   lPSortList(qlp, "%I+ %I+ %I+", QU_seq_no, QU_qhostname, QU_qname);
#endif
   /*
   ** save the queue in hash table
   */
   qmonQueueHash(qlp, hl);

   qmonQueueSetPos(qlp);

   /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
   ** qlp must not be freed it is referenced in qmonHashQueue
   ** and freed there
   */
   
   DEXIT;
}
/* - -- -- -- -- -- -- -- -- -- -- -- -- -- -

   user_args - a cull list(UE_Type) of users
   acl_args - a cull list(US_Type) of acl

   returns 
      0 on success
      -1 on error

*/
int sge_client_add_user(
sge_gdi_ctx_class_t *ctx,
lList **alpp,
lList *user_args,
lList *acl_args 
) {
   lListElem *userarg, *aclarg;
   lList *acl=NULL, *answers=NULL;
   const char *acl_name, *user_name;
   lCondition *where;
   lEnumeration *what;
   u_long32 status;
   int already;

   DENTER(TOP_LAYER, "sge_client_add_user");

   what = lWhat("%T(ALL)", US_Type);

   for_each(aclarg,acl_args) {
      acl_name = lGetString(aclarg, US_name);
      where = lWhere("%T(%I==%s)", US_Type, US_name, acl_name);

      for_each(userarg, user_args) {

         already = 0;
         user_name=lGetString(userarg, UE_name);
   
         /* get old acl */
         answers = ctx->gdi(ctx, SGE_US_LIST, SGE_GDI_GET, &acl, where, what, false);
         lFreeList(&answers);

         if (acl && lGetNumberOfElem(acl) > 0) {
            if (!lGetSubStr(lFirst(acl), UE_name, user_name, US_entries)) {
               lAddSubStr(lFirst(acl), UE_name, user_name, US_entries, UE_Type);

               /* mod the acl */
               answers = ctx->gdi(ctx, SGE_US_LIST, SGE_GDI_MOD, &acl, 
                        NULL, NULL, false);   
            } else {
               already = 1;
            }
         } else {
            /* build new list */
            lAddElemStr(&acl, US_name, acl_name, US_Type);
            lAddSubStr(lFirst(acl), UE_name, user_name, US_entries, UE_Type);
            
            /* add the acl */
            answers = ctx->gdi(ctx, SGE_US_LIST, SGE_GDI_ADD, &acl, 
                     NULL, NULL, false);   
         }

         if (already) {
            status = STATUS_EEXIST;
            SGE_ADD_MSG_ID( sprintf(SGE_EVENT, MSG_GDI_USERINACL_SS, user_name, acl_name));
         }
         else {
            if ((status = lGetUlong(lFirst(answers), AN_status))!=STATUS_OK) {
               const char *cp;
            
               cp = lGetString(lFirst(answers), AN_text);
               if (cp) {
                  sprintf(SGE_EVENT, "%s", cp);
               }
               else {
                  SGE_ADD_MSG_ID( sprintf(SGE_EVENT, MSG_GDI_CANTADDTOACL_SS, user_name, acl_name));
               }
            } else {
               sprintf(SGE_EVENT, MSG_GDI_ADDTOACL_SS, user_name, acl_name);
            }
            lFreeList(&answers);
         }
         answer_list_add(alpp, SGE_EVENT, status, 
            ((status == STATUS_OK) ? ANSWER_QUALITY_INFO : ANSWER_QUALITY_ERROR));
         lFreeList(&acl);

      }
Пример #6
0
int main(int argc, char *argv[])
{
   lList *queuelist = NULL, *joblist = NULL;

   enum {
      MATCH_REQUEST,
      LOOP_JOBS_QUEUES
/*                              SUBWHERE */
   };
   int scene, fulfilled, numdiddeldum;

   lList *erglist = NULL;
   lListElem *job, *queue;
   lCondition *where = NULL;

   lEnumeration *w0, *w1, *nothing, *all;
   lList *queuecomplexes = NULL, *attributes = NULL;
   lListElem *attribute, *request;
   const char *operator;

   DENTER_MAIN(TOP_LAYER, "example2");

   if (argc != 3)
      usage();

   sscanf(argv[1], "%d", &scene);
   sscanf(argv[2], "%d", &numdiddeldum);

   /* neccessary for comfortable output  */
   lInit(nmv);

   queuelist = buildQueueList();
   printf("\n\nQUEUELIST\n\n");
   lWriteList(queuelist);

   COMPLEXLIST = buildComplexList();
   printf("\n\nCOMPLEXLIST\n\n");
   lWriteList(COMPLEXLIST);

   joblist = buildJobList(numdiddeldum);
   printf("\n\nJOBLIST\n\n");
   lWriteList(joblist);

   printf("\n******** BEGIN PROCESSING *********\n\n");

   switch (scene) {

   case MATCH_REQUEST:

      /* 
         find for each job in the joblist all queues that 
         suffer the request of this job 
         ( implemented with quick list functions )
       */

      for_each(job, joblist) {

         printf("\n-------------------------------"
                "-------------------------------\n");
         printf("*** job %s may get started in the following queues ***\n\n",
                lGetString(job, J_name));

         for_each(queue, queuelist) {
            if (matchRequest(lGetList(queue, Q_complexname),
                             lGetList(job, J_hardrequest))) {
               if (!erglist)
                  if (!(erglist = lCreateList("erglist", QueueT))) {
                     printf("case MATCH_REQUEST: lCreateList"
                            " failure\n");
                     exit(-1);
                  }
               lAppendElem(erglist, lCopyElem(queue));
            }
         }
         printf("\n\n**** ERGLIST ****\n\n");
         if (erglist) {
            lWriteList(erglist);
            lFreeList(&erglist);
            erglist = NULL;
         }
      }

      break;

   case LOOP_JOBS_QUEUES:

      /* 
         find for each job in the joblist all queues that 
         suffer the request of this job 
         ( implemented with mighty database-like functions )
       */

      for_each(job, joblist) {

         printf("\n--------------------------------------------------------------\n");
         printf("*** job %s may get started in the following queues ***\n\n",
                lGetString(job, J_name));

         for_each(queue, queuelist) {

            /*
               build a list of the complexes of the queue

               therefore: build a subset of the complex list 
               with the queues complex name list as a selector

               join the complex name list of the queue      
               ( join field: N_complexname) 
               with the global complex list                                         
               ( join field: C_name )

               select nothing from the queue's complex name list (w0)
               and only the attributes of the global complex list (w1)

               every valid combination is needed, so the 
               where parameter is NULL for both lists 
             */

            w0 = lWhat("%T(NONE)", ComplexNameT);       /* NIX */
            w1 = lWhat("%T(%I)", ComplexT, C_attribute);

            queuecomplexes = lJoin("queuecomplexes",
                 N_complexname, lGetList(queue, Q_complexname), NULL, w0,
                                   C_name, COMPLEXLIST, NULL, w1);

            lFreeWhat(&w0);
            lFreeWhat(&w1);

            /* 
               try to find a hard request of this job 
               that is not fulfilled by the queue's complexes
             */
            fulfilled = 1;

            for_each(request, lGetList(job, J_hardrequest)) {

               /* 
                  build a flat complex attribute list with only
                  these attributes of the request

                  this produces a attribute list of all complexes 
                */

               nothing = lWhat("%T(NONE)", lGetListDescr(queuecomplexes));
               all = lWhat("%T(ALL)", ComplexAttributeT);
               where = lWhere("%T( %I == %s )", ComplexAttributeT,
                              A_name,
                              lGetString(request, R_name));

               attributes = lJoinSublist("attributelist",
                              C_attribute, queuecomplexes, NULL, nothing,
                                         ComplexAttributeT, where, all);

               lFreeWhere(&where);
               lFreeWhat(&nothing);
               lFreeWhat(&all);

               /* 
                  if we get an empty list then the queue has 
                  no complex fulfilling the request of this job
                */
               /* 
                  right now the lJoinSublist function returns
                  an empty list (no elements) if there was no sublist
                */
               if (lGetNumberOfElem(attributes) == 0) {
                  fulfilled = 0;
                  break;        /* leave request loop */
               }

               /* 
                  if there are attributes the values of at least one
                  complex of the queue must fulfill the request
                */
               for_each(attribute, attributes) {

                  operator = lGetString(request, R_operator);

                  if (strcmp(operator, "==") == 0) {
                     fulfilled = (!strcmp(
                                          lGetString(attribute, A_value),
                                          lGetString(request, R_value)));

                  }
                  else if (strcmp(operator, "!=") == 0) {
                     fulfilled = (strcmp(
                                           lGetString(attribute, A_value),
                                           lGetString(request, R_value)));

                  }             /* else if .. ( for all operators ) */

                  if (fulfilled)
                     break;     /* leave attribute loop */
               }