diff --git a/CMakeLists.txt b/CMakeLists.txt index b49e3b51a16122cdb917b108771dbc9bfb095154..d2b0178b1454040ec28fecc6a8f5b5f9529c041e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,7 @@ ELSE(DEFINED PackageOnly) include_directories(${PROJECT_SOURCE_DIR}) include_directories(${CMAKE_BINARY_DIR}) + add_subdirectory(catalogue) add_subdirectory(cmdline) add_subdirectory(common) add_subdirectory(objectstore) diff --git a/catalogue/CMakeLists.txt b/catalogue/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..739bd2834859040c84540a2e2a5f75bf7d34c754 --- /dev/null +++ b/catalogue/CMakeLists.txt @@ -0,0 +1,23 @@ +# 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/>. +cmake_minimum_required (VERSION 2.6) + +set (CATALOGUE_LIB_SRC_FILES + Catalogue.cpp + MockCatalogue.cpp) + +add_library (ctacatalogue + ${CATALOGUE_LIB_SRC_FILES}) diff --git a/catalogue/Catalogue.cpp b/catalogue/Catalogue.cpp new file mode 100644 index 0000000000000000000000000000000000000000..673a4f73d961f8b6a7dfb2ec338d39e4f8e2214a --- /dev/null +++ b/catalogue/Catalogue.cpp @@ -0,0 +1,25 @@ +/* + * 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 "catalogue/Catalogue.hpp" + +//------------------------------------------------------------------------------ +// destructor +//------------------------------------------------------------------------------ +cta::Catalogue::~Catalogue() { +} diff --git a/catalogue/Catalogue.hpp b/catalogue/Catalogue.hpp new file mode 100644 index 0000000000000000000000000000000000000000..5b8f169576f1d8120869f1a5b46f26a388f77563 --- /dev/null +++ b/catalogue/Catalogue.hpp @@ -0,0 +1,61 @@ +/* + * 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 "common/ArchiveRequest.hpp" + +#include <stdint.h> +#include <string> + +namespace cta { + +/** + * Abstract class defining the interface to the CTA catalogue responsible for + * storing crticial information about archive files, tapes and tape files. + */ +class Catalogue { +public: + + /** + * Destructor. + */ + virtual ~Catalogue() = 0; + + /** + * Returns the next identifier to be used for a new archive file. + * + * @return The next identifier to be used for a new archive file. + */ + virtual uint64_t getNextArchiveFileId() = 0; + + /** + * Notifies the catalogue that a file has been written to tape. + * + * @param archiveRequest The identifier of the archive file. + * + */ + virtual void fileWrittenToTape( + const ArchiveRequest &archiveRequest, + const std::string vid, + const uint64_t fSeq, + const uint64_t blockId) = 0; + +}; // class Catalogue + +} // namespace cta diff --git a/catalogue/MockCatalogue.cpp b/catalogue/MockCatalogue.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0f928f26284e8ca59390569fc60a582db6049d71 --- /dev/null +++ b/catalogue/MockCatalogue.cpp @@ -0,0 +1,48 @@ +/* + * 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 "catalogue/MockCatalogue.hpp" + +//------------------------------------------------------------------------------ +// constructor +//------------------------------------------------------------------------------ +cta::MockCatalogue::MockCatalogue(): m_nextArchiveFileId(0) { +} + +//------------------------------------------------------------------------------ +// destructor +//------------------------------------------------------------------------------ +cta::MockCatalogue::~MockCatalogue() { +} + +//------------------------------------------------------------------------------ +// getNextArchiveFileId +//------------------------------------------------------------------------------ +uint64_t cta::MockCatalogue::getNextArchiveFileId() { + return m_nextArchiveFileId++; +} + +//------------------------------------------------------------------------------ +// fileWrittenToTape +//------------------------------------------------------------------------------ +void cta::MockCatalogue::fileWrittenToTape( + const ArchiveRequest &archiveRequest, + const std::string vid, + const uint64_t fSeq, + const uint64_t blockId) { +} diff --git a/catalogue/MockCatalogue.hpp b/catalogue/MockCatalogue.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a7a686bc881c6283336c2fc5ef631107cee12bc4 --- /dev/null +++ b/catalogue/MockCatalogue.hpp @@ -0,0 +1,71 @@ +/* + * 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 "catalogue/Catalogue.hpp" + +#include <string> + +namespace cta { + +/** + * Mock CTA catalogue to facilitate unit testing. + */ +class MockCatalogue: public Catalogue { +public: + + /** + * Constructor. + */ + MockCatalogue(); + + /** + * Destructor. + */ + virtual ~MockCatalogue(); + + /** + * Returns the next identifier to be used for a new archive file. + * + * @return The next identifier to be used for a new archive file. + */ + virtual uint64_t getNextArchiveFileId(); + + /** + * Notifies the catalogue that a file has been written to tape. + * + * @param archiveRequest The identifier of the archive file. + * + */ + virtual void fileWrittenToTape( + const ArchiveRequest &archiveRequest, + const std::string vid, + const uint64_t fSeq, + const uint64_t blockId); + +private: + + /** + * The next identifier to be used for a new archive file. + */ + uint64_t m_nextArchiveFileId; + +}; // class MockCatalogue + +} // namespace cta diff --git a/common/ArchiveRequest.hpp b/common/ArchiveRequest.hpp new file mode 100644 index 0000000000000000000000000000000000000000..7504c053bb9753f7b58af2c17974da10b5506095 --- /dev/null +++ b/common/ArchiveRequest.hpp @@ -0,0 +1,48 @@ +/* + * 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 <stdint.h> +#include <string> + +namespace cta { + +/** + * Structure to store an archive request. + */ +struct ArchiveRequest { + + /** + * The size of the file to be archived in bytes. + */ + uint64_t fileSize; + + /** + * The checksum type. + */ + std::string checksumType; + + /** + * The checksum value. + */ + std::string checksumValue; + +}; // struct ArchiveRequest + +} // namespace cta