diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-12-05 13:56:23 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-12-05 13:56:23 +0000 |
commit | 6aa0b9eb1b7bed77d8c4a7727a7f66c52439167f (patch) | |
tree | b1fa98ab6baea93eed373fc6a1e1ab7d45e6c1f7 | |
parent | 0b9510a7354279a4f85c13ce204474404daa470a (diff) | |
download | gnunet-6aa0b9eb1b7bed77d8c4a7727a7f66c52439167f.tar.gz gnunet-6aa0b9eb1b7bed77d8c4a7727a7f66c52439167f.zip |
- Loadleveler code
-rw-r--r-- | src/testbed/Makefile.am | 15 | ||||
-rw-r--r-- | src/testbed/ll_master.c | 92 | ||||
-rw-r--r-- | src/testbed/ll_monitor.c | 76 | ||||
-rwxr-xr-x | src/testbed/sample.job | 16 |
4 files changed, 194 insertions, 5 deletions
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am index a4adb026d..d8cc9a207 100644 --- a/src/testbed/Makefile.am +++ b/src/testbed/Makefile.am | |||
@@ -10,7 +10,9 @@ if USE_COVERAGE | |||
10 | endif | 10 | endif |
11 | 11 | ||
12 | if WITH_LL | 12 | if WITH_LL |
13 | ll_binaries = ll-master | 13 | ll_binaries = \ |
14 | ll-master \ | ||
15 | ll-monitor | ||
14 | endif | 16 | endif |
15 | 17 | ||
16 | libexecdir= $(pkglibdir)/libexec/ | 18 | libexecdir= $(pkglibdir)/libexec/ |
@@ -61,7 +63,13 @@ gnunet_helper_testbed_DEPENDENCIES = \ | |||
61 | ll_master_SOURCES = \ | 63 | ll_master_SOURCES = \ |
62 | ll_master.c | 64 | ll_master.c |
63 | ll_master_LDADD = $(XLIB) \ | 65 | ll_master_LDADD = $(XLIB) \ |
64 | $(LTLIBINTL) -lz | 66 | $(top_builddir)/src/util/libgnunetutil.la \ |
67 | $(LTLIBINTL) -lz -lllapi | ||
68 | |||
69 | ll_monitor_SOURCES = \ | ||
70 | ll_monitor.c | ||
71 | ll_monitor_LDADD = $(XLIB) \ | ||
72 | $(LTLIBINTL) -lz -lllapi | ||
65 | 73 | ||
66 | lib_LTLIBRARIES = \ | 74 | lib_LTLIBRARIES = \ |
67 | libgnunettestbed.la | 75 | libgnunettestbed.la |
@@ -272,4 +280,5 @@ EXTRA_DIST = \ | |||
272 | test_testbed_api_testbed_run_topologyfromfile.conf \ | 280 | test_testbed_api_testbed_run_topologyfromfile.conf \ |
273 | test_testbed_api_testbed_run_topologyscalefree.conf \ | 281 | test_testbed_api_testbed_run_topologyscalefree.conf \ |
274 | overlay_topology.txt \ | 282 | overlay_topology.txt \ |
275 | sample_hosts.txt | 283 | sample_hosts.txt \ |
284 | sample.job | ||
diff --git a/src/testbed/ll_master.c b/src/testbed/ll_master.c index 4eca0e865..23d121582 100644 --- a/src/testbed/ll_master.c +++ b/src/testbed/ll_master.c | |||
@@ -1,6 +1,94 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testbed/ll_master.c | ||
23 | * @brief The load level master. Creates child processes through LoadLeveler | ||
24 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | ||
25 | */ | ||
26 | |||
27 | #include "platform.h" | ||
28 | #include "gnunet_util_lib.h" | ||
1 | #include <llapi.h> | 29 | #include <llapi.h> |
2 | 30 | ||
3 | int main() | 31 | /** |
32 | * LL job information | ||
33 | */ | ||
34 | static struct LL_job job_info; | ||
35 | |||
36 | /** | ||
37 | * Exit status | ||
38 | */ | ||
39 | static int status; | ||
40 | |||
41 | /** | ||
42 | * Main function that will be run. | ||
43 | * | ||
44 | * @param cls closure | ||
45 | * @param args remaining command-line arguments | ||
46 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | ||
47 | * @param cfg configuration | ||
48 | */ | ||
49 | static void | ||
50 | run (void *cls, char *const *args, const char *cfgfile, | ||
51 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
4 | { | 52 | { |
5 | return 0; | 53 | int ret; |
54 | |||
55 | if (NULL == args[0]) | ||
56 | { | ||
57 | fprintf (stderr, _("Job command file not given. Exiting\n")); | ||
58 | return; | ||
59 | } | ||
60 | ret = llsubmit (args[0], | ||
61 | NULL, //char *monitor_program, | ||
62 | NULL, //char *monitor_arg, | ||
63 | &job_info, | ||
64 | LL_JOB_VERSION); | ||
65 | if (0 != ret) | ||
66 | return; | ||
67 | status = GNUNET_OK; | ||
68 | } | ||
69 | |||
70 | |||
71 | /** | ||
72 | * Main function | ||
73 | * | ||
74 | * @param argc the number of command line arguments | ||
75 | * @param argv command line arg array | ||
76 | * @return return code | ||
77 | */ | ||
78 | int | ||
79 | main (int argc, char **argv) | ||
80 | { | ||
81 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
82 | GNUNET_GETOPT_OPTION_END | ||
83 | }; | ||
84 | int ret; | ||
85 | |||
86 | status = GNUNET_SYSERR; | ||
87 | ret = | ||
88 | GNUNET_PROGRAM_run (argc, argv, "ll-master", | ||
89 | "LoadLeveler master process for starting child processes", options, | ||
90 | &run, NULL); | ||
91 | if (GNUNET_OK != ret) | ||
92 | return 1; | ||
93 | return (GNUNET_OK == status) ? 0 : 1; | ||
6 | } | 94 | } |
diff --git a/src/testbed/ll_monitor.c b/src/testbed/ll_monitor.c new file mode 100644 index 000000000..695655056 --- /dev/null +++ b/src/testbed/ll_monitor.c | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testbed/ll_monitor.c | ||
23 | * @brief The load level monitor process. This is called whenever a job event | ||
24 | * happens. This file is called with the following syntax: | ||
25 | * "monitor_program job_id user_arg state exit_status" | ||
26 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | ||
27 | */ | ||
28 | |||
29 | #include "platform.h" | ||
30 | #include "gnunet_common.h" | ||
31 | #include <llapi.h> | ||
32 | |||
33 | |||
34 | /** | ||
35 | * Main function | ||
36 | * | ||
37 | * @param argc the number of command line arguments | ||
38 | * @param argv command line arg array | ||
39 | * @return return code | ||
40 | */ | ||
41 | int | ||
42 | main (int argc, char **argv) | ||
43 | { | ||
44 | char *job_id; | ||
45 | char *user_arg; | ||
46 | char *state; | ||
47 | char *exit_status; | ||
48 | char *outfile; | ||
49 | FILE *out; | ||
50 | |||
51 | if (5 != argc) | ||
52 | { | ||
53 | fprintf (stderr, "Invalid number of arguments\n"); | ||
54 | return 1; | ||
55 | } | ||
56 | job_id = argv[1]; | ||
57 | user_arg = argv[2]; | ||
58 | state = argv[3]; | ||
59 | exit_status = argv[4]; | ||
60 | PRINTF ("Job id: %s\n", job_id); | ||
61 | PRINTF ("\t User arg: %s \n", user_arg); | ||
62 | PRINTF ("\t Job state: %s \n", state); | ||
63 | PRINTF ("\t Exit status: %s \n", exit_status); | ||
64 | |||
65 | if (-1 == asprintf (&outfile, "job-%s.status", job_id)) | ||
66 | return 1; | ||
67 | out = fopen (outfile, "a"); | ||
68 | if (NULL == out) | ||
69 | return 1; | ||
70 | fprintf (out, "Job id: %s\n", job_id); | ||
71 | fprintf (out, "\t User arg: %s \n", user_arg); | ||
72 | fprintf (out, "\t Job state: %s \n", state); | ||
73 | fprintf (out, "\t Exit status: %s \n", exit_status); | ||
74 | fclose (out); | ||
75 | return 0; | ||
76 | } | ||
diff --git a/src/testbed/sample.job b/src/testbed/sample.job new file mode 100755 index 000000000..da3ee47f4 --- /dev/null +++ b/src/testbed/sample.job | |||
@@ -0,0 +1,16 @@ | |||
1 | #!/bin/bash | ||
2 | # This job command file is called job.cmd | ||
3 | #@ job_type = parallel | ||
4 | #@ class = general | ||
5 | #@ node = 1 | ||
6 | #@ output = job$(jobid).out | ||
7 | #@ error = job$(jobid).err | ||
8 | #@ total_tasks=16 | ||
9 | #@ wall_clock_limit = 0:0:1 | ||
10 | #@ network.MPI = sn_all,not_shared,us | ||
11 | ##@ ... other LoadLeveler keywords (see below) | ||
12 | #@ notification = always | ||
13 | #@ notify_user = totakura@in.tum.de | ||
14 | #@ queue | ||
15 | |||
16 | #@ executable = /bin/bash | ||