Changeset - 387c6b396ee5
[Not reviewed]
default
0 1 0
LordOfWar - 16 years ago 2009-07-05 19:55:01

finished status report generator to count the number of frames completed and update the int variable in the blendjob structure. Still need to add code to count the number of frames assigned and the percent done.

How do you round an interger to 2 decimal places?

moved possibility to secondary upload location to blendjob structure from the frameset structure... cause its not gonna change in between frames... it would just waste a ton of memory.

Still need to add more comments to the status report generator.
1 file changed with 15 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -12,109 +12,110 @@
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU Affero General Public License for more details.
 

	
 
  You should have received a copy of the GNU Affero General Public License
 
  along with DistRen.  If not, see <http://www.gnu.org/licenses/>.
 

	
 
*/
 

	
 
/* This file contains the code which both processes (renders) jobs as a slave, and the code which distributes frames to slaves after receiving them from the client portion of the codebase. */
 

	
 
 /* Just some notes -- Ethan Zonca
 
 * ++ Make data availible for other apps to parse
 
 * Server<==>Client Communication
 
 * Upload while rendering
 
 */
 

	
 

	
 
#include <stdio.h>
 
#include "execio.h"
 

	
 
// needs to be implemented
 
#include "options.h"
 

	
 
#include <confuse.h>
 

	
 
#define max 100
 
// maximum number of stored jobs in memory, per job type (lux/blend). Eventually we can dump this data to disk, or atleast the remainder not in memory...
 

	
 
int jobnum = 0;
 

	
 
int hcfjob; //highest consecutively finished job
 

	
 
int highest_jobnum; // The job number of the most recently created job, this is used when creating new jobs
 

	
 
// Structures for storing job information
 
// OOOOOOkay so we really need a struct for frameset rather than just an array, because we should track who each frame was sent out to. Please do this, someone! :D
 
struct {
 
  char *name;
 
  char *submitter;
 
  char *email;
 
  int priority;  // 1 is lowest, 10 is highest, 0 is done
 

	
 
  int percent_done;
 
  int completed_frames; // number of completed frames
 
  int total_frames; // how many frames are in the animation
 

	
 
  struct frameset **frameset; // What exactly is this now? hehe
 

	
 

	
 
  // For secondary upload location...
 
  char url;
 
  char login_name;
 
  char login_pass;
 
} blendjob[max];
 

	
 
// -- Matthew's handywork --
 
// struct for storing informaiton on each frame for a particular blender job
 
struct {
 
	int frame_num; // frame number to render
 
	char slave_name; // user that frame is assigned to
 
	int frame_status; // status of frame, 0= unassigned, 1= taken, 2= done
 

	
 
	// For secondary upload location...
 
	char url;
 
	char login_name;
 
	char login_pass;
 
} frameset[frame_count]; // Frame count is the frame number if the animation starts on zero... but animations start at frame 1
 
                         // Using this method to save memory, because if animation starts on a high frame number, it would waste a lot of RAM on empty structures
 
// -- end of Matthew's handywork --
 

	
 
struct {
 
  char *name;
 
  char *submitter;
 
  char *email;
 
  int priority;
 
  int mode; // 0 = Static Render, stop at Spp, or infinity if spp is null. Framerange is ignored || 1 = animation, stop at Spp and stay in framerange.
 
  int spp;
 
  struct frameset ** frameset;
 
} luxjob[max];
 

	
 

	
 

	
 

	
 
int main(int argc, char *argv[])
 
