Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
drmaa_tool.h
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2016 The Earlham Institute
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16 
22 #ifndef DRMAA_TOOL_H_
23 #define DRMAA_TOOL_H_
24 
25 #include "drmaa_library.h"
26 #include "typedefs.h"
27 #include "linked_list.h"
28 #include "operation.h"
29 #include "json_util.h"
30 #include "uuid_defs.h"
31 //#include "drmaa.h"
32 #include "grassroots_server.h"
33 
34 
35 
41 #define DRMAA_ID_BUFFER_SIZE (256)
42 
43 /* forward declaration */
44 struct drmaa_job_template_s;
45 
56 typedef struct DrmaaTool
57 {
59  char *dt_program_name_s;
60  LinkedList *dt_args_p;
61  char *dt_queue_name_s;
62  char *dt_working_directory_s;
63 
64  struct drmaa_job_template_s *dt_job_p;
65  char *dt_grassroots_uuid_s;
66  char dt_id_s [DRMAA_ID_BUFFER_SIZE];
67 
68  char dt_id_out_s [DRMAA_ID_BUFFER_SIZE];
69 
71  char *dt_output_filename_s;
72  uint32 dt_num_cores;
73  uint32 dt_mb_mem_usage;
74  char *dt_host_name_s;
75  char *dt_user_name_s;
76  char **dt_email_addresses_ss;
77 
78 
79  char *dt_environment_s;
80 
81  bool (*dt_run_fn) (struct DrmaaTool *tool_p, const bool async_flag);
82 
83  OperationStatus (*dt_get_status_fn) (struct DrmaaTool *tool_p);
84 
85 } DrmaaTool;
86 
87 
88 
89 #ifdef __cplusplus
90 extern "C"
91 {
92 #endif
93 
106 GRASSROOTS_DRMAA_API bool InitDrmaa (void);
107 
108 
118 GRASSROOTS_DRMAA_API bool ExitDrmaa (void);
119 
120 
121 
130 GRASSROOTS_DRMAA_API DrmaaTool *AllocateDrmaaTool (const char *program_name_s, const uuid_t id, GrassrootsServer *grassroots_p);
131 
132 
142 GRASSROOTS_DRMAA_API bool InitDrmaaTool (DrmaaTool *tool_p, const char *program_name_s, const uuid_t id, GrassrootsServer *grassroots_p);
143 
144 
155 
156 
164 
165 
175 GRASSROOTS_DRMAA_API bool SetDrmaaToolCurrentWorkingDirectory (DrmaaTool *tool_p, const char *path_s);
176 
186 GRASSROOTS_DRMAA_API bool SetDrmaaToolQueueName (DrmaaTool *tool_p, const char *queue_name_s);
187 
188 
189 
199 GRASSROOTS_DRMAA_API bool SetDrmaaToolEnvVars (DrmaaTool *tool_p, const char *env_vars_s);
200 
201 
210 GRASSROOTS_DRMAA_API bool SetDrmaaToolCores (DrmaaTool *tool_p, uint32 num_cores);
211 
212 
221 GRASSROOTS_DRMAA_API bool SetDrmaaToolMemory (DrmaaTool *tool_p, uint32 mem);
222 
223 
233 GRASSROOTS_DRMAA_API bool SetDrmaaToolHostName (DrmaaTool *tool_p, const char *host_name_s);
234 
235 
244 GRASSROOTS_DRMAA_API bool SetDrmaaToolJobId (DrmaaTool *tool_p, const char *id_s);
245 
246 
255 GRASSROOTS_DRMAA_API bool SetDrmaaToolJobOutId (DrmaaTool *tool_p, const char *id_s);
256 
257 
267 GRASSROOTS_DRMAA_API bool SetDrmaaToolJobName (DrmaaTool *tool_p, const char *job_name_s);
268 
269 
279 GRASSROOTS_DRMAA_API bool SetDrmaaToolOutputFilename (DrmaaTool *tool_p, const char *output_name_s);
280 
281 
291 GRASSROOTS_DRMAA_API bool AddDrmaaToolArgument (DrmaaTool *tool_p, const char *arg_s);
292 
293 
307 GRASSROOTS_DRMAA_API bool RunDrmaaTool (DrmaaTool *tool_p, const bool async_flag, const char * const log_s);
308 
309 
318 
319 
320 
329 GRASSROOTS_DRMAA_API bool SetDrmaaToolEmailNotifications (DrmaaTool *tool_p, const char **email_addresses_ss);
330 
331 
340 GRASSROOTS_DRMAA_API json_t *ConvertDrmaaToolToJSON (const DrmaaTool * const tool_p);
341 
342 
351 GRASSROOTS_DRMAA_API DrmaaTool *ConvertDrmaaToolFromJSON (const json_t * const json_p, GrassrootsServer *grassroots_p);
352 
353 
363 GRASSROOTS_DRMAA_API unsigned char *SerialiseDrmaaTool (const DrmaaTool * const job_p, const size_t *size_p);
364 
365 
374 GRASSROOTS_DRMAA_API DrmaaTool *DeserialiseDrmaaTool (const unsigned char * const data_s);
375 
376 #ifdef __cplusplus
377 }
378 #endif
379 
380 #endif /* DRMAA_TOOL_H_ */
DrmaaTool::SetDrmaaToolQueueName
bool SetDrmaaToolQueueName(DrmaaTool *tool_p, const char *queue_name_s)
Set the queue name that a DrmaaTool will set for run its program on.
DrmaaTool::SetDrmaaToolCurrentWorkingDirectory
bool SetDrmaaToolCurrentWorkingDirectory(DrmaaTool *tool_p, const char *path_s)
Set the current working directory for a DrmaaTool.
DrmaaTool::SetDrmaaToolJobName
bool SetDrmaaToolJobName(DrmaaTool *tool_p, const char *job_name_s)
Set the program that a DrmaaTool will run.
DrmaaTool::GetDrmaaToolStatus
OperationStatus GetDrmaaToolStatus(DrmaaTool *tool_p)
Get the status of job for a DrmaaTool.
DrmaaTool::InitDrmaaTool
bool InitDrmaaTool(DrmaaTool *tool_p, const char *program_name_s, const uuid_t id, GrassrootsServer *grassroots_p)
Initialise a DrmaaTool to run the given program.
DRMAA_ID_BUFFER_SIZE
#define DRMAA_ID_BUFFER_SIZE
The default buffer size used for storing job ids.
Definition: drmaa_tool.h:41
operation.h
DrmaaTool::FreeDrmaaTool
void FreeDrmaaTool(DrmaaTool *tool_p)
Free a DrmaaTool.
DrmaaTool::SetDrmaaToolJobId
bool SetDrmaaToolJobId(DrmaaTool *tool_p, const char *id_s)
Set the id that represents the job that a DrmaaTool will run.
DrmaaTool::AllocateDrmaaTool
DrmaaTool * AllocateDrmaaTool(const char *program_name_s, const uuid_t id, GrassrootsServer *grassroots_p)
Allocate a DrmaaTool to run the given program.
grassroots_server.h
DrmaaTool::SetDrmaaToolJobOutId
bool SetDrmaaToolJobOutId(DrmaaTool *tool_p, const char *id_s)
Set the id that represents the job output that a DrmaaTool will run.
DrmaaTool::ConvertDrmaaToolToJSON
json_t * ConvertDrmaaToolToJSON(const DrmaaTool *const tool_p)
Serialise the DrmaaTool into a JSON fragment.
DrmaaTool::ClearDrmaaTool
void ClearDrmaaTool(DrmaaTool *tool_p)
Clear a DrmaaTool.
GRASSROOTS_DRMAA_API
#define GRASSROOTS_DRMAA_API
Definition: drmaa_library.h:46
uuid_defs.h
typedefs.h
DrmaaTool::SetDrmaaToolMemory
bool SetDrmaaToolMemory(DrmaaTool *tool_p, uint32 mem)
Set the amount of memory that a DrmaaTool will set for its program when it runs.
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
DrmaaTool::RunDrmaaTool
bool RunDrmaaTool(DrmaaTool *tool_p, const bool async_flag, const char *const log_s)
Run a DrmaaTool.
OperationStatus
OperationStatus
The current status of an Operation.
Definition: operation.h:96
DrmaaTool::SetDrmaaToolEnvVars
bool SetDrmaaToolEnvVars(DrmaaTool *tool_p, const char *env_vars_s)
Set the environment variables that a DrmaaTool will set when it runs its program.
DrmaaTool::SetDrmaaToolEmailNotifications
bool SetDrmaaToolEmailNotifications(DrmaaTool *tool_p, const char **email_addresses_ss)
Set the email recipients for any job notifications for a DrmaaTool.
GrassrootsServer
Definition: grassroots_server.h:45
InitDrmaa
bool InitDrmaa(void)
Initialise a DRMAA session.
ExitDrmaa
bool ExitDrmaa(void)
Close a DRMAA session.
DrmaaTool::DeserialiseDrmaaTool
DrmaaTool * DeserialiseDrmaaTool(const unsigned char *const data_s)
Create a DrmaaTool from an unsigned char array.
DrmaaTool::ConvertDrmaaToolFromJSON
DrmaaTool * ConvertDrmaaToolFromJSON(const json_t *const json_p, GrassrootsServer *grassroots_p)
Deserialise a DrmaaTool from a JSON fragment.
DrmaaTool::AddDrmaaToolArgument
bool AddDrmaaToolArgument(DrmaaTool *tool_p, const char *arg_s)
Add an argument to the program that a DrmaaTool will run.
linked_list.h
A doubly-linked list.
DrmaaTool::SetDrmaaToolHostName
bool SetDrmaaToolHostName(DrmaaTool *tool_p, const char *host_name_s)
Set the host that a DrmaaTool will set for run its program on.
DrmaaTool
A Tool for running Drmaa jobs.
Definition: drmaa_tool.h:56
drmaa_library.h
json_util.h
DrmaaTool::SetDrmaaToolOutputFilename
bool SetDrmaaToolOutputFilename(DrmaaTool *tool_p, const char *output_name_s)
Redirect the stdout/stderr streams from a DrmaaTool to a file.
DrmaaTool::SetDrmaaToolCores
bool SetDrmaaToolCores(DrmaaTool *tool_p, uint32 num_cores)
Set the number of cores that a DrmaaTool will use when it runs.
DrmaaTool::SerialiseDrmaaTool
unsigned char * SerialiseDrmaaTool(const DrmaaTool *const job_p, const size_t *size_p)
Convert a DrmaaTool into a raw unsigned char array for use with the APRJobsManager.
uuid_t
Definition: windows_uuid.h:43