Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNnet_remoteParallelFileIO32_c.hxx

00001 /******************************************************************
00002  * CAVERNsoft
00003  * Copyright (C) 1994-2000 Electronic Visualization Laboratory,
00004  * all rights reserved
00005  * By Jason Leigh, Yong-joo Cho, Naveen Krishnaprasad, Chris Scharver,
00006  * Stuart Bailey, Atul Nayak, Shalini Venkataraman
00007  * University of Illinois at Chicago
00008  * 
00009  * This publication and its text and code may not be copied for commercial 
00010  * use without the express written permission of the University of Illinois
00011  * at Chicago.
00012  * The contributors disclaim any representation of warranty: use this
00013  * code at your own risk.
00014  * Direct questions, comments etc to cavern@evl.uic.edu
00015  ******************************************************************/
00016 
00017 #ifndef _CAVERNnet_remoteParallelFileIO32_c
00018 #define _CAVERNnet_remoteParallelFileIO32_c
00019 
00020 #include "CAVERN.hxx"
00021 #include "CAVERNnet_extendedParallelTcp_c.hxx"
00022 #include "CAVERNnet_datapack_c.hxx"
00023 #include "CAVERNmisc_fileList_c.hxx"
00024 
00025 #ifdef WIN32
00026 #include <stdlib.h>
00027 #define MAXPATHLEN      MAX_PATH
00028 #else
00029 #include <sys/param.h>
00030 #endif
00031 
00047 class CAVERNnet_remoteParallelFileIOServer32_c {
00048 public:
00052         static const int DEFAULT_PORT/* = 7673*/;
00053 
00055         static const int THREADED/* = 1*/;
00056 
00058         static const int NON_THREADED/* = 0*/;
00059 
00061         int init(int incomingPort=CAVERNnet_remoteParallelFileIOServer32_c::DEFAULT_PORT,
00062                         char* neighborServer = NULL, 
00063                         int neighborPort = CAVERNnet_remoteParallelFileIOServer32_c::DEFAULT_PORT, 
00064                         int storeLocally = 1, int numOfSockets = 5);
00065 
00075         void process(int threaded = CAVERNnet_remoteParallelFileIOServer32_c::NON_THREADED);
00076 
00077         void setRemotePort(int port = CAVERNnet_remoteParallelFileIOServer32_c::DEFAULT_PORT) { 
00078                 neighborPortNumber = port;
00079         }
00080         void setNeighborServer(char* ServerName) { 
00081                 if (ServerName) strcpy(neighborServerName, ServerName);
00082                 else neighborServerName[0] = '\0';
00083         }
00084         void setStore(int StoreLocally) { store = StoreLocally; }
00085 
00086         long getFileSize(FILE* readFile);
00087 
00088         static const int TRANSFERSIZE/* = 30000*/;
00089 
00090 private:
00091         CAVERNnet_extendedParallelTcpServer_c server;
00092         char neighborServerName[MAXPATHLEN];
00093         int neighborPortNumber;
00094         int store;
00095         int numberOfSockets;
00096 
00097         static int getHostIPNumber(char* hostNameOrIP);
00098         static void* threadHandler(void*);
00099 };
00100 
00103 class CAVERNnet_remoteParallelFileIOClient32_c {
00104         public:
00105 
00107 
00108         static const int OK/* = 1*/;
00109 
00111         static const int FAILED/* = 0*/;
00112 
00114         static const int CANNOT_CONNECT/* = 2*/;
00115 
00117         static const int CANNOT_READ_LOCAL_FILE/* = 3*/;
00118 
00120         static const int CANNOT_WRITE_LOCAL_FILE/* = 3*/;
00121 
00123         static const int INVALID_COMMAND/* = 4*/;
00124 
00126         static const int MEM_ALLOC_ERR/* = 5*/;
00127 
00129         static const int FILE_ERROR/* = 6*/;
00130 
00132         static const int EARLIER/* = 7*/;
00133 
00135         static const int LATER/* = 8*/;
00136 
00138         static const int SAME/* = 9*/;
00139 
00141 
00142         CAVERNnet_remoteParallelFileIOClient32_c();
00143 
00145         void setRemotePort(int port = CAVERNnet_remoteParallelFileIOServer32_c::DEFAULT_PORT);
00146 
00155         int upload(char* ipAddress,char* localFileName, char* remoteFileName, int numberOfSockets = 5);
00156 
00165         int download(char* ipAddress, char* localFilename, char* remoteFileName, int numberOfSockets = 5);
00166 
00175         int getRemoteDateTime(char* ipAddress, char* remoteFileName,
00176                               int *remDay, int *remMon, int *remYear,
00177                               int* remHour, int* remMin, int* remSec,
00178                               int numberOfSockets = 1);
00179 #if (defined(__sgi) || defined(linux) || defined(sun))
00180 
00190     int getRemoteFileList(char* ipAddress, char* remotePath, CAVERNmisc_fileInfo_c*& fileList, int* noObjects, int doRecursion = CAVERNmisc_fileList_c::SKIP_RECURSION, int linkTraversal = CAVERNmisc_fileList_c::DO_NOT_TRAVERSE_LINKS, int numberOfSockets = 1);
00191 #endif 
00192 
00197         static int getLocalDateTime(char* filename,
00198                  int *day,
00199                  int *month,
00200                  int *year,
00201                  int *hour,
00202                  int *minute,
00203                  int *second);
00204 
00211         int compareDateTime(int day1, int month1, int year1,
00212                 int hour1, int minute1, int second1,
00213                 int day2, int month2, int year2,
00214                 int hour2, int minute2, int second2);
00215 
00216     //Functions added for performance monitoring interface
00217     
00230     void showStats(char* streamInfo, char* comment);
00231     
00248     int logStats(char* streamInfo, char* comment, FILE* filePtr);
00249 
00264     int sendStats(char* streamInfo, char* comment);
00265 
00279     int initSendStats(char* monitorClientIP, int port = PERF_DAEMON_DEFAULT_PORT);
00280     
00285     void exitSendStats();
00286 
00287 
00288 private:
00289         int remotePort;
00290         CAVERNnet_extendedParallelTcpClient_c client;
00291     CAVERNnet_perfMonitor_c pmonitor;   //for performance monitoring
00292 };
00293 
00294 /*
00295 FORMAT:There are no spaces between fields
00296 CLIENT -> SERVER
00297 u fileNameLen fileName dataSize data
00298 d fileNameLen fileName
00299 
00300 SERVER->CLIENT
00301 d dataSize data
00302 
00303 
00304 What if download file not found?
00305 need to delete thread somehow
00306 */
00307 #endif

Generated at Mon Jul 2 14:24:42 2001 for CAVERNsoft by doxygen1.2.8-20010617 written by Dimitri van Heesch, © 1997-2001