From fca1d73494c6932d0b6468f8c7c5d25ccd545161 Mon Sep 17 00:00:00 2001
From: Steven Murray <steven.murray@cern.ch>
Date: Thu, 31 Mar 2016 09:43:47 +0200
Subject: [PATCH] Added ArchiveFileQueueCriteria

---
 catalogue/Catalogue.hpp                       | 10 +--
 catalogue/DummyCatalogue.cpp                  |  8 +--
 catalogue/DummyCatalogue.hpp                  |  8 +--
 catalogue/SqliteCatalogue.cpp                 |  8 +--
 catalogue/SqliteCatalogue.hpp                 |  8 +--
 common/CMakeLists.txt                         |  1 +
 .../ArchiveFileQueueCriteria.cpp              | 26 ++++++++
 .../ArchiveFileQueueCriteria.hpp              | 62 +++++++++++++++++++
 8 files changed, 104 insertions(+), 27 deletions(-)
 create mode 100644 common/dataStructures/ArchiveFileQueueCriteria.cpp
 create mode 100644 common/dataStructures/ArchiveFileQueueCriteria.hpp

diff --git a/catalogue/Catalogue.hpp b/catalogue/Catalogue.hpp
index aa3d89eff6..3b8c6df15d 100644
--- a/catalogue/Catalogue.hpp
+++ b/catalogue/Catalogue.hpp
@@ -27,6 +27,7 @@
 #include "common/dataStructures/AdminHost.hpp"
 #include "common/dataStructures/AdminUser.hpp"
 #include "common/dataStructures/ArchiveFile.hpp"
+#include "common/dataStructures/ArchiveFileQueueCriteria.hpp"
 #include "common/dataStructures/ArchiveFileSummary.hpp"
 #include "common/dataStructures/ArchiveJob.hpp"
 #include "common/dataStructures/ArchiveRequest.hpp"
@@ -190,12 +191,11 @@ public:
    * @param user The user for whom the file is to be archived.  This will be
    * used by the Catalogue to determine the mount policy to be used when
    * archiving the file.
-   * @return A triplet of archive file ID, tape copy to tape pool map and mount
-   * group.
+   * @return The information required to queue the associated archive request.
    */
-  virtual std::tuple<uint64_t, cta::common::dataStructures::TapeCopyToPoolMap,
-    cta::common::dataStructures::MountPolicy> prepareForNewFile(
-    const std::string &storageClass, const std::string &user) = 0;
+  virtual cta::common::dataStructures::ArchiveFileQueueCriteria
+    prepareForNewFile(const std::string &storageClass, const std::string &user)
+    = 0;
 
   /**
    * Notifies the catalogue that a file has been written to tape.
diff --git a/catalogue/DummyCatalogue.cpp b/catalogue/DummyCatalogue.cpp
index 13bd50559a..721f0af0b8 100644
--- a/catalogue/DummyCatalogue.cpp
+++ b/catalogue/DummyCatalogue.cpp
@@ -441,14 +441,10 @@ void cta::catalogue::DummyCatalogue::fileWrittenToTape(
 //------------------------------------------------------------------------------
 // prepareForNewFile 
 //------------------------------------------------------------------------------
-std::tuple<uint64_t, cta::common::dataStructures::TapeCopyToPoolMap,
-  cta::common::dataStructures::MountPolicy>
+cta::common::dataStructures::ArchiveFileQueueCriteria
     cta::catalogue::DummyCatalogue::prepareForNewFile(
     const std::string &storageClass, const std::string &user) {
-  const uint64_t fileId = 0;
-  const common::dataStructures::TapeCopyToPoolMap copyToPoolMap;
-  const common::dataStructures::MountPolicy mountPolicy;
-  return std::make_tuple(fileId, copyToPoolMap, mountPolicy);
+  return common::dataStructures::ArchiveFileQueueCriteria();
 } 
 
 //------------------------------------------------------------------------------
diff --git a/catalogue/DummyCatalogue.hpp b/catalogue/DummyCatalogue.hpp
index cfee2b6ce1..71ee43602a 100644
--- a/catalogue/DummyCatalogue.hpp
+++ b/catalogue/DummyCatalogue.hpp
@@ -157,12 +157,10 @@ public:
    * @param user The user for whom the file is to be archived.  This will be
    * used by the Catalogue to determine the mount policy to be used when
    * archiving the file.
-   * @return A triplet of archive file ID, tape copy to tape pool map and mount
-   * group.
+   * @return The information required to queue the associated archive request.
    */
-  virtual std::tuple<uint64_t, cta::common::dataStructures::TapeCopyToPoolMap,
-    cta::common::dataStructures::MountPolicy> prepareForNewFile(
-    const std::string &storageClass, const std::string &user);
+  virtual cta::common::dataStructures::ArchiveFileQueueCriteria
+    prepareForNewFile(const std::string &storageClass, const std::string &user);
 
   std::map<uint64_t,std::string> getCopyNbToTapePoolMap(const std::string &storageClass) const;
   
