RAOParams.hpp 3.74 KB
Newer Older
1
/*
2
 * @project        The CERN Tape Archive (CTA)
3
 * @copyright      Copyright(C) 2003-2021 CERN
4
5
6
7
 * @license        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.
8
 *
9
10
11
12
 *                 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.
13
 *
14
15
 *                 You should have received a copy of the GNU General Public License
 *                 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17
18
19
20
21
22
23
24
 */

#pragma once
#include <string>
#include "tapeserver/castor/tape/tapeserver/daemon/DataTransferConfig.hpp"
#include "tapeserver/castor/tape/tapeserver/SCSI/Structures.hpp"
#include <memory>
#include <common/log/LogContext.hpp>
#include <vector>
25
26
#include "catalogue/Catalogue.hpp"
#include "RAOOptions.hpp"
27
28
29
30
31
32

namespace castor { namespace tape { namespace tapeserver { namespace rao {
  
  /**
   * This class contains the configuration of the CTA RAO Algorithm
   */
33
  class RAOParams{
34
35
36
37
38
39
40
41
42
43
44
45
46
  public:
    /**
     * This enum represent the RAO algorithm type implemented
     * by CTA
     */
    enum RAOAlgorithmType {
      linear,
      random,
      //Short Locate Time First
      sltf
    };
    
    /**
47
48
     * Default constructor, sets useRAO to false
     */
49
    RAOParams();
50
51
    
    /**
52
     * Construct an RAOParams object
53
54
55
     * @param useRAO if set to true, the RAO will be enabled. If false, not enabled.
     * @param raoAlgorithmName the RAO algorithm that will be executed when called
     * @param raoAlgorithmOptions the options that could be passed to the RAO algorithm
56
57
     * @param vid the vid of the tape that is currently mounted for retrieval
     */
58
    RAOParams(const bool useRAO, const std::string & raoAlgorithmName, const std::string & raoAlgorithmOptions, const std::string & vid);
59
60
61
    
    /**
     * Copy constructor
62
     */
63
    RAOParams(const RAOParams & other);
64
65
66
67
    
    /**
     * Operator =
     */
68
    RAOParams & operator=(const RAOParams & other);
69
70
71
72
73
74
75
    
    /**
     * Returns true if RAO has to be used, false otherwise
     */
    bool useRAO() const;
    
    /**
76
     * Returns the RAO algorithm name of this RAO data instance
77
78
79
80
     */
    std::string getRAOAlgorithmName() const;
    
    /**
81
     * Returns the RAO algorithm options of this RAO data instance
82
     */
83
    RAOOptions getRAOAlgorithmOptions() const;
84
85
    
    /**
86
     * Disable RAO of this configuration
87
88
89
90
91
92
93
94
95
96
97
     */
    void disableRAO();
    
    /**
     * Returns RAOAlgorithmType object corresopnding to this configration's raoAlgorithmName
     * @return the RAOAlgorithmType object corresopnding to this configration raoAlgorithmName
     * @throws cta::exception::Exception in case the algorithm name does not match any RAOAlgorithmType
     */
    RAOAlgorithmType getAlgorithmType() const;
    
    /**
98
     * Returns the CTA RAO algorithm names that can be used
99
100
101
     */
    std::string getCTARAOAlgorithmNameAvailable() const;
    
102
103
104
105
106
    /**
     * Returns the vid of the tape that is mounted for retrieval
     */
    std::string getMountedVid() const;
    
107
108
109
  private:
    bool m_useRAO = false;
    std::string m_raoAlgorithmName;
110
111
112
    RAOOptions m_raoAlgorithmOptions;
    std::string m_vid;
    
113
114
115
116
117
118
119
120
121
    
    /**
     * Static map in order to match the string representing an algorithm name and its enum type
     */
    static const std::map<std::string, RAOAlgorithmType> c_raoAlgoStringTypeMap;
  };
  
  
}}}}