# HG changeset patch # User Binki # Date 2009-09-17 16:28:34 # Node ID 2a5a620b64ea25f73f3b2f75ded4626ff5d72610 # Parent 73e1c0d6e315f579843156c0609dd5563368a5f1 frame_finder()=>find_jobfram(), enum framesetstatus, misc diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -45,17 +45,6 @@ struct distrend_config char *datadir; }; - - -/* - frame[frame] Status Assignments: - "NULL" - don't render me - "0" - canceled - "1" - unassigned - "2" - assigned to slave - "3" - completed by slave and uploaded -*/ - struct general_info { short int jobs_in_queue; // unsigned short int free_clients; @@ -153,7 +142,7 @@ int start_data(){ /** Finish-Setter: Sets a frame to the "completed" status.*/ void finish_frame(struct distrenjob *head, struct distrenjob *distrenjob, int frame){ - distrenjob->frameset[frame].status = 2; + distrenjob->frameset[frame].status = FRAMESETSTATUS_DONE; distrenjob->frameset[frame].time_to_render = (clock() - distrenjob[jobnum].frameset[frame].start_time); // Consider changing time-to-render to time-for-frame or something? /* TODO: calculating the average render time like this may have a small amount of error, because the number is truncated to an integer of seconds every time... does it matter? */ /* we could keep track of the total render time... would make calculation a lot easier and more accurate */ @@ -182,7 +171,7 @@ void mortition(struct distrenjob *head, sprintf(path_and_number, "stor/job%d/out/%d.%s", job->jobnum, (counter + job->frameset[0].num), job->output_format); if(stat(path_and_number, &buffer) != -1) { - job->frameset[counter].status = 0; + job->frameset[counter].status = FRAMESETSTATUS_UNASSIGNED; job->completed_frames--; isJobDone = 0; // if a missing frame is found, set isJobDone to false } @@ -227,7 +216,7 @@ void prepare_distrenjob(struct frameset counter2 = start_frame; for(counter = 0; counter <= (end_frame- start_frame + 1); counter++){ distrenjob->frameset[counter].num = counter2; - distrenjob->frameset[counter].status = 0; + distrenjob->frameset[counter].status = FRAMESETSTATUS_UNASSIGNED; counter2++; } @@ -268,9 +257,9 @@ void change_job_priority(struct distrenj struct distrenjob *current_job; struct distrenjob *prev_job = head; - if(job->frameset[0].status == 0){ // if job was not yet started + if(job->frameset[0].status == FRAMESETSTATUS_UNASSIGNED) + /* if job was not yet started */ distrenjob_enqueue(head, job); - } else{ // if job has already been started then place it before the jobs with the same priority // iterate through linked list of jobs for(current_job = head; current_job != NULL; current_job = current_job->next){ @@ -298,10 +287,9 @@ void change_job_priority(struct distrenj @return 0 success, other: error */ -/*@TODO: change frame_finder to job_finder */ -int frame_finder(struct distrenjob *head, struct distrenjob **job, struct frameset **frame) +int find_jobframe(struct distrenjob *head, struct distrenjob **job, struct frameset **frame) { - int your_frame; // your_frame is an integer value that will be given to the client as the frame number to render + int frame_counter; short int your_job_type; unsigned short int found; @@ -311,34 +299,30 @@ int frame_finder(struct distrenjob *head found = 0; /* iterate through jobs from first to last */ for(distrenjob_ptr = head->next; !found && !distrenjob_ptr; distrenjob_ptr = distrenjob_ptr->next) + for(frame_counter = 0; !found && frame_counter < distrenjob_ptr->total_frames; frame_counter ++) + if(distrenjob_ptr->frameset[frame_counter].status == FRAMESETSTATUS_UNASSIGNED) + { + found = 1; + your_job_type = distrenjob_ptr->type; + distrenjob_ptr->frameset[frame_counter].status = FRAMESETSTATUS_ASSIGNED; + distrenjob_ptr->frameset[frame_counter].start_time = clock(); + distrenjob_ptr->assigned_frames++; + } + + // end of while statement... job must be found or linked list must be ended to get out of here + if(!found) { - // while frame hasn't been found, and your_frame is less than the length of the frameset array - for(your_frame = 0; !found && your_frame < distrenjob_ptr->total_frames; your_frame++) - if(distrenjob_ptr->frameset[your_frame].status == 0) - { - found = 1; - your_job_type = distrenjob_ptr->type; - distrenjob_ptr->frameset[your_frame].status = 1; - distrenjob_ptr->frameset[your_frame].start_time = clock(); - distrenjob_ptr->assigned_frames++; - break; - } + fprintf(stderr, "No more jobs to render\n"); + return 1; } -// end of while statement... job must be found or linked list must be ended to get out of here - if(!found) - { - fprintf(stderr, "No more jobs to render\n"); - return 1; - } + // the actual frame number to be rendered by the client is start_frame + your_frame + *job = distrenjob_ptr; + *frame = &distrenjob_ptr->frameset[frame_counter]; - // the actual frame number to be rendered by the client is start_frame + your_frame - *job = distrenjob_ptr; - *frame = &distrenjob_ptr->frameset[your_frame]; - - /* should the job be removed now? ANSWER: well, if a computer decides not to return their frame then we lost our data... so its not done yet. */ - fprintf(stderr, "Job %d is finished, this is probably the place to call the job-removal function\n", distrenjob_ptr->jobnum); - /* @TODO: At this point, all slaves should be instructed to delete the source data for this job. */ + /* should the job be removed now? ANSWER: well, if a computer decides not to return their frame then we lost our data... so its not done yet. */ + fprintf(stderr, "Job %d is finished, this is probably the place to call the job-removal function\n", distrenjob_ptr->jobnum); + /* @TODO: At this point, all slaves should be instructed to delete the source data for this job. */ return 0; } @@ -364,7 +348,7 @@ void blend_frame_watchdog(struct distren If frame is not completed within the number of hours specified by watchdog_forgiveness Then change the frame status to unassigned */ - distrenjob_ptr->frameset[counter].status = 0; + distrenjob_ptr->frameset[counter].status = FRAMESETSTATUS_UNASSIGNED; } } @@ -521,7 +505,7 @@ int main(int argc, char *argv[]) /* If the client is idle, must be modified for climbing through linked list of clients (client->clientnum) */ if(clientstatus == CLIENTSTATUS_IDLE) { - int returnnum = frame_finder(&head, &job, &frame); // Finds a frame to render + int returnnum = find_jobframe(&head, &job, &frame); // Finds a frame to render if(returnnum) { fprintf(stderr,"No frames are available to render at this time. Idling...\n"); diff --git a/src/server/distrenjob.h b/src/server/distrenjob.h --- a/src/server/distrenjob.h +++ b/src/server/distrenjob.h @@ -56,10 +56,18 @@ struct distrenjob { /** Frameset Structure */ +enum framesetstatus + { + FRAMESETSTATUS_CANCELED, /*< The use has canceled this frame */ + FRAMESETSTATUS_UNASSIGNED, /*< The frame has not been assigned */ + FRAMESETSTATUS_ASSIGNED, /*< The frame has been assigned */ + FRAMESETSTATUS_DONE /*< The frame has completed rendering and the slave has returned the product to me */ + }; + struct frameset { int num; /*< frame number to render */ char slave_name; /*< user that frame is assigned to */ - int status; /*< status of frame, 0= unassigned, 1= taken, 2= done */ + enum framesetstatus status; /*< status of frame, 0= unassigned, 1= taken, 2= done */ clock_t start_time; /*< time the frame was started */ int time_to_render; /*< the total seconds it took to render the frame */ }; /* Frameset array is generated by status_report_generator() */