Changeset - 25ea5b51c17a
[Not reviewed]
default
0 3 0
LordOfWar - 16 years ago 2009-09-17 21:19:52

removed avg_render_time from distrenjob structure
removed time_remaining from distrenjob structure
removed percent_done from distrenjob structure
-- values that don't need to be calculated by the server

-added total_render_time to distrenjob structure
-changed finish_frame() to increase total_render_time by the time it took the frame to render
3 files changed with 11 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -141,16 +141,13 @@ int start_data(){
 
  free(&buffer); // @TODO: Is this pointless?
 
}
 

	
 
/** Finish-Setter: Sets a frame to the "completed" status.*/
 
void finish_frame(struct distrenjob *head, struct distrenjob *distrenjob, int frame){
 
  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 */
 
  distrenjob->avg_render_time = ((distrenjob->avg_render_time*(distrenjob->completed_frames)) + distrenjob->frameset[frame].time_to_render)/(distrenjob->completed_frames + 1);
 
  distrenjob->total_render_time = distrenjob->total_render_time + (clock() - distrenjob[jobnum].frameset[frame].start_time);
 
  distrenjob->completed_frames++;
 
  distrenjob->assigned_frames--;
 
  general_info.total_frames_rendered++; // Increase total frames var for stats
 

	
 
  if(distrenjob->completed_frames == distrenjob->total_frames)
 
    {
src/server/distrenjob.c
Show inline comments
 
/*
 
  Copyright 2009 Nathan Phillip Brink <ohnobinki@ohnopublishing.net>
 
  
 

	
 
  This file is a part of DistRen.
 

	
 
  DistRen is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU Affero General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 
@@ -55,24 +55,22 @@ int distrenjob_new(struct distrenjob **d
 
  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->percent_done = 0;
 
  dj->completed_frames = 0;
 
  dj->assigned_frames = 0;
 
  dj->avg_render_time = 0;
 
  dj->time_remaining = (unsigned int)-1;
 
  dj->total_render_time = 0;
 
  dj->frameset = (struct frameset *)NULL; /*< @todo does frameset need to be initialized here? */
 
  
 

	
 
  return 0;
 
}
 

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

	
 
  xmlDocPtr xmldoc;
 
@@ -83,44 +81,44 @@ int xml2distrenjob(struct distrenjob **d
 

	
 
  int tmp;
 

	
 
  if(distrenjob_new(distrenjob))
 
    return 1;
 
  dj = *distrenjob;
 
  
 

	
 
  xmldoc = xmlReadFile(pathtoxml, NULL, XML_PARSE_PEDANTIC);
 
  if(!xmldoc)
 
    {
 
      /**
 
	 @todo are we able to depend on libxml2's printed errors or 
 
	 @todo are we able to depend on libxml2's printed errors or
 
	 channel them into syslog output (eventually)? Currently,
 
	 this error is repetitious of a libxml2 error printed on stderr
 
	 for us.
 
       */
 
      fprintf(stderr, "error reading XML file ``%s''\n", pathtoxml);
 

	
 
      distrenjob_free(distrenjob);
 
      return 2;
 
    }
 
  
 

	
 
  xmlxpathcontext = xmlXPathNewContext(xmldoc);
 
  xmlnode = xml_quickxpath(xmlxpathcontext, (xmlChar *)"/distren/job");
 
  if(!xmlnode)
 
    {
 
      distrenjob_free(distrenjob);
 
      return 3;
 
    }
 
  
 

	
 
  /*< @todo should we use xmlChar everywhere too? */
 
  dj->name = (char *)xmlGetProp(xmlnode, (xmlChar *)"name");
 
  if(!dj->name)
 
    {
 
      distrenjob_free(distrenjob);
 
      return 4;
 
    }
 
  
 

	
 
  /*< @todo validation needs to be done on usernames. e.g., currently, they shouldn't contain the '"' char  */
 
  dj->submitter = (char *)xmlGetProp(xmlnode, (xmlChar *)"submitter");
 
  if(!dj->submitter)
 
    {
 
      distrenjob_free(distrenjob);
 
      return 5;
src/server/distrenjob.h
Show inline comments
 
@@ -37,19 +37,17 @@ struct 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
 
  float percent_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 hours till the frame is re-assigned (if client computer crashes etc);
 
  time_t avg_render_time; // average seconds it took to render a frame
 
  time_t time_remaining; /*< estimated seconds remaining till render is complete (up to 49, 710 days) */
 
  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;
 
};
 

	
 

	
 

	
0 comments (0 inline, 0 general)