From 9275c5097d530aeaea9058e82cdaa2d07a380f6c Mon Sep 17 00:00:00 2001 From: tradke Date: Wed, 14 Mar 2001 22:28:42 +0000 Subject: Write the hostname / port number information for streamed HDF5 data into a temporary text file which then gets advertised for downloading via the Cactus web interface. It uses MIME type "data/streamed-hdf5". git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOStreamedHDF5/trunk@64 0888f3d4-9f52-45d2-93bc-d00801ff5e46 --- src/Startup.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Startup.c b/src/Startup.c index d8d85e6..198599e 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -15,6 +15,7 @@ #include "cctk_Parameters.h" #include "util_Network.h" #include "BetaThorns/Socket/src/SocketUtils.h" +#include "CactusBase/IOUtil/src/ioutil_AdvertisedFiles.h" #include "CactusBase/IOUtil/src/ioutil_CheckpointRecovery.h" #include "ioStreamedHDF5GH.h" @@ -113,6 +114,13 @@ void IOStreamedHDF5_Terminate (cGH *GH) CCTK_TimerDestroyI (myGH->timers[i]); } } + + /* remove advertised file and free filename */ + if (myGH->advertised_filename) + { + remove (myGH->advertised_filename); + free (myGH->advertised_filename); + } } } @@ -135,6 +143,8 @@ void IOStreamedHDF5_Terminate (cGH *GH) CCTK_RegisterIOMethodTriggerOutput Socket_TCPOpenServerSock Socket_SetNonBlocking + IOUtil_AdvertiseFile + Util_GetHostName CCTK_TimerCreateI CCTK_TimerDestroyI CCTK_TimerResetI @@ -168,8 +178,11 @@ static void *IOStreamedHDF5_SetupGH (tFleshConfig *config, int i; int myproc; int numvars; + char hostname[256]; ioStreamedHDF5GH *myGH; - char hostname[1024]; + FILE *advertised_file_fd; + char advertised_filename[L_tmpnam]; + ioAdvertisedFileDesc advertised_file; /* suppress compiler warnings about unused variables */ @@ -196,6 +209,7 @@ static void *IOStreamedHDF5_SetupGH (tFleshConfig *config, myGH = (ioStreamedHDF5GH *) malloc (sizeof (ioStreamedHDF5GH)); myGH->geo_output = (ioHDF5Geo_t **) calloc (numvars, sizeof (ioHDF5Geo_t *)); myGH->out_last = (int *) malloc (numvars * sizeof (int)); + myGH->advertised_filename = NULL; for (i = 0; i < numvars; i++) { @@ -227,6 +241,32 @@ static void *IOStreamedHDF5_SetupGH (tFleshConfig *config, "HDF5 data streaming service started on\n" " %s:%d", hostname, data_port); + + /* write the hostname/portnumber information in a temporary file + which gets advertised and then can be downloaded */ + myGH->advertised_filename = (char *) malloc (L_tmpnam); + if (tmpnam (myGH->advertised_filename)) + { + advertised_file_fd = fopen (myGH->advertised_filename, "w"); + fprintf (advertised_file_fd, "Hostname: %s\n", hostname); + fprintf (advertised_file_fd, "Data port: %d", data_port); + fclose (advertised_file_fd); + + advertised_file.slice = ""; + advertised_file.thorn = CCTK_THORNSTRING; + advertised_file.varname = "All variables"; + advertised_file.description = "Streamed HDF5 data"; + advertised_file.mimetype = "data/streamed-hdf5"; + + IOUtil_AdvertiseFile (GH, myGH->advertised_filename, &advertised_file); + } + else + { + CCTK_WARN (2, "Couldn't create unique temporary filename " + "for advertising the hostname/portnumber information !"); + free (myGH->advertised_filename); + myGH->advertised_filename = NULL; + } } } -- cgit v1.2.3