Skip to content
Snippets Groups Projects
Commit f35135de authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Added the missing DriveState and DriveSTatus data structures

parent 0582c698
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@ set (COMMON_LIB_SRC_FILES
dataStructures/Dedication.cpp
dataStructures/DeleteArchiveRequest.cpp
dataStructures/DRData.cpp
dataStructures/DriveState.cpp
dataStructures/EntryLog.cpp
dataStructures/ListStorageClassRequest.cpp
dataStructures/ReadTestResult.cpp
......
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common/dataStructures/DriveState.hpp"
#include "common/exception/Exception.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::dataStructures::DriveState::DriveState() {
m_bytesTransferedInSessionSet = false;
m_currentStateStartTimeSet = false;
m_currentTapePoolSet = false;
m_currentVidSet = false;
m_filesTransferedInSessionSet = false;
m_latestBandwidthSet = false;
m_logicalLibrarySet = false;
m_mountTypeSet = false;
m_nameSet = false;
m_sessionIdSet = false;
m_sessionStartTimeSet = false;
m_statusSet = false;
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
cta::dataStructures::DriveState::~DriveState() throw() {
}
//------------------------------------------------------------------------------
// allFieldsSet
//------------------------------------------------------------------------------
bool cta::dataStructures::DriveState::allFieldsSet() const {
return m_bytesTransferedInSessionSet
&& m_currentStateStartTimeSet
&& m_currentTapePoolSet
&& m_currentVidSet
&& m_filesTransferedInSessionSet
&& m_latestBandwidthSet
&& m_logicalLibrarySet
&& m_mountTypeSet
&& m_nameSet
&& m_sessionIdSet
&& m_sessionStartTimeSet
&& m_statusSet;
}
//------------------------------------------------------------------------------
// setBytesTransferedInSession
//------------------------------------------------------------------------------
void cta::dataStructures::DriveState::setBytesTransferedInSession(const uint64_t bytesTransferedInSession) {
m_bytesTransferedInSession = bytesTransferedInSession;
m_bytesTransferedInSessionSet = true;
}
//------------------------------------------------------------------------------
// getBytesTransferedInSession
//------------------------------------------------------------------------------
uint64_t cta::dataStructures::DriveState::getBytesTransferedInSession() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the DriveState have been set!");
}
return m_bytesTransferedInSession;
}
//------------------------------------------------------------------------------
// setCurrentStateStartTime
//------------------------------------------------------------------------------
void cta::dataStructures::DriveState::setCurrentStateStartTime(const time_t &currentStateStartTime) {
m_currentStateStartTime = currentStateStartTime;
m_currentStateStartTimeSet = true;
}
//------------------------------------------------------------------------------
// getCurrentStateStartTime
//------------------------------------------------------------------------------
time_t cta::dataStructures::DriveState::getCurrentStateStartTime() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the DriveState have been set!");
}
return m_currentStateStartTime;
}
//------------------------------------------------------------------------------
// setCurrentTapePool
//------------------------------------------------------------------------------
void cta::dataStructures::DriveState::setCurrentTapePool(const std::string &currentTapePool) {
m_currentTapePool = currentTapePool;
m_currentTapePoolSet = true;
}
//------------------------------------------------------------------------------
// getCurrentTapePool
//------------------------------------------------------------------------------
std::string cta::dataStructures::DriveState::getCurrentTapePool() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the DriveState have been set!");
}
return m_currentTapePool;
}
//------------------------------------------------------------------------------
// setCurrentVid
//------------------------------------------------------------------------------
void cta::dataStructures::DriveState::setCurrentVid(const std::string &currentVid) {
m_currentVid = currentVid;
m_currentVidSet = true;
}
//------------------------------------------------------------------------------
// getCurrentVid
//------------------------------------------------------------------------------
std::string cta::dataStructures::DriveState::getCurrentVid() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the DriveState have been set!");
}
return m_currentVid;
}
//------------------------------------------------------------------------------
// setFilesTransferedInSession
//------------------------------------------------------------------------------
void cta::dataStructures::DriveState::setFilesTransferedInSession(const uint64_t filesTransferedInSession) {
m_filesTransferedInSession = filesTransferedInSession;
m_filesTransferedInSessionSet = true;
}
//------------------------------------------------------------------------------
// getFilesTransferedInSession
//------------------------------------------------------------------------------
uint64_t cta::dataStructures::DriveState::getFilesTransferedInSession() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the DriveState have been set!");
}
return m_filesTransferedInSession;
}
//------------------------------------------------------------------------------
// setLatestBandwidth
//------------------------------------------------------------------------------
void cta::dataStructures::DriveState::setLatestBandwidth(const double &latestBandwidth) {
m_latestBandwidth = latestBandwidth;
m_latestBandwidthSet = true;
}
//------------------------------------------------------------------------------
// getLatestBandwidth
//------------------------------------------------------------------------------
double cta::dataStructures::DriveState::getLatestBandwidth() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the DriveState have been set!");
}
return m_latestBandwidth;
}
//------------------------------------------------------------------------------
// setLogicalLibrary
//------------------------------------------------------------------------------
void cta::dataStructures::DriveState::setLogicalLibrary(const std::string &logicalLibrary) {
m_logicalLibrary = logicalLibrary;
m_logicalLibrarySet = true;
}
//------------------------------------------------------------------------------
// getLogicalLibrary
//------------------------------------------------------------------------------
std::string cta::dataStructures::DriveState::getLogicalLibrary() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the DriveState have been set!");
}
return m_logicalLibrary;
}
//------------------------------------------------------------------------------
// setMountType
//------------------------------------------------------------------------------
void cta::dataStructures::DriveState::setMountType(const cta::dataStructures::MountType &mountType) {
m_mountType = mountType;
m_mountTypeSet = true;
}
//------------------------------------------------------------------------------
// getMountType
//------------------------------------------------------------------------------
cta::dataStructures::MountType cta::dataStructures::DriveState::getMountType() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the DriveState have been set!");
}
return m_mountType;
}
//------------------------------------------------------------------------------
// setName
//------------------------------------------------------------------------------
void cta::dataStructures::DriveState::setName(const std::string &name) {
m_name = name;
m_nameSet = true;
}
//------------------------------------------------------------------------------
// getName
//------------------------------------------------------------------------------
std::string cta::dataStructures::DriveState::getName() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the DriveState have been set!");
}
return m_name;
}
//------------------------------------------------------------------------------
// setSessionId
//------------------------------------------------------------------------------
void cta::dataStructures::DriveState::setSessionId(const uint64_t sessionId) {
m_sessionId = sessionId;
m_sessionIdSet = true;
}
//------------------------------------------------------------------------------
// getSessionId
//------------------------------------------------------------------------------
uint64_t cta::dataStructures::DriveState::getSessionId() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the DriveState have been set!");
}
return m_sessionId;
}
//------------------------------------------------------------------------------
// setSessionStartTime
//------------------------------------------------------------------------------
void cta::dataStructures::DriveState::setSessionStartTime(const time_t &sessionStartTime) {
m_sessionStartTime = sessionStartTime;
m_sessionStartTimeSet = true;
}
//------------------------------------------------------------------------------
// getSessionStartTime
//------------------------------------------------------------------------------
time_t cta::dataStructures::DriveState::getSessionStartTime() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the DriveState have been set!");
}
return m_sessionStartTime;
}
//------------------------------------------------------------------------------
// setStatus
//------------------------------------------------------------------------------
void cta::dataStructures::DriveState::setStatus(const cta::dataStructures::DriveStatus &status) {
m_status = status;
m_statusSet = true;
}
//------------------------------------------------------------------------------
// getStatus
//------------------------------------------------------------------------------
cta::dataStructures::DriveStatus cta::dataStructures::DriveState::getStatus() const {
if(!allFieldsSet()) {
throw cta::exception::Exception(std::string(__FUNCTION__)+" Error: not all fields of the DriveState have been set!");
}
return m_status;
}
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <list>
#include <map>
#include <stdint.h>
#include <string>
#include "common/dataStructures/DriveStatus.hpp"
#include "common/dataStructures/MountType.hpp"
namespace cta {
namespace dataStructures {
class DriveState {
public:
/**
* Constructor
*/
DriveState();
/**
* Destructor
*/
~DriveState() throw();
void setBytesTransferedInSession(const uint64_t bytesTransferedInSession);
uint64_t getBytesTransferedInSession() const;
void setCurrentStateStartTime(const time_t &currentStateStartTime);
time_t getCurrentStateStartTime() const;
void setCurrentTapePool(const std::string &currentTapePool);
std::string getCurrentTapePool() const;
void setCurrentVid(const std::string &currentVid);
std::string getCurrentVid() const;
void setFilesTransferedInSession(const uint64_t filesTransferedInSession);
uint64_t getFilesTransferedInSession() const;
void setLatestBandwidth(const double &latestBandwidth);
double getLatestBandwidth() const;
void setLogicalLibrary(const std::string &logicalLibrary);
std::string getLogicalLibrary() const;
void setMountType(const cta::dataStructures::MountType &mountType);
cta::dataStructures::MountType getMountType() const;
void setName(const std::string &name);
std::string getName() const;
void setSessionId(const uint64_t sessionId);
uint64_t getSessionId() const;
void setSessionStartTime(const time_t &sessionStartTime);
time_t getSessionStartTime() const;
void setStatus(const cta::dataStructures::DriveStatus &status);
cta::dataStructures::DriveStatus getStatus() const;
private:
/**
* @return true if all fields have been set, false otherwise
*/
bool allFieldsSet() const;
uint64_t m_bytesTransferedInSession;
bool m_bytesTransferedInSessionSet;
time_t m_currentStateStartTime;
bool m_currentStateStartTimeSet;
std::string m_currentTapePool;
bool m_currentTapePoolSet;
std::string m_currentVid;
bool m_currentVidSet;
uint64_t m_filesTransferedInSession;
bool m_filesTransferedInSessionSet;
double m_latestBandwidth;
bool m_latestBandwidthSet;
std::string m_logicalLibrary;
bool m_logicalLibrarySet;
cta::dataStructures::MountType m_mountType;
bool m_mountTypeSet;
std::string m_name;
bool m_nameSet;
uint64_t m_sessionId;
bool m_sessionIdSet;
time_t m_sessionStartTime;
bool m_sessionStartTimeSet;
cta::dataStructures::DriveStatus m_status;
bool m_statusSet;
}; // class DriveState
} // namespace dataStructures
} // namespace cta
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
namespace cta {
namespace dataStructures {
enum DriveStatus {
Down,
Up,
Starting,
Mounting,
Transfering,
Unloading,
Unmounting,
DrainingToDisk,
CleaningUp
};
} // namespace dataStructures
} // namespace cta
......@@ -21,6 +21,7 @@
namespace cta {
namespace dataStructures {
enum MountType {
none,
read,
write
};
......
......@@ -18,6 +18,42 @@
#pragma once
#include "common/dataStructures/AdminHost.hpp"
#include "common/dataStructures/AdminUser.hpp"
#include "common/dataStructures/ArchiveFile.hpp"
#include "common/dataStructures/ArchiveJob.hpp"
#include "common/dataStructures/ArchiveMount.hpp"
#include "common/dataStructures/ArchiveRequest.hpp"
#include "common/dataStructures/ArchiveRoute.hpp"
#include "common/dataStructures/CancelRetrieveRequest.hpp"
#include "common/dataStructures/Dedication.hpp"
#include "common/dataStructures/DeleteArchiveRequest.hpp"
#include "common/dataStructures/DRData.hpp"
#include "common/dataStructures/EntryLog.hpp"
#include "common/dataStructures/ListStorageClassRequest.hpp"
#include "common/dataStructures/LogicalLibrary.hpp"
#include "common/dataStructures/MountType.hpp"
#include "common/dataStructures/ReadTestResult.hpp"
#include "common/dataStructures/RepackInfo.hpp"
#include "common/dataStructures/RepackType.hpp"
#include "common/dataStructures/Requester.hpp"
#include "common/dataStructures/RetrieveJob.hpp"
#include "common/dataStructures/RetrieveMount.hpp"
#include "common/dataStructures/RetrieveRequest.hpp"
#include "common/dataStructures/SecurityIdentity.hpp"
#include "common/dataStructures/StorageClass.hpp"
#include "common/dataStructures/TapeFileLocation.hpp"
#include "common/dataStructures/Tape.hpp"
#include "common/dataStructures/TapeMount.hpp"
#include "common/dataStructures/TapePool.hpp"
#include "common/dataStructures/UpdateFileInfoRequest.hpp"
#include "common/dataStructures/UserGroup.hpp"
#include "common/dataStructures/User.hpp"
#include "common/dataStructures/UserIdentity.hpp"
#include "common/dataStructures/VerifyInfo.hpp"
#include "common/dataStructures/VerifyType.hpp"
#include "common/dataStructures/WriteTestResult.hpp"
#include "common/exception/Exception.hpp"
#include "scheduler/SchedulerDatabase.hpp"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment