~ubuntu-branches/ubuntu/precise/torque/precise-updates

« back to all changes in this revision

Viewing changes to src/server/req_holdjob.c

  • Committer: Bazaar Package Importer
  • Author(s): Dominique Belhachemi
  • Date: 2010-05-17 20:56:46 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100517205646-yjsoqs5r1s9xpnu9
Tags: upstream-2.4.8+dfsg
ImportĀ upstreamĀ versionĀ 2.4.8+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
#include "server.h"
97
97
#include "credential.h"
98
98
#include "batch_request.h"
99
 
#include "job.h"
 
99
#include "pbs_job.h"
100
100
#include "work_task.h"
101
101
#include "pbs_error.h"
102
102
#include "log.h"
103
103
#include "acct.h"
104
104
#include "svrfunc.h"
 
105
#include "csv.h"
105
106
 
106
107
/* Private Functions Local to this file */
107
108
 
 
109
static void process_checkpoint_reply A_((struct work_task *));
108
110
static void process_hold_reply A_((struct work_task *));
109
111
 
110
112
/* Global Data Items: */
166
168
  char    *pset;
167
169
  int     rc;
168
170
  attribute temphold;
 
171
  attribute *pattr;
169
172
 
170
173
  pjob = chk_job_request(preq->rq_ind.rq_hold.rq_orig.rq_objname, preq);
171
174
 
199
202
  sprintf(log_buffer, msg_jobholdset, pset, preq->rq_user,
200
203
          preq->rq_host);
201
204
 
202
 
  if (pjob->ji_qs.ji_state == JOB_STATE_RUNNING)
 
205
  pattr = &pjob->ji_wattr[(int)JOB_ATR_checkpoint];
 
206
 
 
207
  if ((pjob->ji_qs.ji_state == JOB_STATE_RUNNING) &&
 
208
      ((pattr->at_flags & ATR_VFLAG_SET) &&
 
209
       ((csv_find_string(pattr->at_val.at_str, "s") != NULL) ||
 
210
        (csv_find_string(pattr->at_val.at_str, "c") != NULL) ||
 
211
        (csv_find_string(pattr->at_val.at_str, "enabled") != NULL))))
203
212
    {
204
213
 
205
214
    /* have MOM attempt checkpointing */
212
221
      }
213
222
    else
214
223
      {
215
 
      pjob->ji_qs.ji_substate = JOB_SUBSTATE_RERUN;
216
224
      pjob->ji_qs.ji_svrflags |=
217
 
        JOB_SVFLG_HASRUN | JOB_SVFLG_CHKPT;
 
225
        JOB_SVFLG_HASRUN | JOB_SVFLG_CHECKPOINT_FILE;
218
226
      job_save(pjob, SAVEJOB_QUICK);
 
227
      
 
228
      /* fill in log_buffer again, since relay_to_mom changed it */
 
229
      
 
230
      sprintf(log_buffer, msg_jobholdset, pset, preq->rq_user,
 
231
          preq->rq_host);
 
232
          
219
233
      LOG_EVENT(PBSEVENT_JOB, PBS_EVENTCLASS_JOB,
220
 
                pjob->ji_qs.ji_jobid, log_buffer);
 
234
        pjob->ji_qs.ji_jobid, log_buffer);
221
235
      }
222
236
    }
 
237
#ifdef ENABLE_BLCR
 
238
  else if (pjob->ji_qs.ji_state == JOB_STATE_RUNNING)
 
239
    {
 
240
    /*
 
241
     * This system is configured with BLCR checkpointing to be used,
 
242
     * but this Running job does not have checkpointing enabled,
 
243
     * so we reject the request
 
244
     */
 
245
 
 
246
    LOG_EVENT(
 
247
      PBSEVENT_JOB,
 
248
      PBS_EVENTCLASS_JOB,
 
249
      pjob->ji_qs.ji_jobid,
 
250
      log_buffer);
 
251
 
 
252
    req_reject(PBSE_IVALREQ, 0, preq, NULL,
 
253
        "job not held since checkpointing is expected but not enabled for job");
 
254
    }
 
