00001
00002
00003 #ifndef __ARC_DTRSTATUS_H__
00004 #define __ARC_DTRSTATUS_H__
00005
00006 #include <string>
00007 #include <vector>
00008
00009 namespace DataStaging {
00010
00012 class DTRStatus {
00013
00014 public:
00015
00017 enum DTRStatusType {
00018
00019
00020
00022 NEW,
00023
00025 CHECK_CACHE,
00026
00028 CHECKING_CACHE,
00029
00031 CACHE_WAIT,
00032
00034 CACHE_CHECKED,
00035
00037 RESOLVE,
00038
00040 RESOLVING,
00041
00043 RESOLVED,
00044
00046 QUERY_REPLICA,
00047
00049 QUERYING_REPLICA,
00050
00052 REPLICA_QUERIED,
00053
00055 PRE_CLEAN,
00056
00058 PRE_CLEANING,
00059
00061 PRE_CLEANED,
00062
00064 STAGE_PREPARE,
00065
00067 STAGING_PREPARING,
00068
00070 STAGING_PREPARING_WAIT,
00071
00073 STAGED_PREPARED,
00074
00076 TRANSFER,
00077
00079 TRANSFERRING,
00080
00082 TRANSFERRING_CANCEL,
00083
00085 TRANSFERRED,
00086
00088 RELEASE_REQUEST,
00089
00091 RELEASING_REQUEST,
00092
00094 REQUEST_RELEASED,
00095
00097 REGISTER_REPLICA,
00098
00100 REGISTERING_REPLICA,
00101
00103 REPLICA_REGISTERED,
00104
00106 PROCESS_CACHE,
00107
00109 PROCESSING_CACHE,
00110
00112 CACHE_PROCESSED,
00113
00115 DONE,
00116
00118 CANCELLED,
00119
00121 CANCELLED_FINISHED,
00122
00124 ERROR,
00125
00127 NULL_STATE
00128
00129 };
00130
00132 DTRStatus(const DTRStatusType& status, std::string desc="")
00133 : status(status), desc(desc) {}
00135 DTRStatus()
00136 : status(NEW), desc ("") {}
00137
00139 bool operator==(const DTRStatusType& s) const {
00140 return status == s;
00141 }
00143 bool operator==(const DTRStatus& s) const {
00144 return status == s.status;
00145 }
00146
00147
00149 bool operator!=(const DTRStatusType& s) const {
00150 return status != s;
00151 }
00153 bool operator!=(const DTRStatus& s) const {
00154 return status != s.status;
00155 }
00156
00158 DTRStatus& operator=(const DTRStatusType& s) {
00159 status = s;
00160 return *this;
00161 }
00162
00164 std::string str() const;
00165
00167 void SetDesc(const std::string& d) {
00168 desc = d;
00169 }
00170
00172 std::string GetDesc() const {
00173 return desc;
00174 }
00175
00177 DTRStatusType GetStatus() const {
00178 return status;
00179 }
00180
00181
00183 static const std::vector<DTRStatus::DTRStatusType> ToProcessStates;
00185 static const std::vector<DTRStatus::DTRStatusType> ProcessingStates;
00186
00188 static const std::vector<DTRStatus::DTRStatusType> StagedStates;
00189
00190 private:
00191
00193 DTRStatusType status;
00195 std::string desc;
00196
00197 };
00198
00200 class DTRErrorStatus {
00201
00202 public:
00203
00205 enum DTRErrorStatusType {
00206
00208 NONE_ERROR,
00209
00211 INTERNAL_LOGIC_ERROR,
00212
00214 INTERNAL_PROCESS_ERROR,
00215
00217 SELF_REPLICATION_ERROR,
00218
00220 CACHE_ERROR,
00221
00223 TEMPORARY_REMOTE_ERROR,
00224
00226 PERMANENT_REMOTE_ERROR,
00227
00229 LOCAL_FILE_ERROR,
00230
00232 TRANSFER_SPEED_ERROR,
00233
00235 STAGING_TIMEOUT_ERROR
00236 };
00237
00239 enum DTRErrorLocation {
00240
00242 NO_ERROR_LOCATION,
00243
00245 ERROR_SOURCE,
00246
00248 ERROR_DESTINATION,
00249
00251 ERROR_TRANSFER,
00252
00254 ERROR_UNKNOWN
00255 };
00256
00258 DTRErrorStatus(DTRErrorStatusType status,
00259 DTRStatus::DTRStatusType error_state,
00260 DTRErrorLocation location,
00261 const std::string& desc = ""):
00262 error_status(status),
00263 last_error_state(error_state),
00264 error_location(location),
00265 desc(desc) {};
00266
00268 DTRErrorStatus() :
00269 error_status(NONE_ERROR),
00270 last_error_state(DTRStatus::NULL_STATE),
00271 error_location(NO_ERROR_LOCATION),
00272 desc("") {};
00273
00275 DTRErrorStatusType GetErrorStatus() const {
00276 return error_status;
00277 }
00278
00280 DTRStatus::DTRStatusType GetLastErrorState() const {
00281 return last_error_state.GetStatus();
00282 }
00283
00285 DTRErrorLocation GetErrorLocation() const {
00286 return error_location;
00287 }
00288
00290 std::string GetDesc() const {
00291 return desc;
00292 }
00293
00295 bool operator==(const DTRErrorStatusType& s) const {
00296 return error_status == s;
00297 }
00299 bool operator==(const DTRErrorStatus& s) const {
00300 return error_status == s.error_status;
00301 }
00302
00304 bool operator!=(const DTRErrorStatusType& s) const {
00305 return error_status != s;
00306 }
00308 bool operator!=(const DTRErrorStatus& s) const {
00309 return error_status != s.error_status;
00310 }
00311
00313 DTRErrorStatus& operator=(const DTRErrorStatusType& s) {
00314 error_status = s;
00315 return *this;
00316 }
00317
00318 private:
00320 DTRErrorStatusType error_status;
00322 DTRStatus last_error_state;
00324 DTRErrorLocation error_location;
00326 std::string desc;
00327
00328 };
00329
00330 }
00331
00332 #endif