RAOManager.hpp 4.11 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
 * The CERN Tape Archive (CTA) project
 * Copyright (C) 2019  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 <vector>
#include <memory>
#include "castor/tape/tapeserver/RAO/RAOConfig.hpp"
#include "castor/tape/tapeserver/drive/DriveInterface.hpp"
#include "castor/tape/tapeserver/SCSI/Structures.hpp"
#include "scheduler/RetrieveJob.hpp"
#include "common/optional.hpp"
#include "RAOAlgorithmFactory.hpp"
#include "common/log/LogContext.hpp"

namespace castor { namespace tape { namespace tapeserver { namespace rao {
  
/**
 * This class will be used to manage everything that is linked to RAO.
 * It centralizes all the RAO-related task that are executed during the
 * RecallTaskInjector lifecycle.
 */
class RAOManager {
public:
  /**
   * Default constructor, disable the RAO
   */
  RAOManager();
  
  /**
   * Copy constructor
   * @param manager the RAOManager to copy
   */
  RAOManager(const RAOManager & manager);
  
  /**
   * Constructor of a RAO manager
   * @param config the configuration of the RAO to manage
   * @param drive the DriveInterface of the drive that is mounting
   */
  RAOManager(const RAOConfig & config, castor::tape::tapeserver::drive::DriveInterface * drive);
  
  /**
   * Assignment operator
   * */
  RAOManager & operator=(const RAOManager & manager);
  
  /**
   * Returns true if RAO will be used, false otherwise
   */
  bool useRAO() const;
  
  /**
   * Returns true if the manager has informations about the drive's User Data Segments limits to
   * perform RAO for enteprise drive
   */
  bool hasUDS() const;
  
  /**
   * Returns true if the manager can ask for an Enterprise RAO Algorithm
   * false otherwise
   */
  bool isDriveEnterpriseEnabled() const;
  
  /**
   * Returns the pointer to the interface of that is mounting
   */
  castor::tape::tapeserver::drive::DriveInterface * getDrive() const;
  
  /**
   * Returns the number of files that will be supported by the RAO algorithm
   */
  cta::optional<uint64_t> getMaxFilesSupported() const;
  
  /**
   * Returns the RAOConfig that is used by this RAOManager
   */
  RAOConfig getConfig() const;
  
  /**
   * Disable the RAO algorithm
   */
  void disableRAO();
  
  /**
   * Set the enterprise RAO User Data Segments limits
   * that will be used by this manager to perform the Enterprise RAO query on the drive
   * @param raoLimits the enterprise RAO user data segments limits
   */
  void setEnterpriseRAOUdsLimits(const SCSI::Structures::RAO::udsLimits & raoLimits);
  
  /**
   * Query the RAO of the files passed in parameter
   * @param jobs the vector of jobs to query the RAO
   * @param lc the log context
   * @return the vector with re-arranged indexes of the jobs passed in parameter
   * It does not returns the fseqs, but a vector of indexes that will be used by the recall task injector to pick
   * the correct job after RAO has been done
   */
  std::vector<uint64_t> queryRAO(const std::vector<std::unique_ptr<cta::RetrieveJob>> & jobs, cta::log::LogContext & lc);
  
  virtual ~RAOManager();
  
private:
  RAOConfig m_config;
  /** Enterprise Drive-specific RAO parameters */
  SCSI::Structures::RAO::udsLimits m_enterpriseRaoLimits;
  //Is true if the drive have been able to get the RAO UDS limits numbers
  bool m_hasUDS = false;
  //The maximum number of files that will be considered for RAO
  cta::optional<uint64_t> m_maxFilesSupported;
  //Pointer to the drive interface of the drive currently used by the tapeserver
  castor::tape::tapeserver::drive::DriveInterface * m_drive;
  bool m_isDriveEnterpriseEnabled = false;
};

}}}}