Changeset - 03f549da3f73
[Not reviewed]
default
0 3 0
ethanzonca - 16 years ago 2009-08-26 20:29:39

Added xml-function calls to the slave, removed resolution from exec_blender()
3 files changed with 19 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/server/slave.c
Show inline comments
 
@@ -126,14 +126,17 @@ int busy = 0;     // Client business 1=b
 

	
 
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
 

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

	
 
// If the slave is getting job info...
 
if(gotframe ==1)
 
  {
 
    char *tarcmd;
 
    char *outdir;
 
    char *jobdatapath;
 
@@ -147,12 +150,13 @@ if(gotframe ==1)
 
    _distren_asprintf(&jobdatapath, "job%d", jobnum);
 
    _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);
 
@@ -166,22 +170,32 @@ if(gotframe ==1)
 
    mkdir(outdir, 0750);
 

	
 
    _distren_asprintf(&tarcmd, "tar -xvf \"%s\" -C \"%s\"", pathtoTar, outdir);
 
    system(tarcmd);
 
    free(tarcmd);
 

	
 
    // exec_blender(distrenjob, pathtoJobfile, pathtoOutput, framenum); // @TODO: Implement the xml --> struct function
 
    // Grabs data from the XML file, throws it in the myjob struct.
 
    if(xml2distrenjob(&myjob, pathtoXml) == 0){
 
      fprintf(stderr,"Well, the XML craziness may have worked. Maybe. \n");
 
      distrenjob_free(&myjob); // Frees things up if it was successful. xml2distrenjob() really only fails if malloc'ing inside it fails
 
    }
 
    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
 

	
 
    // 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
 
      }
 
    busy = 2;
 
    busy = 1; // When done rendering, set this.
 
    busy = 1; // @TODO: When done rendering, set this.
 
     }
 
    // When blender is finished, run this...
 
      if(busy==2){
 
        fprintf(stderr, "Finished frame %d in job %d, uploading...",framenum,jobnum);
 
        char *outputurl;
 
        _distren_asprintf(&outputurl, "http://protofusion.org/distren/stor/job%d/",jobnum); // Throws the jobnum nicely in the string
src/server/slavefuncs.c
Show inline comments
 
@@ -51,13 +51,13 @@ xmlNodePtr xml_quickxpath(xmlXPathContex
 
  if(!xmlxpathobjptr
 
     || !xmlxpathobjptr->nodesetval->nodeNr)
 
    {
 
      fprintf(stderr, "XPath resolution failed for ``%s'' in ``%s'' (``%s'')\n", path, xpathctxt->doc->name, xpathctxt->doc->URL);
 
      return (xmlNodePtr)NULL;
 
    }
 
  
 

	
 
  toreturn = *(xmlxpathobjptr->nodesetval->nodeTab);
 

	
 
  xmlXPathFreeObject(xmlxpathobjptr);
 

	
 
  return toreturn;
 
}
 
@@ -337,13 +337,13 @@ return 1; // Success
 

	
 
/*
 
  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, char *outputres, int frame)
 
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?
src/server/slavefuncs.h
Show inline comments
 
@@ -31,11 +31,11 @@ size_t curl_writetodisk(void *ptr, size_
 
int curlget(char *url, char *out);
 
int curlpost(char *filename, char *url);
 
int ssh_keygen();
 
int register_user(char *username, char *email);
 
int login_user(char *username);
 
int conf_replace(char *username);
 
void exec_blender(struct distrenjob* distrenjob, char *input, char *output, char *outputres, int frame);
 
void exec_blender(struct distrenjob* distrenjob, char *input, char *output, int frame);
 
void xmlinit();
 
void xmlcleanup();
 

	
 
#endif
0 comments (0 inline, 0 general)