Changeset - 1b885b7c9c3e
[Not reviewed]
default
0 4 0
ethanzonca - 16 years ago 2009-08-06 23:41:11

Fixes to slave, todo prune
4 files changed with 34 insertions and 17 deletions:
0 comments (0 inline, 0 general)
TODO
Show inline comments
 
Key:
 
*-An important Item that needs to be finished
 
B-Initial of person who needs to fix this (Binki)
 
M-LordofWar needs to fix this
 
E-normaldotcom needs to fix this
 
x-finished task
 
=-Long-term goal
 

	
 
Build
 

	
 
Master
 
*-Add calls to remotio
 
 -Write more meat into the pseudo-code main() to pull everything together
 
@@ -16,13 +17,16 @@ 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
 
 -Add errorcatchers to return in libcurl functions
 
=-Make code more flexible for different types of jobs
 

	
 
Options
 
 -Rewrite some stuff, try to make it simpler
 
x-Move server and client confuse code into their individual files, rather than in the common file. -- note: there wasn't any client code in options.c. There was the ``server'' section. That section is passed multiple times and provides information to remoteio on how to connect to servers
 
 -Review all confuse interfacing
 
 -Push patch for relative includes in confuse to the confuse developers
src/server/slave.c
Show inline comments
 
@@ -109,31 +109,30 @@ options_init(argc,argv,&my_cfg, myopts, 
 
	}
 
	else{
 
	  fprintf(stderr,"Something is terribly wrong!");
 
	}
 

	
 

	
 
/* Somewhat pseudo Rendering code */
 

	
 
/* These should all be filled by remotio and other code @TODO: Make this less blender-specific and more jobtype-flexible */
 
int jobnum;
 
int framenum;
 

	
 
/* These should all be filled by remotio and other code */
 
int jobnum;   // Filled by the server telling the client what to render
 
int framenum; // same as above
 
char *outputext = "JPG";
 
/* These should be filled by the xml file that comes with a job */
 
char *outputExt = "JPG";
 
char *outputRes = "1600x1200";
 

	
 
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 *pathtoOutput;
 

	
 

	
 
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 *pathtoOutput;  // Full path to the output (rendered) file
 

	
 
// If the slave is getting job info...
 
if(gotframe ==1)
 
  {
 
    char *tarcmd;
 
    char *outdir;
 
@@ -148,26 +147,32 @@ 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(&pathtoOutput, "%s/job%d/output/frame%d.%s", datadir, jobnum, framenum, outputext ); // Prepares the path to the jobfile
 
    _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
 

	
 
    //  Download the data
 
    curlget(urltoTar, pathtoTar); // Downloads the Tar @TODO: add a progressbar
 
      struct stat buffer;
 
      int fstatus = stat(pathtoJobfile, &buffer);
 
      if(fstatus != -1){
 
              fprintf(stderr, "Using cached job file...\n");
 
              curlget(urltoTar, pathtoTar); // Downloads the Tar @TODO: add a progressbar
 
      }
 

	
 
    _distren_asprintf(&outdir, "/tmp/distren/job%d", jobnum); /*< @todo free() */
 
    mkdir("/tmp/distren", 0750);
 
    mkdir(outdir, 0750);
 

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

	
 
    // exec_blender(blendjob, pathtoJobfile, pathtoOutput, framenum); // So this should grab data from the struct? I have no idea. @TODO: Ohnobinki, we should clear this up.
 
    // exec_blender(blendjob, pathtoJobfile, pathtoOutput, framenum); // @TODO: Make a 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
src/server/slavefuncs.c
Show inline comments
 
@@ -35,12 +35,18 @@
 
#include <string.h>
 
#include <unistd.h>
 
#include <stdlib.h>
 
#include <sys/stat.h>
 
#include <fcntl.h>
 

	
 

	
 
/** Stub, writes struct from xml */
 
int buildstruct(struct blendjob* blendjob, char *pathtoxml){
 
  return 1;
 
}
 

	
 
/** Stub stub stubbiness ugh */
 
void tell_the_server(char *stuff){
 
}
 

	
 
/** Function referenced by curlget() to write data to disk. */
 
size_t curl_writetodisk(void *ptr, size_t size, size_t nmemb, FILE *stream)
 
@@ -312,19 +318,20 @@ 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 blendjob* blendjob, char *input, char *output, int frame)
 
void exec_blender(struct blendjob* blendjob, char *input, char *output, char *outputres, 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;
 

	
src/server/slavefuncs.h
Show inline comments
 
@@ -19,18 +19,19 @@
 

	
 
#ifndef _DISTREN_SLAVEFUNCS_H
 
#define _DISTREN_SLAVEFUNCS_H
 
#include "blendjob.h"
 
#include <stdio.h>
 

	
 

	
 
int buildstruct(struct blendjob* blendjob, char *pathtoxml);
 
void tell_the_server(char *stuff);
 
size_t curl_writetodisk(void *ptr, size_t size, size_t nmemb, FILE *stream);
 
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 blendjob* blendjob, char *input, char *output, int frame);
 
void exec_blender(struct blendjob* blendjob, char *input, char *output, char *outputres, int frame);
 

	
 

	
 
#endif
0 comments (0 inline, 0 general)