diff options
author | schnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f> | 2005-05-28 12:04:33 +0000 |
---|---|---|
committer | schnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f> | 2005-05-28 12:04:33 +0000 |
commit | 5555ec71ef4be69a2f4425554d030829a33baac2 (patch) | |
tree | 9f3052433dbd2d8e478974e8ccdf682150ca284e /src/announce.cc | |
parent | d41baa0734e66bfe72ffe848ac5fa2fa69ce68f5 (diff) |
Make announcing to the portal work
git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/Formaline/trunk@17 83718e91-0e4f-0410-abf4-91180603181f
Diffstat (limited to 'src/announce.cc')
-rw-r--r-- | src/announce.cc | 257 |
1 files changed, 249 insertions, 8 deletions
diff --git a/src/announce.cc b/src/announce.cc index 2525671..6b11184 100644 --- a/src/announce.cc +++ b/src/announce.cc @@ -4,15 +4,22 @@ #include <cstdio> #include <cstdlib> #include <cstring> +#include <ctime> +#include <iomanip> #include <sstream> #include <string> +#include <sys/types.h> +#include <unistd.h> + #include "cctk.h" #include "cctk_Arguments.h" #include "cctk_Parameters.h" #include "cctk_Version.h" #include "util_Network.h" +#include "http_Content.h" + #include "file.hh" #include "multistorage.hh" #include "portal.hh" @@ -21,21 +28,69 @@ using namespace std; -extern "C" -void -Formaline_Announce (CCTK_ARGUMENTS) +static char * jobid = 0; + + + + // Create a unique job id +static void +create_jobid (CCTK_ARGUMENTS) { + DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; + ostringstream jobidbuf; + + char run_host [1000]; + Util_GetHostName (run_host, sizeof run_host); + jobidbuf << run_host; + jobidbuf << "-"; + +#if 0 + char const * const run_user = CCTK_RunUser(); +#else + char const * const run_user = getenv ("USER"); +#endif + jobidbuf << run_user; + + jobidbuf << "-"; + + time_t const tim = time (0); + struct tm * const ptm = gmtime (& tim); + jobidbuf << setfill ('0') + << setw(4) << ptm->tm_year + << setw(2) << ptm->tm_mon + << setw(2) << ptm->tm_mday + << "-" + << setw(2) << ptm->tm_hour + << setw(2) << ptm->tm_min + << setw(2) << ptm->tm_sec; + + jobidbuf << "-"; + + pid_t const pid = getpid(); + jobidbuf << pid; + + string const jobidstr = jobidbuf.str(); + jobid = strdup (jobidstr.c_str()); +} + + + +extern "C" +void +Formaline_AnnounceInitial (CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; // Only store from the root processor if (CCTK_MyProc (cctkGH) != 0) return; - // Create a unique job id - char const * const jobid = "unique ID"; + create_jobid (cctkGH); @@ -43,18 +98,117 @@ Formaline_Announce (CCTK_ARGUMENTS) if (announce_to_portal) { - stores.add_storage (new portal (jobid)); + stores.add_storage (new portal (jobid, storage::initial)); } if (store_into_file) { - stores.add_storage (new file (jobid)); + stores.add_storage (new file (jobid, storage::initial)); } if (stores.num_storages() == 0) return; + // Information in the Portal/Announce format + { + // Don't know what this is for + stores.store ("jobtype", "default"); + } + { + int type; + void const * const ptr + = CCTK_ParameterGet ("cctk_run_title", "Cactus", & type); + assert (type == PARAMETER_STRING); + char const * const run_title = * static_cast<char const * const *> (ptr); + stores.store ("app_title", run_title); + } + { + char run_date [1000]; + Util_CurrentDate (sizeof run_date, run_date); + char run_time [1000]; + Util_CurrentTime (sizeof run_time, run_time); + ostringstream timebuf; + timebuf << run_date << " " << run_time; + string const timestr = timebuf.str(); + stores.store ("start_time", timestr.c_str()); + } + { + // Don't know what this is for + stores.store ("project_name", ""); + } + { + stores.store ("output_files", out_dir); + } + { + char run_host [1000]; + Util_GetHostName (run_host, sizeof run_host); + stores.store ("host", run_host); + } + { + unsigned long http_port; +#ifdef __HTTP_CONTENT_H__ + if (CCTK_IsThornActive ("HTTPD")) + { + // Thorn is compiled in and active, ask it + http_port = HTTP_Port(); + } + else + { + // Thorn is compiled in but not active, ignore it + http_port = 0; + } +#else + { + // Thorn is not compiled in, ignore it + http_port = 0; + } +#endif + stores.store ("port", (int) http_port); + } + { + stores.store ("portal_username", portal_username); + } + { +#if 0 + char const * const run_user = CCTK_RunUser(); +#else + char const * const run_user = getenv ("USER"); +#endif + stores.store ("local_username", run_user); + } + { + char parameter_filename [10000]; + CCTK_ParameterFilename (sizeof parameter_filename, parameter_filename); + stores.store ("parameter_file", parameter_filename); + } + { + char ** argv; + int argc; + int n; + CCTK_CommandLine (& argv); + for (argc = 0; argv [argc]; ++ argc); + stores.store ("executable", argc == 0 ? "" : argv[0]); + } + { + // Don't know what this is for + stores.store ("data_directory", ""); + } + { + // Could also be "private" + stores.store ("app_visibility", "public"); + } + { + // Could apparently be none, register, update, deregister + stores.store ("notification_reports", ""); + } + { + // Could apparently be none, email, im, sms + stores.store ("notification_methods", ""); + } + + + // Cactus { @@ -122,7 +276,7 @@ Formaline_Announce (CCTK_ARGUMENTS) void const * const ptr = CCTK_ParameterGet ("cctk_run_title", "Cactus", & type); assert (type == PARAMETER_STRING); - char const * const run_title = static_cast<char const *> (ptr); + char const * const run_title = * static_cast<char const * const *> (ptr); stores.store ("run title", run_title); } @@ -151,6 +305,8 @@ Formaline_Announce (CCTK_ARGUMENTS) stores.store ("parameter filename", parameter_filename); } +#if 0 + // This is superfluous, and it does not look nice { char parameter_filename [10000]; char parameter_file [1000000]; @@ -164,6 +320,7 @@ Formaline_Announce (CCTK_ARGUMENTS) parameter_file [count] = '\0'; stores.store ("parameter file", parameter_file); } +#endif { int type; @@ -182,6 +339,7 @@ Formaline_Announce (CCTK_ARGUMENTS) +#if 0 // All Cactus thorns { @@ -269,4 +427,87 @@ Formaline_Announce (CCTK_ARGUMENTS) first = 0; } } +#endif + + + + // Simulation state + + { + stores.store ("cctk_iteration", cctk_iteration); + } +} + + + +extern "C" +void +Formaline_AnnounceUpdate (CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + // Only store from the root processor + if (CCTK_MyProc (cctkGH) != 0) return; + + + + multistorage stores; + + if (announce_to_portal) + { + stores.add_storage (new portal (jobid, storage::update)); + } + + if (store_into_file) + { + stores.add_storage (new file (jobid, storage::update)); + } + + if (stores.num_storages() == 0) return; + + + + // Simulation state + + { + stores.store ("cctk_iteration", cctk_iteration); + } +} + + + +extern "C" +void +Formaline_AnnounceFinal (CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + // Only store from the root processor + if (CCTK_MyProc (cctkGH) != 0) return; + + + + multistorage stores; + + if (announce_to_portal) + { + stores.add_storage (new portal (jobid, storage::final)); + } + + if (store_into_file) + { + stores.add_storage (new file (jobid, storage::final)); + } + + if (stores.num_storages() == 0) return; + + + + // Simulation state + + { + stores.store ("cctk_iteration", cctk_iteration); + } } |