Changeset - f5a1573ebc08
[Not reviewed]
default
0 3 0
Nathan Brink (binki) - 16 years ago 2010-02-13 23:01:22
ohnobinki@ohnopublishing.net
fix up finish_frame() into mysql.c, reorganize mysql.? a bit
3 files changed with 75 insertions and 26 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -6,338 +6,337 @@
 
  DistRen is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU Affero General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  DistRen is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  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/>.
 

	
 
*/
 

	
 
/* This file contains the code which both processes (renders) jobs as a slave, and the code which distributes frames to slaves after receiving them from the client portion of the codebase. */
 

	
 
#include "distrenjob.h"
 
#include "listen.h"
 
#include "slavefuncs.h"
 
#include "mysql.h"
 

	
 
#include "common/asprintf.h"
 
#include "common/execio.h"
 
#include "common/options.h"
 
#include "common/protocol.h"
 

	
 
#include <confuse.h>
 
#include <malloc.h>
 
#include <stdio.h>
 
#include <stdlib.h>
 
#include <string.h>
 
#include <sys/stat.h>
 
#include <sys/types.h>
 
#include <time.h>
 
#include <unistd.h>
 

	
 
#include <libxml/encoding.h>
 
#include <libxml/parser.h>
 
#include <libxml/tree.h>
 
#include <libxml/xmlmemory.h>
 
#include <libxml/xmlreader.h>
 
#include <libxml/xmlwriter.h>
 

	
 
/* ******************* Structs ************************ */
 
struct general_info
 
{
 
  struct distrenjob head;
 
  distrend_mysql_conn_t conn;
 

	
 
  struct distrend_config *config;
 

	
 
  struct
 
  {
 
    /** general_info.xml */
 
    char *geninfo;
 
    
 
  } files;
 

	
 
  int jobs_in_queue;
 
  unsigned int free_clients;
 
  unsigned int rendering_clients;
 
  unsigned int total_finished_jobs;
 
  unsigned int total_frames_rendered;
 
  unsigned int highest_jobnum;
 
  int hibernate;
 
  time_t timestamp;
 
  unsigned long total_render_power;
 
  unsigned long total_priority_pieces;
 
};
 

	
 

	
 
/* *********************************************
 
   Function Prototypes
 
   ********************************************* */
 

	
 
/* ************General Functions************* */
 
// int xml_dump();
 
int distrend_do();
 
// int start_data(struct general_info *general_info);
 
int start_data(struct general_info *general_info);
 
int mortition(struct general_info *geninfo, struct distrenjob *job);
 
// int restoreJobState(struct distrenjob *job);
 
// int prepare_distrenjob(struct general_info *geninfo, int type, char *name, char *submitter, int priority, int start_frame, int end_frame, int width, int height);
 
// int distrenjob_enqueue(struct general_info *geninfo, struct distrenjob *job);
 
// int find_jobframe_from_job(struct distrenjob *distrenjob_ptr, struct distrenjob **job, struct frameset **frame);
 
// int find_jobframe_new(struct general_info *geninfo, int rend_pwr, struct distrenjob **job, struct frameset **frame);
 
// int find_jobframe_again(struct general_info *geninfo, int jobnum, int rend_pwr, struct distrenjob **job, struct frameset **frame);
 
void frame_watchdog(struct distrenjob *distrenjob_head);
 
// struct distrenjob *distrenjob_get(struct distrenjob *head, jobnum_t jobnum);
 
// void distrenjob_remove(struct general_info *geninfo, struct distrenjob *bj);
 
int distrend_do_config(int argc, char *argv[], struct distrend_config **config);
 
int distrend_config_free(struct distrend_config *config);
 

	
 
/* **************XML Functions**************** */
 
void update_general_info(struct general_info *geninfo);
 
int import_general_info(struct general_info *general_info);
 
int restore_distrenjob(struct general_info *geninfo, struct distrenjob **distrenjob, jobnum_t jobnum);
 
int updateJobStatsXML(struct distrenjob *job);
 
int update_xml_joblist(struct general_info *geninfo);
 
int createQueueFromXML(struct general_info *geninfo);
 
int reCreateQueueFromXML(struct general_info *geninfo, xmlDocPtr doc, xmlNodePtr current);
 

	
 
/* **************Test Functions**************** */
 
int printFrameInfo(struct frameset *frame);
 
int printJob(struct distrenjob *job);
 
int printJobInfo(struct distrenjob *job);
 
int printAllJobnums(struct distrenjob *head);
 