{
 

	
 
/* !!!!!!! Important notes !!!!!!!!!!!!
 

	
 
So, we need a common key. Maybe. Or we need to generate a key in registeruser() and get it to the client somehow.
 
If we use a common key, then we'll need different passphrases for each user, which would be kinda crazy. How can
 
we get a key generated on the server, and transferred to the client's distrend?
 

	
 
*/
 

	
 
  int cont = 1;
 
  struct distrend_listenset *listenset;
 
  struct distrend_config *config;
 
  distrend_do_config(argc, argv, &config);
 

	
 
  distrend_listen(&listenset, config);
 
  /* This is called the ``main loop'' */
 
  while(cont)
 
    {
 
      struct distren_action *action;
 

	
 
      distrend_accept(&action);
 
      cont = distrend_do(action);
 
      distrend_action_free(action);
 
    }
 

	
 
  distrend_unlisten(listenset);
 
  distrend_config_free(config);
 

	
 
  return 0;
 
@@ -293,103 +294,110 @@ int frame_finder(){
 
	short int done = 0;
 

	
 
	for(int priority = 10; priority >= 1; priority--){ // start the scan for the next job with the highest priority
 
		finder_jobnum = hcfjob + 1; // reset it to start scanning at first uncompleted job for the pass at each priority level
 

	
 
		while(finder_jobnum <= highest_jobnum){
 
			if(blendjob[finder_jobnum].priority = priority){  // looks for a job with the current priority value
 
				done = 1;									  // notice it starts by looking at the oldest job first
 
				break;
 
			}
 

	
 
			if(done = 1)  // If it has found a job with the current priority value, it will break out of the loop
 
				break;    // If none is found it goes to the next job to see if it is of the current priority value
 
			else
 
				finder_jobnum++;
 
		}
 

	
 
		if(done = 1) // if job has been found, it lets it out of the priority changer loop
 
			break;
 
	}
 

	
 
	while(your_frame <= (sframe - eframe)){ // Finds the frameset number with a frame that needs to be rendered
 
		if (blendjob[finder_jobnum].frameset[frameset_count].frame_status = 0)  // If frame that is not assigned has been found, frameset_count is not changed
 
			break;																// and frameset_count is used to give the frame number later in this funciton
 

	
 
		x++;  // If frame is assigned or done, it goes to next frame
 
	}
 

	
 
blendjob[jobnum].frameset[x].frame_status++; // sets the value of the frame to 2, which means its taken
 

	
 
your_frame = blendjob[jobnum].frameset[x].frame_num; //  Takes the frameset found in the while statement above, and extracts the frame number from it and assigns it to the int your_frame
 

	
 
if(your_frame = null)  // If that job had no open frames for some reason, run the status report generator so that
 
	status_report_generator();  //the job priority can be changed to 0
 

	
 
return your_frame; // your_frame is returned as the frame to be rendered
 
}
 

	
 
// This figures out how much of the job is done, where jobnum corresponds to the job number
 
// This uses pointers, so when it is run it updates certain values in memory
 
void status_report_generator(){
 
	int num1 = hcfjob+1; // to scan through jobs
 
	int num2 = 0;		 // to scan through frames
 

	
 
	if(blendjob[num1].priority = 0)  //If the job after the highest consecutively finished job is finished
 
		hcfjob+1;  // adds 1 to the highest consecutively finished job
 

	
 
	while(num1 <= highest_jobnum){
 
		if(blendjob[num1].frameset[num2].priority != 0){
 
		if(blendjob[num1].frameset[num2].priority != 0){ // If the job is not done, scan it
 

	
 
			int finished_frames = 0; // variable that counts the completed frames
 
			while(num2 <= blendjob[jobnum].total_frames){
 
				int finished_frames = 0;
 
				if(blendjob[jobnum].frameset[num2])
 
					finished_frames++;
 

	
 
				num2++;
 
			}
 
		}
 

	
 
		blendjob[num1].completed_frames = finished_frames;
 

	
 
		num1++;
 
	}
 

	
 
}
 

	
 
// This function makes the value of the frame 2, which means its completed.
 
void the_finisher(int frame){
 
	blendjob[jobnum].frameset[frame]++;
 
}
 

	
 
// Queuer: this function should add files to the queue
 
// Type: 0 = blender, 1 = luxrender
 
// jobnum is the current job number
 

	
 
void queue(int type, char *name, char *submitter, char *email, int priority, int mode, int spp, *frameset) {
 
  if(type == 1){
 
    blendjob[jobnum].name = name;
 
    blendjob[jobnum].submitter = submitter;
 
    blendjob[jobnum].email = email;
 
    blendjob[jobnum].priority = priority;
 
    blendjob[jobnum].frameset =  frameset;
 
  }
 
  if(type == 2){
 
    luxjob[jobnum].name = name;
 
    luxjob[jobnum].submitter = submitter;
 
    luxjob[jobnum].email = email;
 
    luxjob[jobnum].priority = priority;
 
    luxjob[jobnum].mode = mode;
 
    luxjob[jobnum].spp = spp;
 
    luxjob[jobnum].frameset = frameset;
 
    // handle lux modes somehow.
 
}
 
  else{
 
    // Throw error.
 
  }
 
jobnum++;
 
}
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 
/*
 
Slave execution code lies below
0 comments (0 inline, 0 general)