diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -21,41 +21,37 @@ #include #include -/* Just some notes -- Ethan Zonca - * - * So I read the IRC transcript, and we need some communication and plugin (e.g., blender, povray) standards. - * In addition to those standards, we should also have standards for information availability, - * making statistics and remote control of each plugin or the whole system standard and common, - * so other apps can grab stats from it (such as a j2me phone DistRen status app or a php web - * interface). - * - * - * - * Notes from IRCness: + /* Just some notes -- Ethan Zonca + * ++ Make data availible for other apps to parse * Server<==>Client Communication - * Job initiation: - * Job addition : - * Client Control: system (such as drop all jobs, shutdown client, etc) - * - * blender_getframecount() - * indigo_getframecount() always return 1... or just not bother with it? - * - * Upload while rendering - * - * + * Upload while rendering */ +#define max 100 + // maximum number of stored jobs in memory, per job type (lux/blend). Eventually we can dump this data to disk, or atleast the remainder not in memory... +int jobnum = 0; -// mySql configuration vars -static char *opt_host_name = "localhost"; // Server Hostname -static char *opt_user_name = "distren"; // Username -static char *opt_password = "008987"; // Password -static unsigned int opt_port_num = 0; // Port (or builtin if 0) -static char *opt_socket_name = NULL; // Socket Name (or builtin if null) -static char *opt_db_name = "distrend"; // Database name -static unsigned int opt_flags = 0; // Connection flags, what are these for? -static MYSQL *conn; // Pointer to the connection handler +// Structures for storing job information +// tweak char lengths to save on mem? +typedef struct { + char name[64]; + char submitter[64]; + char email[128]; + int priority; + struct frameset **frameset; // array of frames as big as the total number of frames. Every value should be null/0 to start out with. Values can be changed to reflect frame render status. +} blendjob[max]; + +typedef struct { + char name[64]; + char submitter[64]; + char email[128]; + int priority; + int mode; // 0 = Static Render, stop at Spp, or infinity if spp is null? Framerange is ignored.; 1 = animation, stop at Spp and stay in framerange. + int spp; + struct frameset ** frameset; +} luxjob[max]; + + @@ -63,70 +59,56 @@ int main(int argc, char *argv[]) { -// It's a happy fun mySQL party! This just test-connects to the server and does absolutely nothing else. Hopefully. + - /* initialize connection handler */ - conn = mysql_init (NULL); - if (conn == NULL) - { - fprintf (stderr, "mysql_init() failed (probably out of memory)\n"); - return 1; - } - /* connect to server */ - if (mysql_real_connect (conn, opt_host_name, opt_user_name, opt_password, - opt_db_name, opt_port_num, opt_socket_name, opt_flags) == NULL) - { - fprintf (stderr, "mysql_real_connect() failed\n"); - mysql_close (conn); - return 1; - } - /* disconnect from server */ - mysql_close (conn); +// frame[frame] Assignments: +// "0" - cancelled +// "1" - unassigned +// "2" - assigned to slave +// "3" - completed by slave and uploaded +// Have a script crawl through each job in the arrays, ordered by priority?, and assign a certain number of frames to each slave. +// Then we will need some sort of watchdog to monitor slaves on the main server to check for stales. + - return 0; +// Queuer: this function should add files to the queue +// Type: 0 = blender, 1 = lux +// jobnum is the current job number +void queue(int type, char *name, char *submitter, char *email, int priority, int mode, int spp, int **frameset) { + +if(type == 1){ + blendjob[jobnum].name = name; + blendjob[jobnum].submitter = submitter; + blendjob[jobnum].email = email; + blendjob[jobnum].priority = priority; + blendjob[jobnum].frameset = frameset[frames]; // pointer? will this work? +} + +if(type == 2){ + luxjob[jobnum].name = name; + luxjob[jobnum].submitter = submitter; + luxjob[jobnum].email = email; + luxjob[jobnum].priority = priority; + luxjob[jobnum].mode = mode; + luxjob[jobnum].spp = spp; + luxjob[jobnum].frameset = frameset[frames]; + // handle lux modes somehow. +} + +else{ +// Throw error. +} + +jobnum++; } -/* The (mostly psuedo) Blender Rendering Code, by Ethan Zonca: - -/////////////////////// MASTER /////////////////////////////// - -// MySQL Setup Code (put in common maybe). Even though you don't want to use mysql, I'm going to write it anyway. Clients can be compiled without mysql... -#include -MYSQL *conn; -MYSQL_RES *res; -MYSQL_ROW row; -// - char *server = "localhost"; // change if/when we do the multiserver setup... then distributed mysql with ssl? haha - char *user = "mysql"; - char *password = "mysql"; // heh - char *database = "distrend"; // check... I think this exists already on my server(s) -// -conn = mysql_init(NULL); -if (!mysql_real_connect(conn, server, user, password, database, 0, NULL, 0)) { fprintf(stderr, "%s\n", mysql_error(conn)); return (0); } -// Queuer -void queue(char *filename, int priority, char name, char submitter, char contact) { - -// Todo... store frame status in mysql tables, along with table with list of jobs/submitters/contact info/whatever else we want -/* Create a table with a row for each job, and a column for each frame. Rows will be ordered by priority. Each cell will have a status of - * "0" - cancelled - * "1" - not queued - * "2" - queued / assigned to slave - * "3" - completed by slave and uploaded -// Have a script crawl through each job, ordered by priority, and assign a certain number of frames -// to each slave. Then we will need some sort of watchdog to monitor slaves. - - -/* - -} @@ -164,4 +146,15 @@ void exec_imagemagick {char *input, char ret = execv {"/usr/bin/imagemagick", cmd); } - */ + + + + + + + + + + + return 0; +}