int interactiveTest(int test, struct general_info general_info);
 
int job_getserialfilename(char **filename, struct general_info *geninfo, unsigned int jobnum, int createdir);
 
int distren_mkdir_recurse(char *dirname);
 

	
 
/* **************** Main ********************* */
 
int main(int argc, char *argv[])
 
{
 
  /* Parse arguments */
 
  int counter;
 
  int test = 0; /*< Interactive mode if 1 */
 
  struct general_info general_info;
 
  struct distrend_clientset *clients;
 

	
 
  enum clientstatus
 
  {
 
    CLIENTSTATUS_UNINITIALIZED = 0,
 
    CLIENTSTATUS_BUSY = 1,
 
    CLIENTSTATUS_IDLE = 2
 
  } clientstatus;
 

	
 
  xmlinit();
 

	
 
  for(counter = 0; counter < argc; counter ++)
 
    {
 
      if(strcmp(argv[counter], "-h") == 0)
 
      {
 
    	  fprintf(stderr, "Usage: distrend [option] \nStarts the distrend server\n\t-h\tshow this help\n\t-t\tlaunches queue testing interface \n");
 
	  return 2;
 
      }
 

	
 
      else if(strcmp(argv[counter], "-t") == 0)
 
      {
 
    	  fprintf(stderr, "Entering into test mode...\n\n");
 
    	  test = 1;
 
      }
 
    }
 

	
 

	
 
  if(distrend_do_config(argc, argv, &general_info.config))
 
    return 1;
 

	
 
  /** preset paths */
 
  _distren_asprintf(&general_info.files.geninfo, "%s/general_info.xml",
 
		    general_info.config->datadir);
 

	
 
  /* @QUERY: Obselete?
 
  if(start_data(&general_info))
 
    {
 
      fprintf(stderr, "%s:%d: start_data() failed\n", __FILE__, __LINE__);
 
      return 1;
 
    }
 
    */
 

	
 
  /** MySQL Connection */
 
  struct distrend_mysql_con *conn;
 
  if(mysqlConnect(&conn))
 
  if(mysqlConnect(&general_info.conn))
 
    {
 
      fprintf(stderr, "%s:%d: mysqlConnect() failed\n", __FILE__, __LINE__);
 
      return 1;
 
    }
 

	
 
  /** pre-loaded jobs for testing */
 
  // prepare_distrenjob(&general_info, 1, "awesome", "LordOfWar", 8, 1, 100, 640, 480);
 
  // prepare_distrenjob(&general_info, 1, "hamburger", "ohnobinki", 3, 1, 50, 1280, 720);
 

	
 
  /** Execute test function */
 
  // interactiveTest(test, general_info);
 

	
 
  distrend_listen(general_info.config, &clients);
 

	
 
  int slaveKey = 0; // Remotio should set me on a per-slave basis
 
  /* Main Loop */
 
  while(!general_info.config->die)
 
    {
 
      int clientsays = 0; /*< temporary example variable, will be replaced when we can handle messages */
 

	
 
      distrend_accept(general_info.config, clients);
 

	
 
      /* Make the following code more event-driven */
 
      frame_watchdog(&general_info.head);
 

	
 
      struct frameset *frame;
 
      struct distrenjob *job;
 

	
 
      /* If the client is idle, must be modified for climbing through linked list of clients (client->clientnum) */
 
      if(clientstatus == CLIENTSTATUS_IDLE)
 
	{
 
	  int returnnum = find_jobframe(slaveKey, &job->jobnum, &frame->num, conn); // Finds a frame to render @FIXME: Slavenum :D
 
	  if(returnnum)
 
	    {
 
	      fprintf(stderr,"No frames are available to render at this time. Idling...\n");
 
	      sleep(10);
 
	    }
 
	  else
 
	    remotio_send_to_client(frame->num, job->jobnum); // Pseudo-sends data to client
 
	}
 
      /* If the client states that they finished the frame */
 
      	if(clientsays == DISTREN_REQUEST_DONEFRAME){
 
      	  clientstatus = CLIENTSTATUS_IDLE; // Sets the client back to idle
 
      	  finish_frame(slaveKey, job->jobnum, frame->num, conn); // @TODO: Make sure this actually works.
 
      	  finish_frame(general_info.conn, job->jobnum, frame->num); // @TODO: Make sure this actually works.
 
      	}
 
    }
 

	
 
  distrend_unlisten(general_info.config->listens, clients);
 
  distrend_config_free(general_info.config);
 

	
 
  xmlcleanup();
 

	
 
  /** free() paths */
 
  free(general_info.files.geninfo);
 
  mysqlDisconnect(conn);
 
  mysqlDisconnect(general_info.conn);
 

	
 
  return 0;
 
}
 

	
 
