Exemplo n.º 1
0
void
Wrapup( )
{
	struct rusage local_rusage;
	char notification[ BUFSIZ ];

	dprintf(D_FULLDEBUG, "Entering Wrapup()\n" );

	notification[0] = '\0';

	/* This HadErr business isn't well defined. There doesn't seem
		to be a clean way of representing the event of a
		pre-job startup initialization failure.  So, instead of trying
		to propogate the nonexistant JobStatus around to future
		code paths trying to clean up a mess specified by HadErr,
		we are simply going to EXCEPT(). HadErr only gets specified
		when either the std file can't be opened or the shadow
		cannot chdir() to the initialdir(often because of a
		permission/existance problem). */
	if( HadErr ) {
		/* dump the specific error if it has been determined */
		if (ErrBuf[0] != '\0') {
			EXCEPT("%s", ErrBuf);
		} else {
			EXCEPT("Couldn't set up std files or chdir to initialdir--"
				"probably a permissions error.");
		}
	} else {
		/* all event logging has been moved from handle_termination() to
		   log_termination()	--RR */
		handle_termination( Proc, notification, &JobStatus, NULL );
	}

	/* fill in the Proc structure's exit_status with JobStatus, so that when
	 * we call update_job_status the exit status is written into the job queue,
	 * so that the history file will have exit status information for the job.
	 * note that JobStatus is in BSD format, and Proc->exit_status is in POSIX
	 * int format, so we copy very carefully.  on most platforms the 2 formats
	 * are interchangeable, so most of the time we'll get intelligent results.
	 *    -Todd, 11/95
	*/
	memcpy(&(Proc->exit_status[0]),&JobStatus,sizeof((Proc->exit_status[0])));
	get_local_rusage( &local_rusage );
	update_job_status( &local_rusage, &JobRusage );


	/* log the event associated with the termination; pass local and remote
	   rusage for the run.  The total local and remote rusages for the job are
	   stored in the Proc --- these values were updated by update_job_status */
	log_termination (&local_rusage, &JobRusage);

	if( notification[0] ) {
		NotifyUser( notification, Proc );
	}
}
Exemplo n.º 2
0
void update_pool_status( bool *all_blocked , int * pending) {
  int i;
  int pend_count   = 0;
  *all_blocked = true;

  for (i=0; i < vector_get_size( job_pool ); i++) {
    block_job_type * job = vector_iget( job_pool , i );
    update_job_status( job );

    if (!job->running)
      pend_count++;
  }

  {
    hash_iter_type * iter = hash_iter_alloc( nodes );
    while (!hash_iter_is_complete( iter )) {
      const char * hostname = hash_iter_get_next_key( iter );
      const count_pair_type * count = hash_get( nodes , hostname );
      if (count->current < count->target)
        *all_blocked = false;
    }
  }
  *pending = pend_count;
}
Exemplo n.º 3
0
int grid2vanilla(int argc, char **argv)
{
    if(argc != 3) {
        fprintf(stderr, "Usage:\n"
                "  %s vanillafile gridfile\n", argv[0]);
        return 1;
    }

    ClassAd n_ad_van;
    if( ! load_classad_from_old_file(argv[1], n_ad_van) ) {
        die("Failed to parse vanilla class ad\n");
    }
    ClassAd n_ad_grid;
    if( ! load_classad_from_old_file(argv[2], n_ad_grid) ) {
        die("Failed to parse grid class ad\n");
    }

    // Get old (vanilla) cluster.proc
    int vcluster;
    if( ! n_ad_van.EvaluateAttrInt(ATTR_CLUSTER_ID, vcluster) ) {
        dprintf(D_ALWAYS, "Vanilla job lacks a cluster\n");
        return 1;
    }
    int vproc;
    if( ! n_ad_van.EvaluateAttrInt(ATTR_PROC_ID, vproc) ) {
        dprintf(D_ALWAYS, "Vanilla job lacks a proc\n");
        return 1;
    }

    // Get new (grid) cluster.proc
    int cluster;
    if( ! n_ad_grid.EvaluateAttrInt(ATTR_CLUSTER_ID, cluster) ) {
        dprintf(D_ALWAYS, "Grid job lacks a cluster\n");
        return 1;
    }
    int proc;
    if( ! n_ad_grid.EvaluateAttrInt(ATTR_PROC_ID, proc) ) {
        dprintf(D_ALWAYS, "Grid job lacks a proc\n");
        return 1;
    }

    // Right. That was a silly amount of prep work.

    // Update the original ad
    n_ad_van.EnableDirtyTracking();
    n_ad_van.ClearAllDirtyFlags();
    if( ! update_job_status( n_ad_van, n_ad_grid) ) {
        dprintf(D_ALWAYS, "Unable to update ad\n");
        return 1;
    }

    // Push the updates!
    push_dirty_attributes(n_ad_van, 0, 0);

    // Put a fork in the grid job.
    bool b = finalize_job(n_ad_van,cluster,proc,0,0);
    printf("Finalize attempt on %d.%d %s\n", cluster,proc,b?"succeeded":"failed");
    if( ! b ) {
        return 1;
    }

    // Yield the original job
    MyString errors;
    b = yield_job(n_ad_van,0,0,true, vcluster, vproc, &errors, MYID);
    printf("Yield attempt on %d.%d %s\n", vcluster, vproc, b?"succeeded":"failed");
    return b?0:1;
}