255
#endif
223
256
  else
224
257
    {
225
258
    /* everything went well, may need to update the job state */
249
282
 
250
283
 
251
284
/*
 
285
 * req_checkpointjob - service the Checkpoint Job Request
 
286
 *
 
287
 */
 
288
 
 
289
void req_checkpointjob(
 
290
 
 
291
  struct batch_request *preq)
 
292
 
 
293
  {
 
294
  job    *pjob;
 
295
  int     rc;
 
296
  attribute *pattr;
 
297
 
 
298
  if ((pjob = chk_job_request(preq->rq_ind.rq_manager.rq_objname, preq)) == NULL)
 
299
    {
 
300
    return;
 
301
    }
 
302
 
 
303
  pattr = &pjob->ji_wattr[(int)JOB_ATR_checkpoint];
 
304
 
 
305
  if ((pjob->ji_qs.ji_state == JOB_STATE_RUNNING) &&
 
306
      ((pattr->at_flags & ATR_VFLAG_SET) &&
 
307
       ((csv_find_string(pattr->at_val.at_str, "s") != NULL) ||
 
308
        (csv_find_string(pattr->at_val.at_str, "c") != NULL) ||
 
309
        (csv_find_string(pattr->at_val.at_str, "enabled") != NULL))))
 
310
    {
 
311
    /* have MOM attempt checkpointing */
 
312
 
 
313
    if ((rc = relay_to_mom(pjob->ji_qs.ji_un.ji_exect.ji_momaddr,
 
314
                           preq, process_checkpoint_reply)) != 0)
 
315
      {
 
316
      req_reject(rc, 0, preq, NULL, NULL);
 
317
      }
 
318
    else
 
319
      {
 
320
      pjob->ji_qs.ji_svrflags |= JOB_SVFLG_CHECKPOINT_FILE;
 
321
      job_save(pjob, SAVEJOB_QUICK);
 
322
      LOG_EVENT(PBSEVENT_JOB, PBS_EVENTCLASS_JOB,
 
323
                pjob->ji_qs.ji_jobid, log_buffer);
 
324
      }
 
325
    }
 
326
  else
 
327
    {
 
328
    /* Job does not have checkpointing enabled, so reject the request */
 
329
 
 
330
    LOG_EVENT(
 
331
      PBSEVENT_JOB,
 
332
      PBS_EVENTCLASS_JOB,
 
333
      pjob->ji_qs.ji_jobid,
 
334
      log_buffer);
 
335
 
 
336
    req_reject(PBSE_IVALREQ, 0, preq, NULL, "job is not checkpointable");
 
337
    }
 
338
  }  /* END req_checkpointjob() */
 
339
 
 
340
 
 
341
 
 
342
 
 
343
/*
252
344
 * req_releasejob - service the Release Job Request
253
345
 *
254
346
 *  This request clears one or more holds on a job.
409
501
  struct batch_request *preq;
410
502
  int   newstate;
411
503
  int   newsub;
 
504
  attribute temphold;
 
505
  char *pset;
 
506
  int rc;
412
507
 
413
508
  svr_disconnect(pwt->wt_event); /* close connection to MOM */
414
509
 
424
519
    }
425
520
  else if (preq->rq_reply.brp_code != 0)
