Changeset - 144cab775ebd
[Not reviewed]
default
0 2 0
ethanzonca - 16 years ago 2009-07-25 00:37:59

Added protocolness, updated pseudocode
2 files changed with 13 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/common/protocol.h
Show inline comments
 
@@ -19,22 +19,22 @@
 

	
 
/**
 
   This file defines the constants and structs that the client uses to talk to the server and that the servers use to talk to eachother.
 
 */
 

	
 
/**
 
   generic, shared requests 
 
   generic, shared requests
 
 */
 
enum distren_request_type
 
  {
 
    DISTREN_REQUEST_VERSION = 1, /*< identifies the version of software being 
 
    DISTREN_REQUEST_VERSION = 1, /*< identifies the version of software being
 
				   used by the sender and tells if it is a client or server */
 
    DISTREN_REQUEST_PING = 2, 
 
    DISTREN_REQUEST_PING = 2,
 
    DISTREN_REQUEST_PONG = 3,
 
    DISTREN_REQUEST_DISCONNECT = 4,
 
    
 

	
 
    /**
 
       client->server only requests
 
    */
 
    DISTREN_REQUEST_SUBMIT = 5,
 

	
 
    /**
 
@@ -48,8 +48,10 @@ enum distren_request_type
 
    DISTREN_REQUEST_JOBINFO_RESPONSE = 7, /*< returns information about a job */
 

	
 
    /**
 
       server->server
 
    */
 
    DISTREN_REQUEST_RENDERFRAME = 8,
 
    DISTREN_REQUEST_DONEFRAME = 9
 
    DISTREN_REQUEST_DONEFRAME = 9,
 
    DISTREN_REQUEST_PROGRESS = 10, /*< tells another server of the progress of the first server's work at rendering */
 

	
 
  };
src/server/slave.c
Show inline comments
 
@@ -24,17 +24,21 @@
 
 *
 
 * Slave listens on server for a command in the format of each function...
 
 * We need if's for returns... ==> watchdog
 
 * **********************************************************************************
 
*/
 

	
 
// Provides DISTREN_REQUEST* which is in reality, DISTREN_SEND(signal)
 
#include "protocol.h"
 

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

	
 
	///////////////////// Semi-pseudo Slave Code ///////////////////////////
 

	
 

	
 
	int slavestatus = 0;
 

	
 
	if('no username in config file, no key present'){
 
		fprintf(stderr "run distrend -c username] [emailaddr] to register")
 
	}
 
	if('they use a -c flag according to getopt, with 2 args'){
 
@@ -50,22 +54,21 @@ int main(int argc, char *arvg[])
 
		fprintf(stderr, "Got frame %d in job %d, preparing to render...",frame,job);
 
		get('http://distren.protofusion.org/srv/job#.tgz');
 
		exec('tar -xvf job#.tgz /tmp/distren/job#'); // somehow
 
		exec_blender(jobname.blendfile, jobnum.framenum.JPG, jobnum); // (check the args, we'll need to adjust for different output formats)... set SLAVESTATUS=1 while rendering, SLAVESTATUS=2 when done
 
	}
 
	if(SLAVESTATUS==2){
 
		tell_the_server("Completed");
 
		fprintf(stderr, "Finished frame %d in job %d",framenum,jobnum);
 
		SLAVESTATUS=0;
 
	}
 
	if(SLAVESTATUS==0){
 
		tell_the_server("Idle");
 
		tell_the_server(DISTREN_REQUEST_DONEFRAME);
 
		fprintf(stderr, "Idle. No frames to render.");
 
	}
 
	while(SLAVESTATUS==1){
 
		tell_the_server("Rendering");
 
		tell_the_server(DISTREN_REQUEST_PROGRESS);
 
		fprintf(stderr, "Rendering frame %d in job %d...",framenum,jobnum);
 
		delay(1000); // or not... this should be more event-driven, but should still give a heartbeat to the server
 
	}
 

	
 
  return 0;
 
}
0 comments (0 inline, 0 general)