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
 
 -Write a stub for getting info from the tarball/validifying the tarball. Read distren-job.xml, a file in the tarball, to find out 1. which rendering system to use (that system, e.g. blender/povray, can read more specifics, such as name of file to pass to blender and frames. Options common between different systems will be handled in common as best as possible)
 
 -Write a stub for publishing file and constructing job description so that the job can be shared
 
*-Other XML-writing/reading
 

	
 
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
 
B-Expand execio() to support stderr
 
 
 
\ No newline at end of file
src/server/slave.c
Show inline comments
 
@@ -103,77 +103,82 @@ options_init(argc,argv,&my_cfg, myopts, 
 
			fprintf(stderr,"You should now be logged into distren.\n");
 
		}
 
		else{
 
			fprintf(stderr,"Login failed. I have no clue why. Sorry.\n");
 
			return 0;
 
		}
 
	}
 
	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;
 
    char *jobdatapath;
 

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

	
 
    /**
 
       Variable Preparation
 
       @todo find where to free() all of these
 
    */
 
    _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
 
      }
 
    busy = 2;
 
    busy = 1; // When done rendering, set this.
 
     }
 
    // When blender is finished, run this...
 
      if(busy==2){
src/server/slavefuncs.c
Show inline comments
 
@@ -29,24 +29,30 @@
 

	
 
#include <curl/curl.h>
 
#include <curl/types.h>
 
#include <curl/easy.h>
 

	
 
#include <stdio.h>
 
#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)
 
 {
 
    return fwrite(ptr, size, nmemb, stream);
 
  }
 

	
 
/** Gets a URL with cURL and saves it to disk */
 
int curlget(char *url, char *out){
 
@@ -306,31 +312,32 @@ int conf_replace(char *username){
 
  fprintf(stderr,"Wrote conf file...\n");
 
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 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;
 

	
 
  _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...
 
  while(!execio_read(testrem, buf, 9, &readlen))
 
  	    {
src/server/slavefuncs.h
Show inline comments
 
@@ -13,24 +13,25 @@
 
  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/>.
 
*/
 

	
 
#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)