/* ********************** Functions ************************* */
 

	
 
/** Dumps all data in RAM to an xml file (such as current jobs, etc) which is parsed by start_data. Remember to invoke this before shutting down! @TODO: Fill this stub*/
 
// @QUERY: Obselete function, get rid of me!
 
/*
 
int xml_dump()
 
{
 
  return 0;
 
}
 
*/
 

	
 

	
 
/**
 
   Performs command stored in a client's request. @TODO: Fill stub
 
*/
 
int distrend_do()
 
{
 
  return 0;
 
}
 

	
 
/** 
 
    Fill variables at startup from XML dumps or defaults
 
 */
 
// @QUERY: Obselete function, as data is stored in sql now.
 

	
 
/*
 
int start_data(struct general_info *general_info)
 
{
 
  struct stat buffer;
 

	
 

	
 
// defaults
 

	
 
  memset(&general_info->head, '\0', sizeof(struct distrenjob));
 
  general_info->head.priority = 0;
 

	
 
  general_info->jobs_in_queue = 0;
 
  general_info->free_clients = 0;
 
  general_info->rendering_clients = 0;
 
  general_info->total_finished_jobs = 0;
 
  general_info->total_frames_rendered = 0;
 
  general_info->highest_jobnum = 0;
 
  general_info->hibernate = 0;
 
  general_info->timestamp = 0;
 
  general_info->total_render_power = 0;
 
  general_info->total_priority_pieces = 0;
 

	
 
  fprintf(stderr, "Initialized default global and queue states\n");
 

	
 
  if(stat(general_info->files.geninfo, &buffer) == 0)
 
    {
 
      fprintf(stderr, "Previous state file found; loading ``%s'':\n", general_info->files.geninfo);
 

	
 
      fprintf(stderr, "Parsing XML files and restoring previous state...\n");
 
      if(import_general_info(general_info))
 
        fprintf(stderr, "FAILURE\n");
 
      
 
      fprintf(stderr, "Restoring queue...\n");
 
      if(createQueueFromXML(general_info))
 
        fprintf(stderr, "FAILURE\n");
 
      
 
      fprintf(stderr, "done\n");
 
    }
 
  
 
  return 0;
 
}
 
*/
 

	
 

	
 
/**
 
   checks to see if a job is actually done.
 
   - scans the folder of the job to make sure all output files are present
 
*/
 
// @QUERY: Needs some complex query work
 

	
 
/*
 
int mortition(struct general_info *geninfo, struct distrenjob *job)
 
{
 
  short int isJobDone;
 
  int counter;
 
  char *path_and_number;
 
  struct stat buffer;
 

	
 
  isJobDone = 1;
 
  for(counter = 0; counter < job->total_frames; counter++)
 
    {
 
      _distren_asprintf(&path_and_number, "%s/stor/job%d/out/%d.%s",
 
                        geninfo->config->datadir,
 
                        job->jobnum,
 
                        job->frameset[counter].num,
 
                        job->output_format);
 
      if(stat(path_and_number, &buffer) == -1)
 
        {
 

	
 
          //   missing frame found
 

	
 
          job->frameset[counter].status = FRAMESETSTATUS_UNASSIGNED;
 
          job->completed_frames--;
 
          geninfo->total_frames_rendered--;
 
          isJobDone = 0;
 
        }
 
      free(path_and_number);
 
    }
 

	
 
  if(isJobDone)
 
    {
 

	
 
    //   all frames were accounted for
 

	
 
      distrenjob_remove(geninfo, job);
 
      distrenjob_free(&job);
 
      update_xml_joblist(geninfo);
 
    }
 
  else
 

	
 
    //   if the job isn't done, have frame_finder() start from the first frame, allowing it to see the frames that are now unassigned
 

	
src/server/mysql.c
Show inline comments
 
/*
 
  Copyright 2009 Nathan Phillip Brink, Ethan Zonca, Matthew Orlando
 

	
 
  This file is a part of DistRen.
 

	
 
  DistRen is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU Affero General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  DistRen is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  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/>.
 

	
 
*/
 

	
 
#include "mysql.h"
 
#include <mysql/mysql.h>
 

	
 
#include "common/asprintf.h"
 
#include "common/protocol.h"
 

	
 