426
521
    {
 
522
 
 
523
    rc = get_hold(&preq->rq_ind.rq_hold.rq_orig.rq_attr, &pset, &temphold);
 
524
 
 
525
    if (rc == 0)
 
526
      {
 
527
      rc = job_attr_def[(int)JOB_ATR_hold].at_set(&pjob->ji_wattr[(int)JOB_ATR_hold],
 
528
           &temphold, DECR);
 
529
      }
 
530
 
427
531
    pjob->ji_qs.ji_substate = JOB_SUBSTATE_RUNNING;  /* reset it */
428
 
    pjob->ji_modified = 1;    /* indicate attributes changed     */
 
532
 
 
533
    pjob->ji_modified = 1;    /* indicate attributes changed */
429
534
    svr_evaljobstate(pjob, &newstate, &newsub, 0);
430
535
    svr_setjobstate(pjob, newstate, newsub); /* saves job */
431
536
 
445
550
    {
446
551
    /* record that MOM has a checkpoint file */
447
552
 
448
 
    /* Stupid PBS_CHKPT_MIGRATE is defined as zero therefore this code will never fire.
 
553
    /* PBS_CHECKPOINT_MIGRATEABLE is defined as zero therefore this code will never fire.
449
554
     * And if these flags are not set, start_exec will not try to run the job from
450
555
     * the checkpoint image file.
451
556
     */
452
557
 
453
 
    pjob->ji_qs.ji_svrflags |= JOB_SVFLG_CHKPT;
 
558
    pjob->ji_qs.ji_svrflags |= JOB_SVFLG_CHECKPOINT_FILE;
454
559
 
455
 
    if (preq->rq_reply.brp_auxcode)  /* chkpt can be moved */
 
560
    if (preq->rq_reply.brp_auxcode)  /* checkpoint can be moved */
456
561
      {
457
 
      pjob->ji_qs.ji_svrflags &= ~JOB_SVFLG_CHKPT;
458
 
      pjob->ji_qs.ji_svrflags |=  JOB_SVFLG_HASRUN | JOB_SVFLG_ChkptMig;
 
562
      pjob->ji_qs.ji_svrflags &= ~JOB_SVFLG_CHECKPOINT_FILE;
 
563
      pjob->ji_qs.ji_svrflags |=  JOB_SVFLG_HASRUN | JOB_SVFLG_CHECKPOINT_MIGRATEABLE;
459
564
      }
460
565
 
461
566
    pjob->ji_modified = 1;    /* indicate attributes changed     */
463
568
    svr_evaljobstate(pjob, &newstate, &newsub, 0);
464
569
    svr_setjobstate(pjob, newstate, newsub); /* saves job */
465
570
 
466
 
    account_record(PBS_ACCT_CHKPNT, pjob, (char *)0);  /* note in accounting file */
 
571
    account_record(PBS_ACCT_CHKPNT, pjob, "Checkpointed and held"); /* note in accounting file */
 
572
    reply_ack(preq);
 
573
    }
 
574
  }
 
575
 
 
576
/*
 
577
 * process_checkpoint_reply
 
578
 * called when a checkpoint request was sent to MOM and the answer
 
579
 * is received.  Completes the checkpoint request for running jobs.
 
580
 */
 
581
 
 
582
static void process_checkpoint_reply(
 
583
 
 
584
  struct work_task *pwt)
 
585
  {
 
586
  job       *pjob;
 
587
 
 
588
  struct batch_request *preq;
 
589
 
 
590
  svr_disconnect(pwt->wt_event); /* close connection to MOM */
 
591
 
 
592
  preq = pwt->wt_parm1;
 
593
  preq->rq_conn = preq->rq_orgconn;  /* restore client socket */
 
594
 
 
595
  if ((pjob = find_job(preq->rq_ind.rq_manager.rq_objname)) == (job *)0)
 
596
    {
 
597
    LOG_EVENT(PBSEVENT_DEBUG, PBS_EVENTCLASS_JOB,
 
598
              preq->rq_ind.rq_manager.rq_objname,
 
599
              msg_postmomnojob);
 
600
    req_reject(PBSE_UNKJOBID, 0, preq, NULL, msg_postmomnojob);
 
601
    }
 
602
  else
 
603
    {
 
604
    /* record that MOM has a checkpoint file */
 
605
 
 
606
    account_record(PBS_ACCT_CHKPNT, pjob, "Checkpointed"); /* note in accounting file */
467
607
    reply_ack(preq);
468
608
    }
469
609
  }