Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members

src/TaskManager.h

00001 /*
00002 K-10 Distributed Processing - Lium, Le Mans
00003 Copyright (C) 2006 Vincent JOUSSE
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018 */
00019 
00020 #ifndef TASKMANAGER_H
00021 #define TASKMANAGER_H
00022 
00023 #include "Task.h"
00024 #include "TaskDataInfo.h"
00025 
00026 #include <prio.h>
00027 
00028 #include <sys/shm.h>
00029 
00030 typedef struct 
00031 {
00032         int running;
00033         int returnVal;
00034 } state_info;
00035 
00043 class TaskManager {
00044 
00045 private :
00049   int mShmid;
00050 
00051   struct share_mem* sharedMem();
00052   char* taskName(struct share_mem* aShared);
00053   state_info* stateInfo(struct share_mem* aShared);
00054 
00059   void setReturnValue(int aReturnValue);
00060 
00064   Task* mTask;
00065 
00069   std::string mTaskPath;
00070 
00074   std::string mIpAddr;
00075 
00079   std::string mAgentPath;
00080 
00084   std::string mMountPoint;
00085 
00094   int forkCommand(const std::string aCommand);
00095 
00099   std::string mHostName;
00100 
00104   std::string mStartTime;
00105 
00109   std::string mEndTime;
00110 
00114   std::string mArchiveName;
00115 
00119   void writeLine(PRFileDesc* fileDest,const char* data);
00120 
00124   static TaskManager* pinstance;
00125 
00126   TaskManager(std::string aIpAddr,std::string aAgentPath,std::string aMountPoint);
00127 
00137   bool copyDataInfo(TaskDataInfo* aData);
00138 
00139 public :
00140   int getInfoShmid() { return mShmid; }
00141   
00147   static TaskManager* Instance(std::string aIpAddr,std::string aAgentPath,std::string aMountPoint);
00148 
00149   ~TaskManager();
00150 
00154   bool isTaskRunning();
00155 
00159   void setTaskRunning(bool isRunning);
00160 
00164   int getReturnValue();
00165 
00166 
00172   bool registerTask(Task* aTask);
00173 
00178   bool executeCurrentTask();
00179 
00184   bool createCurrentTaskSummary();
00185 
00186 
00191   bool archiveCurrentTask();
00192 
00197   bool copyCurrentTaskArchive();
00198 
00203   bool deleteCurrentTaskArchive();
00204 
00208   Task* getTask();
00209 
00212   char* getTaskName();
00213 
00217   static const std::string kLOGS_DIR;
00218 
00219 };
00220 #endif //TASKMANAGER_H

Generated on Fri May 19 23:15:28 2006 for k10-agent by  doxygen 1.4.4