#include <stdio.h>
 
#include <string.h>
 
#include <unistd.h>
 
#include <stdlib.h>
 
#include <sys/stat.h>
 
#include <fcntl.h>
 

	
 
/**
 
   local types
 
 */
 

	
 
#define SEVENTY_FIVE 75
 
#define FORTY_TWO 42
 

	
 
struct distrend_mysql_con 
 
/**
 
   performs mysql query.
 
   errors will be logged to the user by this function.
 
   @return pointer to query handle on success, NULL on failure
 
 */
 
distrend_mysql_result_t mysqlQuery(distrend_mysql_conn_t conn, char *query);
 

	
 
/**
 
   frees mysql query result. Accepts a NULL pointer and ignores it to
 
   help deal with one-shot calls to mysqlQuery so that you don't have to
 
   check if it returned NULL or not.
 
   @return 0 on success
 
 */
 
int mysqlResultFree(distrend_mysql_result_t result);
 

	
 

	
 

	
 
struct distrend_mysql_conn
 
{
 
  MYSQL *mysqlconn;
 
  short pointlesscheck;
 
};
 

	
 
struct distrend_mysql_result
 
{
 
  MYSQL_RES *mysqlresult;
 
  short pointlesscheck;
 
};
 

	
 
/** 
 
    funcs
 
 */
 

	
 
int mysqlConnect(struct distrend_mysql_con **conn)
 
int mysqlConnect(distrend_mysql_conn_t *conn)
 
{
 
  MYSQL *mysqlconn;
 

	
 
  char *server = "zserver1";
 
  char *user = "distren";
 
  char *password = "secretpassword";
 
  char *database = "distren";
 

	
 
  mysqlconn = mysql_init(NULL);
 
  mysql_options(mysqlconn, MYSQL_OPT_RECONNECT,"true");
 

	
 
  if(!mysql_real_connect(mysqlconn, server, user, password, database, 0, NULL, 0))
 
    {
 
      fprintf(stderr, "%s\n", mysql_error(mysqlconn));
 
      return 1;
 
    }
 

	
 
  *conn = malloc(sizeof(struct distrend_mysql_con));
 
  *conn = malloc(sizeof(struct distrend_mysql_conn));
 
  if(!*conn)
 
    {
 
      mysql_close(mysqlconn);
 
      mysql_server_end();
 
      return 2;
 
    }
 
  (*conn)->mysqlconn = mysqlconn;
 
  (*conn)->pointlesscheck = SEVENTY_FIVE;
 

	
 
  return 0;
 
}
 

	
 
int mysqlDisconnect(distrend_mysql_con_t conn)
 
int mysqlDisconnect(distrend_mysql_conn_t conn)
 
{
 
  /**
 
     check if this handle is valid
 
   */
 
  if(conn->pointlesscheck != SEVENTY_FIVE)
 
    fprintf(stderr, "warning, I was passed a bad struct distrend_mysql_con...\n");
 
    fprintf(stderr, "warning, I was passed a bad struct distrend_mysql_conn...\n");
 

	
 
  /**
 
     invalidate handle :-D
 
   */
 
  conn->pointlesscheck ++;
 

	
 
  mysql_close(conn->mysqlconn);
 
  mysql_server_end();
 
  free(conn);
 

	
 
  return 0;
 
}
 

	
 

	
 
distrend_mysql_result_t mysqlQuery(distrend_mysql_con_t conn, char *query)
 
distrend_mysql_result_t mysqlQuery(distrend_mysql_conn_t conn, char *query)
 
{
 
  MYSQL_RES *result;
 
  distrend_mysql_result_t distrenresult;
 

	
 
  /**
 
     pointless sanity check
 
  */
 
  if(conn->pointlesscheck != SEVENTY_FIVE)
 
    fprintf(stderr, "warning, I was passed a bad struct distrend_mysql_con...\n");
 
    fprintf(stderr, "warning, I was passed a bad struct distrend_mysql_conn...\n");
 
  
 
  /** make sure that connection is still alive
 
   */
 
  if(mysql_ping(conn->mysqlconn))
 
    fprintf(stderr, "MySQL Connection _was_ broken or may be broken, I'm not sure exactly what this return value means\n");
 

	
 
  if (mysql_query(conn->mysqlconn, query))
 
     fprintf(stderr, "%s\n", mysql_error(conn->mysqlconn));
 

	
 
  result = mysql_use_result(conn->mysqlconn);
 

	
 
  distrenresult = malloc(sizeof(struct distrend_mysql_result));
 
  if(!distrenresult)
 
    {
 
      mysql_free_result(result);
 
      return NULL;
 
    }
 
  
 
  distrenresult->mysqlresult = result;
 
  distrenresult->pointlesscheck = FORTY_TWO;
 
  
 
  return distrenresult;
 
}
 

	
 
