00001 /* 00002 * File: Queue.h 00003 * 00004 * Copyright Jonathan Schaeffer 2009-2010, 00005 * CC-IN2P3, CNRS <jonathan.schaeffer@cc.in2p3.fr> 00006 * Contributors : Andres Gomez, 00007 * CC-IN2P3, CNRS <andres.gomez@cc.in2p3.fr> 00008 * 00009 * This software is a computer program whose purpose is to schedule, sort 00010 * and submit file requests to the hierarchical storage system HPSS. 00011 * 00012 * This software is governed by the CeCILL license under French law and 00013 * abiding by the rules of distribution of free software. You can use, 00014 * modify and/or redistribute the software under the terms of the CeCILL 00015 * license as circulated by CEA, CNRS and INRIA at the following URL 00016 * "http://www.cecill.info". 00017 * 00018 * As a counterpart to the access to the source code and rights to copy, 00019 * modify and redistribute granted by the license, users are provided only 00020 * with a limited warranty and the software's author, the holder of the 00021 * economic rights, and the successive licensors have only limited 00022 * liability. 00023 * 00024 * In this respect, the user's attention is drawn to the risks associated 00025 * with loading, using, modifying and/or developing or reproducing the 00026 * software by the user in light of its specific status of free software, 00027 * that may mean that it is complicated to manipulate, and that also 00028 * therefore means that it is reserved for developers and experienced 00029 * professionals having in-depth computer knowledge. Users are therefore 00030 * encouraged to load and test the software's suitability as regards their 00031 * requirements in conditions enabling the security of their systems and/or 00032 * data to be ensured and, more generally, to use and operate it in the 00033 * same conditions as regards security. 00034 * 00035 * The fact that you are presently reading this means that you have had 00036 * knowledge of the CeCILL license and that you accept its terms. 00037 * 00038 */ 00039 00040 #ifndef QUEUE_H_ 00041 #define QUEUE_H_ 00042 00043 #include <string> 00044 #include <time.h> 00045 #include <map> 00046 #include "QueueStatus.h" 00047 #include "QueueDAO.h" 00048 #include "FilePositionOnTape.h" 00049 #include "Reading.h" 00050 #include "ErrorCode.h" 00051 #include "logger.h" 00052 00053 using namespace log4cxx; 00054 00055 namespace treqs { 00056 00058 00116 class Queue { 00117 public: 00119 Queue(); 00121 00127 Queue(std::string tape, unsigned short int pvrid); 00129 ~Queue(); 00130 00132 time_t getCreationTime(); 00134 unsigned int getCurrentPosition() const; 00136 time_t getEndTime(); 00138 time_t getSuspensionTime(); 00140 00149 Reading* getNextReading(); 00151 00156 std::string getOwnerName() const; 00158 unsigned short int getPVR() const; 00160 QueueStatus getStatus(); 00162 time_t getSubmissionTime(); 00164 unsigned short int getSuspendDuration(); 00165 00167 void setCreationTime(time_t t); 00169 00172 void setCurrentPosition(unsigned int currentPosition); 00174 void setEndTime(time_t t); 00176 void setPVR(unsigned short int p); 00178 void setStatus(QueueStatus qs); 00180 void setSubmissionTime(time_t t); 00182 00187 void setSuspendDuration(unsigned short int d); 00188 00190 00194 void activate(); 00196 00199 void dump(); 00201 void initCreationTime(); 00203 00206 void prepareCleanup(); 00208 00218 bool registerFile(FilePositionOnTape* fpot, unsigned short int r) 00219 throw (Error); 00221 00228 void suspendQueue(); 00230 00236 void unsuspend(); 00237 00238 private: 00240 static LoggerPtr logger; 00242 unsigned long long int byteSize; 00244 time_t creationTime; 00246 unsigned int currentPosition; 00248 00253 time_t endTime; 00255 std::map<unsigned short int, Reading> filesList; 00257 unsigned long id; 00259 unsigned short int nbDone; 00261 unsigned short int nbFailed; 00263 std::string ownerName; 00265 unsigned short int pvr; 00267 unsigned short int maxReadRetries; 00269 QueueStatus status; 00271 time_t submissionTime; 00273 time_t suspensionTime; 00275 unsigned short int suspendDuration; 00276 00278 00281 void countJobs(); 00283 void finalize(); 00285 00289 void setOwnerName(); 00290 }; 00291 }//namespace treqs 00292 #endif /* QUEUE_H_ */