Changeset - d7b349e0d490
[Not reviewed]
default
0 3 0
LordOfWar - 16 years ago 2009-09-18 20:51:08

-created hibernate in general_info and distrenjob structures
-implimented it into find_jobframe() and the functions that initialize the jobs variables
3 files changed with 8 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -45,24 +45,25 @@ struct distrend_config
 
  struct options_common *options;
 
  struct distrend_listen **listens; /*< Null terminated array of structs */
 
  char *datadir;
 
};
 

	
 
struct general_info {
 
  short int jobs_in_queue; //
 
  unsigned short int free_clients;
 
  unsigned short int rendering_clients;//
 
  unsigned short int total_finished_jobs; //
 
  unsigned int total_frames_rendered; //
 
  unsigned int highest_jobnum;
 
  short int hibernate;
 
} general_info;
 

	
 

	
 

	
 
/*
 
  internally defined funcs's prototypes
 
*/
 
void distrenjob_remove(struct distrenjob *head, struct distrenjob *bj);
 

	
 
struct distrenjob *distrenjob_get(struct distrenjob *head, jobnum_t jobnum);
 
void distrenjob_enqueue(struct distrenjob *head, struct distrenjob *job);
 
void mortition(struct distrenjob *head, struct distrenjob *job);
 
@@ -117,24 +118,25 @@ void distrend_unlisten()
 
}
 
/**
 
   This is probably just a placeholder for remotio
 
*/
 
void remotio_send_to_client()
 
{
 
	// I am futile!
 
}
 

	
 
/** Fill variables after crash / shutdown from XML dumps */
 
int start_data()
 
{
 
  general_info.hibernate = 0;
 
  struct stat buffer;
 
  if(stat(SYSCONFDIR "/data.xml", &buffer) == 0){
 

	
 
    // @TODO: retrieve total_finished_jobs and total_finished_frames from xml file
 

	
 
    fprintf(stderr,"Parsing XML files and restoring previous state...\n");
 
    return 1;
 
  }
 
  else{
 
    general_info.total_finished_jobs = 0;
 
    general_info.total_frames_rendered = 0;
 
    fprintf(stderr,"Can't find XML dump, starting up fresh.\n");
 
@@ -273,34 +275,37 @@ void change_job_priority(struct distrenj
 

	
 
/**
 
  Frame Finder: matches your computer up with a lovely frame to render
 
  TODO: Major issue here, the client needs to know the frame number, AND the job number!
 
  Notice that this function starts by looking at the oldest job first
 

	
 
	TODO: Link this up with the main() function to check if there are frames available or not and provide jobnum/framenum to the client
 

	
 
  @return 0 success, other: error
 
*/
 
int find_jobframe(struct distrenjob *head, struct distrenjob **job, struct frameset **frame)
 
{
 
  if(general_info.hibernate)
 
    return 1;
 

	
 
  unsigned int frame_counter;
 
  short int your_job_type;
 
  unsigned short int found;
 

	
 
  struct distrenjob *distrenjob_ptr;
 

	
 
  your_job_type = 0;
 
  found = 0;
 
  /* iterate through jobs from first to last */
 
  for(distrenjob_ptr = head->next; !found && !distrenjob_ptr; distrenjob_ptr = distrenjob_ptr->next)
 
  for(distrenjob_ptr = head->next; (!found && !distrenjob_ptr) && !distrenjob_ptr->hibernate; 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++;
 
	}
 

	
 
  if(!found)
 
    {
src/server/distrenjob.c
Show inline comments
 
@@ -52,24 +52,25 @@ int distrenjob_new(struct distrenjob **d
 
    }
 
  *distrenjob = dj;
 

	
 
  dj->next = NULL;
 
  dj->name = (char *)NULL;
 
  dj->submitter = (char *)NULL;
 
  dj->email = (char *)NULL;
 
  dj->jobnum = 0; /*< @todo there should be a central jobnum allocator and a way to save the maximum jobnumber allocated */
 
  dj->priority = 0;
 
  dj->completed_frames = 0;
 
  dj->assigned_frames = 0;
 
  dj->total_render_time = 0;
 
  dj->hibernate = 0;
 
  dj->frameset = (struct frameset *)NULL; /*< @todo does frameset need to be initialized here? */
 

	
 
  return 0;
 
}
 

	
 
/**
 
   writes struct from xml
 
*/
 
int xml2distrenjob(struct distrenjob **distrenjob, char *pathtoxml)
 
{
 
  struct distrenjob *dj;
 

	
src/server/distrenjob.h
Show inline comments
 
@@ -35,24 +35,25 @@ typedef unsigned int jobnum_t;
 
struct distrenjob {
 
  struct distrenjob *next; /*< next will be NULL unless if there is another distrenjob */
 
  short int type; // 1:Blender, 2:something else
 
  char *name;
 
  char *submitter;
 
  char *email; /*< This should be looked up based on the value of submitter, not stored in this struct */
 
  jobnum_t jobnum;
 
  int priority;  // 1 is lowest, 10 is highest, 0 means the job is done
 
  int completed_frames; // number of completed frames for stats/etc
 
  int assigned_frames; // number of assigned frames (that are not yet completed) for stats/etc
 
  int total_frames; // how many frames are in the animation for stats/etc (unassigned frames)
 
  int watchdog_forgiveness; // how many seconds till the frame is re-assigned (if client computer crashes etc);
 
  short int hibernate;
 
  time_t total_render_time; // total seconds of time spent on all the completed frames
 
  char *output_format; /*< currently is the file extention of the request output format. @todo make this mime-type based/not a string */
 
  struct frameset *frameset;
 
};
 

	
 

	
 

	
 
/**
 
   Frameset Structure
 
*/
 
enum framesetstatus
 
  {
0 comments (0 inline, 0 general)