int mysqlResultFree(distrend_mysql_result_t result)
 
{
 
  if(!result)
 
    return 0;
 

	
 
  if(result->pointlesscheck != FORTY_TWO)
 
    fprintf(stderr, "%s:%d: I didn't get the type of handle I wanted\n", __FILE__, __LINE__);
 

	
 
  mysql_free_result(result->mysqlresult);
 
  free(result);
 

	
 
  return 0;
 
}
 

	
 
<<<<<<< local
 

	
 

	
 
/*
 
   Individual query functions:
 
=======
 
/**
 
   Querying Functions
 
>>>>>>> other
 
 */
 

	
 
<<<<<<< local
 
=======
 
/** Finish-Setter: Sets a frame to the "completed" status.*/
 
// @QUERY: update `distren`.`Job` set `Finish_Confirmed`=1 where `Job_Key`='1' and `Frame` = somenumber;
 
void finish_frame(int slaveKey, int jobKey, int frameNum, distrend_mysql_con_t conn)
 
{
 
  MYSQL_RES *result;
 
  MYSQL_ROW row;
 
>>>>>>> other
 

	
 
<<<<<<< local
 
void finish_frame(distrend_mysql_conn_t conn, int32_t jobkey, int32_t framenum)
 
=======
 
  char *query = "update `distren`.`Job` set `Finish_Confirmed`=1 where `Job_Key`='1' and `Frame` = somenumber;";
 
  result = mysqlQuery(conn, query);
 

	
 
  // Check to make sure the slavekey is the one who rendered the frame before finishing :D
 
  /*
 
  distrenjob->frameset[frame].status = FRAMESETSTATUS_DONE;
 
  distrenjob->total_render_time = distrenjob->total_render_time + (clock() - distrenjob->frameset[frame].start_time);
 
  distrenjob->completed_frames ++;
 
  distrenjob->assigned_frames --;
 
  geninfo->total_frames_rendered ++; //< Increase total frames var for stats
 
  update_general_info(geninfo);
 
  updateJobStatsXML(distrenjob);
 
  */
 
}
 

	
 
/** Changes the priority of an existing (and maybe running) job. @arg head I may end up changing the head if job == head */
 
// @QUERY: update `distren`.`Job` set `Priority`='12', `Finish_Confirmed`=1 where `Job_Key`='1';
 
int change_job_priority(int jobKey, int newPriority, distrend_mysql_con_t conn){
 
  /*
 
  struct distrenjob *current_job;
 
  struct distrenjob *prev_job;
 
  char *serialname;
 

	
 
  distrenjob_remove(geninfo, job);
 
  job->priority = new_priority;
 

	
 
  prev_job = &geninfo->head;
 

	
 
  if(job->frameset[0].status == FRAMESETSTATUS_UNASSIGNED)
 

	
 
      //  if job was not yet started
 

	
 
    {
 
      distrenjob_enqueue(geninfo, job);
 
      return 0;
 
    }
 

	
 

	
 
    // iterate through linked list of jobs
 
    for(current_job = &geninfo->head;
 
        current_job != NULL
 
          && job->priority > current_job->priority;
 
        current_job = current_job->next)
 
      prev_job = current_job;
 

	
 
    prev_job->next = job;
 
    job->next = current_job;
 

	
 

	
 
  update_xml_joblist(geninfo);
 
  // reserialize after changes
 
  job_getserialfilename(&serialname, geninfo, job->jobnum, 0);
 
  distrenjob_serialize(job, serialname);
 
  free(serialname);
 
*/
 
  return 0;
 
}
 

	
 
/**
 
  Frame Finder: Finds a frame for a slave to render
 
*/
 
// @QUERY: Frame_Get()
 
int find_jobframe(int slaveKey, int *jobKey, int *frameNum, distrend_mysql_con_t conn)
 
>>>>>>> other
 