diff --git a/catalogue/SqliteCatalogue.cpp b/catalogue/SqliteCatalogue.cpp
index 93a413ae2f..a6ec231f60 100644
--- a/catalogue/SqliteCatalogue.cpp
+++ b/catalogue/SqliteCatalogue.cpp
@@ -2043,14 +2043,10 @@ void cta::catalogue::SqliteCatalogue::fileWrittenToTape(
 //------------------------------------------------------------------------------
 // prepareForNewFile
 //------------------------------------------------------------------------------
-std::tuple<uint64_t, cta::common::dataStructures::TapeCopyToPoolMap,
-  cta::common::dataStructures::MountPolicy>
+cta::common::dataStructures::ArchiveFileQueueCriteria
   cta::catalogue::SqliteCatalogue::prepareForNewFile(
   const std::string &storageClass, const std::string &user) {
-  const uint64_t fileId = 0;
-  const common::dataStructures::TapeCopyToPoolMap copyToPoolMap;
-  const common::dataStructures::MountPolicy mountPolicy;
-  return std::make_tuple(fileId, copyToPoolMap, mountPolicy);
+  return common::dataStructures::ArchiveFileQueueCriteria();
 }
 
 //------------------------------------------------------------------------------
diff --git a/catalogue/SqliteCatalogue.hpp b/catalogue/SqliteCatalogue.hpp
index c995d96444..5733f842e2 100644
--- a/catalogue/SqliteCatalogue.hpp
+++ b/catalogue/SqliteCatalogue.hpp
@@ -177,12 +177,10 @@ public:
    * @param user The user for whom the file is to be archived.  This will be
    * used by the Catalogue to determine the mount policy to be used when
    * archiving the file.
-   * @return A triplet of archive file ID, tape copy to tape pool map and mount
-   * group.
+   * @return The information required to queue the associated archive request.
    */
-  virtual std::tuple<uint64_t, cta::common::dataStructures::TapeCopyToPoolMap,
-    cta::common::dataStructures::MountPolicy> prepareForNewFile(
-    const std::string &storageClass, const std::string &user);
+  virtual cta::common::dataStructures::ArchiveFileQueueCriteria 
+    prepareForNewFile(const std::string &storageClass, const std::string &user); 
   
   virtual std::map<uint64_t,std::string> getCopyNbToTapePoolMap(const std::string &storageClass) const;
   virtual cta::common::dataStructures::MountPolicy getArchiveMountPolicy(const cta::common::dataStructures::UserIdentity &requester) const;
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 0d40618672..79acf644bb 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -25,6 +25,7 @@ set (COMMON_LIB_SRC_FILES
   dataStructures/AdminHost.cpp
   dataStructures/AdminUser.cpp
   dataStructures/ArchiveFile.cpp
+  dataStructures/ArchiveFileQueueCriteria.cpp
   dataStructures/ArchiveFileSummary.cpp
   dataStructures/ArchiveJob.cpp
   dataStructures/ArchiveRequest.cpp
diff --git a/common/dataStructures/ArchiveFileQueueCriteria.cpp b/common/dataStructures/ArchiveFileQueueCriteria.cpp
new file mode 100644
index 0000000000..366a6d7d27
--- /dev/null
+++ b/common/dataStructures/ArchiveFileQueueCriteria.cpp
@@ -0,0 +1,26 @@
+/*
+ * 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/ArchiveFileQueueCriteria.hpp"
+
+//------------------------------------------------------------------------------
+// constructor
+//------------------------------------------------------------------------------
+cta::common::dataStructures::ArchiveFileQueueCriteria::
+  ArchiveFileQueueCriteria(): fileId(0) {
+}
diff --git a/common/dataStructures/ArchiveFileQueueCriteria.hpp b/common/dataStructures/ArchiveFileQueueCriteria.hpp
new file mode 100644
index 0000000000..cd72de5335
--- /dev/null
+++ b/common/dataStructures/ArchiveFileQueueCriteria.hpp
@@ -0,0 +1,62 @@
+/*
+ * 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/dataStructures/MountPolicy.hpp"
+#include "common/dataStructures/TapeCopyToPoolMap.hpp"
+
+#include <stdint.h>
+
+namespace cta {
+namespace common {
+namespace dataStructures {
+
+/**
+ * The queueing criteria created after preparing for a new archive file within
+ * the Catalogue.  This queueing criteria specify on which tape-pool queue(s)
+ * the corresponding data-transfer jobs are to be queued and which mount policy
+ * should be used.
+ */
+struct ArchiveFileQueueCriteria {
+
+  /**
+   * Constructor.
+   */
+  ArchiveFileQueueCriteria();
+
+  /**
+   * The unique archive-file identifier.
+   */
+  uint64_t fileId;
+
+  /**
+   * The map from tape copy number to tape pool name.
+   */
+  TapeCopyToPoolMap copyToPoolMap;
+
+  /**
+   * The mount policy.
+   */
+  MountPolicy mountPolicy;
+
+}; // struct ArchiveFileQueueCriteria
+
+} // namespace dataStructures
+} // namespace common
+} // namespace cta
-- 
GitLab