Changeset - 96731e6c15f9
[Not reviewed]
default
0 3 0
ethanzonca - 16 years ago 2009-08-30 22:31:29

Fixed up some stuff, removed archaic code, etc
3 files changed with 19 insertions and 18 deletions:
0 comments (0 inline, 0 general)
TODO
Show inline comments
 
@@ -19,14 +19,13 @@ Master
 

	
 
Slave
 
 -Fix current bugs
 
*-Add calls to remoteio, once it works or even before it works
 
 -Add code to write arguments for exec_blender based on the contents of a job's xml file
 
*-Other XML-writing/reading
 
	+Parse XML file and toss data in blendjob struct
 
	+Update exec_blender() to use the struct rather than other vars
 
	+Update exec_blender() to use some struct info, maybe.
 
 -Add errorcatchers to return in libcurl functions, can we detect 404?
 
=-Make code more flexible for different types of jobs and operating systems (such as paths, libs, etc)
 
 -Add code to allow pausing/resuming of the slave (including a running blender process)
 
 -Add a threads variable for software that doesn't support threads (blender takes care of this by itself)
 

	
 
Options
src/server/slave.c
Show inline comments
 
@@ -110,36 +110,37 @@ options_init(argc,argv,&my_cfg, myopts, 
 
	else{
 
	  fprintf(stderr,"Something is terribly wrong!");
 
	}
 

	
 

	
 

	
 
/* These should all be filled by remotio and other code @TODO: Make this less blender-specific and more jobtype-flexible... how should we go about doing this? */
 
/* Code-filled Vars, filled somewhere in the loopage  */
 
int jobnum;
 
int framenum;
 

	
 
/* These should be filled by the xml file that comes with a job @TODO: Add calls to the xml function that ohnobinki's working on */
 
char *outputExt = "JPG";
 
char *outputRes = "1600x1200";
 
int framenum; // @TODO: Remotio should fill this
 

	
 
int gotframe; // set this to 1 after data for a job is received from the server
 
int busy = 0;     // Client business 1=busy 0=idle
 

	
 
char *urltoTar;  // Full URL to the server-side location of job#.tgz
 
char *pathtoTar; // Full path to the location of the job#.tgz
 

	
 
char *urltoOutput;   // Full URL where output is posted
 
char *pathtoJobfile; // Full path to the job's main file
 
char *pathtoXml;     // Full path to the job's xml file
 
char *pathtoOutput;  // Full path to the output (rendered) file
 
char *outputExt;     // Output Extension (e.g., JPG)
 

	
 
struct distrenjob *myjob; // Structure to hold data gathered from the XML file
 

	
 
// If the slave is getting job info...
 
if(gotframe ==1)
 
  {
 
    /* @TODO: fix these remoteio_read's */
 
    jobnum = remotio_read(jobnum); // Set jobnum from remoteio (we could use info from struct, but we need this info to download the xmlfile)
 
    framenum = remoteio_read(jobnum); // Set framenum from remoteio
 

	
 
    char *tarcmd;
 
    char *outdir;
 
    char *jobdatapath;
 

	
 
    fprintf(stderr, "Received %d in job %d, preparing to render...\n",framenum,jobnum);
 

	
 
@@ -151,13 +152,12 @@ if(gotframe ==1)
 
    _distren_asprintf(&urltoTar, "http://protofusion.org/distren/stor/job%d/job%d.tar.gz",jobnum); // Prepares URL to download from
 
    _distren_asprintf(&pathtoTar, "%s/stor/jobdata/job%d.tar.gz", datadir, jobnum); // Prepares destination to save to
 

	
 
    _distren_asprintf(&pathtoJobfile, "%s/%s/job.blend", datadir, jobdatapath ); // Prepares the path to the jobfile
 
    _distren_asprintf(&urltoOutput, "http://protofusion.org/distren/stor/job%d/output/", jobdatapath ); // Prepares the URL where output is posted
 
    _distren_asprintf(&pathtoXml, "%s/job%d/job%d.xml",datadir, jobnum ); // Prepares the path to the job's XML file
 
    _distren_asprintf(&pathtoOutput, "%s/job%d/output/frame%d.%s", datadir, jobnum, framenum, outputExt ); // Prepares the path to the jobfile
 

	
 
    //  Download the data if it isn't  present. (prevents re-downloading for same-job frames) @TODO: Delete old job data
 

	
 
      struct stat buffer;
 
      int fstatus = stat(pathtoJobfile, &buffer);
 
      if(fstatus != -1){
 
@@ -180,13 +180,18 @@ if(gotframe ==1)
 
    }
 
    else{
 
      fprintf(stderr,"I think the XML craziness may have failed, so I'll terminate just for fun.\n");
 
      return 1;
 
    }
 

	
 
    exec_blender(&myjob, pathtoJobfile, pathtoOutput, framenum); // @TODO: Implement the xml --> struct function
 
    /* Variable-fillers which require XML */
 
    outputExt = myjob.outputFormat;
 
    _distren_asprintf(&pathtoOutput, "%s/job%d/output/frame%d.%s", datadir, jobnum, framenum, outputExt ); // Prepares the path to the jobfile
 

	
 

	
 
     exec_blender(&myjob, pathtoJobfile, pathtoOutput, framenum); // @TODO: This warning should be fixed :D
 

	
 
    // Consider placing the following in the exec_blender() function
 
    while(busy == 1){
 
      tell_the_server(DISTREN_REQUEST_PROGRESS);
 
        fprintf(stderr, "Rendering frame %d in job %d...",framenum,jobnum);
 
        sleep(5); // or not... this should be more event-driven, but should still give a heartbeat to the server
src/server/slavefuncs.c
Show inline comments
 
@@ -332,50 +332,47 @@ int conf_replace(char *username){
 
return 1; // Success
 
}
 

	
 

	
 
/* Executors */
 

	
 
/*
 
  It seems that the client will need to know the job number. fixme.
 
*/
 

	
 
/** Executor function for Blender operations */
 
void exec_blender(struct distrenjob* distrenjob, char *input, char *output, int frame)
 
{
 
  int ret;
 
  char *frame_str;
 

	
 
  /* start execio code */
 
  char *command = "blender"; // @TODO: append .exe if win32?
 
  // @TODO: Put in code for output resolution, maybe... mayyyyyyybe....
 

	
 
  char *cmd[] = { command, "-b", "-o", output, input, "-f", frame_str, (char *)NULL };
 

	
 
  char buf[10];
 
  struct execio *testrem;
 
  size_t readlen;
 

	
 
  _distren_asprintf(&frame_str, "%i", frame);
 

	
 
  ret = execio_open(&testrem, command, cmd); // This path will be absolute for testing, should be relative to install on production
 
  buf[9] = '\0'; // null-terminating the array...
 
  ret = execio_open(&testrem, command, cmd); // This path will be absolute for testing, @TODO: should be relative to install on production
 
  buf[9] = '\0';
 
  while(!execio_read(testrem, buf, 9, &readlen))
 
  	    {
 
  	      if(readlen > 9) {
 
  		fprintf(stderr, "Something is terribly wrong!\n");
 
  	      }
 
  	      buf[readlen] = '\0';
 
  	      fprintf(stderr, "read \"%s\"\n", buf);
 
  	    }
 
  	execio_close(testrem);
 
  /* end execio code */
 
  	if(ret == 1){
 
  		fprintf(stderr,"Error starting Blender. Check your install.");
 
  		fprintf(stderr,"Error starting Blender. Check your install.\n");
 
  	}
 
  	else{
 
  		fprintf(stderr,"Blender at least started nicely, who knows if it rendered anything though.");
 
  		fprintf(stderr,"Blender at least started nicely, we don't know if it rendered anything though.\n");
 
  	}
 
}
 

	
 
void xmlinit()
 
{
 
  xmlInitParser();
0 comments (0 inline, 0 general)