{
 
<<<<<<< local
 
  distrend_mysql_result_t result;
 
  char *query;
 
=======
 
  /*
 
  if(geninfo->hibernate)
 
    return 1;
 
>>>>>>> other
 

	
 
<<<<<<< local
 
  /**
 
    @TODO record the total rendering time for the frame
 
   */
 
=======
 
  unsigned int frame_counter;
 
  unsigned short int found;
 
>>>>>>> other
 

	
 
<<<<<<< local
 
  _distren_asprintf(&query, "UPDATE `distren`.`Job` SET `Finish_Confirmed`=1 WHERE `Job_Key`=%d AND `Frame`=%d",
 
		    jobkey, framenum);
 
  
 
  result = mysqlQuery(conn, query);
 
  free(query);
 
  
 
  mysqlResultFree(result);
 
=======
 
  struct distrenjob *distrenjob_ptr;
 

	
 
  found = 0;
 
  // iterate through jobs from first to last
 
  for(distrenjob_ptr = geninfo->head.next; distrenjob_ptr && !distrenjob_ptr->hibernate; distrenjob_ptr = distrenjob_ptr->next)
 
  {
 
    for(frame_counter = (distrenjob_ptr->prev_frame_index + 1); frame_counter < distrenjob_ptr->total_frames; frame_counter ++)
 
    {
 
      if(distrenjob_ptr->frameset[frame_counter].status == FRAMESETSTATUS_UNASSIGNED) // jobframe found
 
      {
 
        found = 1;
 
        distrenjob_ptr->frameset[frame_counter].status = FRAMESETSTATUS_ASSIGNED;
 
        distrenjob_ptr->frameset[frame_counter].start_time = clock();
 
        distrenjob_ptr->assigned_frames++;
 
        distrenjob_ptr->prev_frame_index = frame_counter;
 
        updateJobStatsXML(distrenjob_ptr);
 
      }
 

	
 
      if(found)
 
        break;
 
    }
 

	
 
    if(found)
 
      break;
 
  }
 

	
 
  if(!found)
 
    {
 
      fprintf(stderr, "No more jobs to render\n");
 
      sleep(1); //< @todo eliminate the need for this line
 
      return 1;
 
    }
 

	
 
  *job = distrenjob_ptr;
 
  *frame = &distrenjob_ptr->frameset[frame_counter];
 
*/
 
  return 0;
 
>>>>>>> other
 
}
src/server/mysql.h
Show inline comments
 
/*
 
  Copyright 2009 Nathan Phillip Brink, Ethan Zonca, Matthew Orlando
 

	
 
  This file is a part of DistRen.
 

	
 
  DistRen is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU Affero General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  DistRen is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  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 MYSQL_H_
 
#define MYSQL_H_
 

	
 
struct distrend_mysql_con;
 
#include <stdint.h>
 

	
 
struct distrend_mysql_conn;
 
struct distrend_mysql_result;
 

	
 
typedef struct distrend_mysql_con *distrend_mysql_con_t;
 
typedef struct distrend_mysql_conn *distrend_mysql_conn_t;
 
typedef struct distrend_mysql_result *distrend_mysql_result_t;
 

	
 
/**
 
   initiates a MySQL connection
 
   @param conn, pointer will be set to the struct
 
   @return 0 on success
 
 */
 
int mysqlConnect(distrend_mysql_con_t *conn);
 
int mysqlConnect(distrend_mysql_conn_t *conn);
 

	
 
/**
 
   cleans and disconnects MySQL connection
 
   @param conn connection to clean
 
   @return 0 on success
 
*/
 
int mysqlDisconnect(distrend_mysql_con_t conn);
 
int mysqlDisconnect(distrend_mysql_conn_t conn);
 

	
 
/**
 
   performs mysql query.
 
   errors will be logged to the user by this function.
 
   @return pointer to query handle on success, NULL on failure
 
   Mark a frame as finished in the database.
 
 */
 
distrend_mysql_result_t mysqlQuery(struct distrend_mysql_con *conn, char *query);
 
void finish_frame(distrend_mysql_conn_t conn, int32_t jobkey, int32_t framenum);
 

	
 
/**
 
   frees mysql query result.
 
   @return 0 on success
 
 */
 
int mysqlResultFree(distrend_mysql_result_t result);
 

	
 

	
 
/** Import */
 

	
 
void finish_frame(int slaveKey, int jobKey, int frameNum, distrend_mysql_con_t conn);
 
int change_job_priority(int jobKey, int newPriority, distrend_mysql_con_t conn);
 
int find_jobframe(int slaveKey, int *jobKey, int *frameNum, distrend_mysql_con_t conn);
 

	
 

	
 

	
 

	
 
#endif /* MYSQL_H_ */
0 comments (0 inline, 0 general)