Functions

diet-bms-lib.h File Reference

This file can be used to access the API for the DIET Batch Management System. More...

#include <sys/types.h>
#include "JobStructures.h"

Go to the source code of this file.

Functions

int dietlist (const char *hostname, listOfJobs_t *listOfJobs, char *errorMessage, const size_t errorSize)
 Function used to list the jobs on a machine.
int dietNbJobs (const char *hostname, char *errorMessage, const size_t errorSize)
 Function used to get the number of jobs on a machine.
int dietNbRunningJobs (const char *hostname, char *errorMessage, const size_t errorSize)
 Function used to get the number of running jobs on a machine.
int dietNbWaitingJobs (const char *hostname, char *errorMessage, const size_t errorSize)
 Function used to get the number of waiting jobs on a machine.
int dietcancel (const char *hostname, const char *jobId, char *outputMessage, const size_t maxsize, char *errorMessage, const size_t errorSize)
 Function used to cancel a job on a machine with its job id.
int dietsubmit (const char *hostname, const char *scriptPath, char *jobID, const size_t maxsize, char *error_message, const size_t error_maxsize)
 Function used to submit a job on a machine with a script.
int printListOfJobs (const listOfJobs_t *listOfJobs)
 Method used to the a list of jobs.
int printJob (const job_t *job)
 Method used to print a job.

Detailed Description

This file can be used to access the API for the DIET Batch Management System.


Function Documentation

int dietcancel ( const char *  hostname,
const char *  jobId,
char *  outputMessage,
const size_t  maxsize,
char *  errorMessage,
const size_t  errorSize 
)

Function used to cancel a job on a machine with its job id.

Parameters:
hostnamethe name of the machine
jobIdthe id of the job to cancel
outputMessagemessage delivered by the scheduler
maxsizethe maximum length of the buffer where the output message will be stored
errorMessageerror message
errorSizesize of the error message

Here is an example of code using the dietcancel function to cancel a job with ID "bar" on the target machine called "foo":

 #include <stdio.h>
 #include <stdlib.h>
 #include "JobStructures.h"
 #include "diet-bms-lib.h"

 int main(int argc, char* argv[]){
 
 diet_initialize(argv[1], argc, argv);
 
 char* outputMessage = (char*)malloc(255*sizeof(char));
 char* errorMessage = (char*)malloc(1000*sizeof(char));

 dietcancel("foo","bar",outputMessage,255, errorMessage, 1000);
 
 printf("%s\n",outputMessage);
 
 free(outputMessage);
 free(errorMessage);

 diet_finalize();

 }
int dietlist ( const char *  hostname,
listOfJobs_t listOfJobs,
char *  errorMessage,
const size_t  errorSize 
)

Function used to list the jobs on a machine.

Parameters:
hostnamename of the machine
listOfJobsstructure that will at the end contain the list of jobs
errorMessageerror message
errorSizesize of the error message

Here is a example code using the dietlist function to retrieve the existing jobs on a machine called "foo":

 #include <stdio.h>
 #include <stdlib.h>
 #include "JobStructures.h"
 #include "diet-bms-lib.h"
 
 int main(int argc, char* argv[]){
 
 diet_initialize(argv[1], argc, argv);

 listOfJobs_t listOfJobs;
 char* errorMessage = (char*)malloc(1000*sizeof(char));

 dietlist("foo",&listOfJobs,errorMessage,1000);

 printListOfJobs(&listOfJobs);
 
 free(errorMessage);
 
 diet_finalize();
 
 }
int dietNbJobs ( const char *  hostname,
char *  errorMessage,
const size_t  errorSize 
)

Function used to get the number of jobs on a machine.

Parameters:
hostnamename of the machine
errorMessageerror message
errorSizesize of the error message
Returns:
the number of jobs

Here is an example of code using the dietNbJobs function to retrieve the number of jobs on the target machine called "foo":

 #include <stdio.h>
 #include <stdlib.h>
 #include "JobStructures.h"
 #include "diet-bms-lib.h"

 int main(int argc, char* argv[]){
 
 diet_initialize(argv[1], argc, argv);

 char* errorMessage = (char*)malloc(1000*sizeof(char));
 
 int nbJobs = dietNbJobs("Arrakis-2.local", errorMessage, 1000);

 printf("Total number of jobs on %s is %d\n","Arrakis-2.local",nbJobs);

 free(errorMessage);

 diet_finalize();

 }
int dietNbRunningJobs ( const char *  hostname,
char *  errorMessage,
const size_t  errorSize 
)

Function used to get the number of running jobs on a machine.

Parameters:
hostnamename of the machine
errorMessageerror message
errorSizesize of the error message
Returns:
the number of running jobs

Here is an example of code using the dietNbRunningJobs function to retrieve the number of running jobs on the target machine called "foo":

 #include <stdio.h>
 #include <stdlib.h>
 #include "JobStructures.h"
 #include "diet-bms-lib.h"

 int main(int argc, char* argv[]){
 
 diet_initialize(argv[1], argc, argv);

 char* errorMessage = (char*)malloc(1000*sizeof(char));
 
 int nbRunningJobs = dietNbRunningJobs("foo", errorMessage, 1000);

 printf("Total number of running jobs on %s is %d\n","foo",nbRunningJobs);

 free(errorMessage);

 diet_finalize();

 }
int dietNbWaitingJobs ( const char *  hostname,
char *  errorMessage,
const size_t  errorSize 
)

Function used to get the number of waiting jobs on a machine.

Parameters:
hostnamename of the machine
errorMessageerror message
errorSizesize of the error message
Returns:
the number of waiting jobs

Here is an example of code using the dietNbWaitingJobs function to retrieve the number of waiting jobs on the target machine called "foo":

 #include <stdio.h>
 #include <stdlib.h>
 #include "JobStructures.h"
 #include "diet-bms-lib.h"

 int main(int argc, char* argv[]){
 
 diet_initialize(argv[1], argc, argv);

 char* errorMessage = (char*) malloc(1000*sizeof(char));

 int nbWaitingJobs = dietNbWaitingJobs("foo");

 printf("Total number of waiting jobs on %s is %d\n","foo",nbWaitingJobs);

 free(errorMessage);

 diet_finalize();

 }
int dietsubmit ( const char *  hostname,
const char *  scriptPath,
char *  jobID,
const size_t  maxsize,
char *  error_message,
const size_t  error_maxsize 
)

Function used to submit a job on a machine with a script.

Parameters:
hostnamename of the machine
scriptPathpath of the script to submit
jobIDid of the job that has been submitted
maxsizemaximum size of data that should be stored in the jobID variable
error_messagemessage containing the possible error message thrown during the submission
error_maxsizesize of the data that should be stored in the error_message variable

Here is an example of code using the dietsubmit function to submit a job with scrip file bar.txt on the target machine called "foo":

 #include <stdio.h>
 #include <stdlib.h>
 #include "JobStructures.h"
 #include "diet-bms-lib.h"

 int main(int argc, char* argv[]){
 
 diet_initialize(argv[1], argc, argv);
 
 char* jobID = (char*)malloc(255*sizeof(char));

 char* errorMessage = (char*)malloc(1000*sizeof(char));

 dietsubmit("foo","bat.txt", jobID,255, errorMessage, 1000);
 
 printf("%s\n",jobID);
 
 free(jobID);

 diet_finalize();

 }
int printJob ( const job_t job )

Method used to print a job.

Parameters:
joba job to pring
int printListOfJobs ( const listOfJobs_t listOfJobs )

Method used to the a list of jobs.

Parameters:
listOfJobsa list of jobs to print
 All Classes Files Functions Variables