ArchiveMount.hpp 3.51 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * 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

21
#include "common/exception/Exception.hpp"
22
23
24
25
#include "scheduler/ArchiveJob.hpp"
#include "scheduler/SchedulerDatabase.hpp"
#include "scheduler/TapeMount.hpp"

26
27
28
#include <memory>

namespace cta {
29
  class NameServer;
30
31
32
33
34
35
36
  
  /**
   * The class driving a retrieve mount.
   * The class only has private constructors as it is instanciated by
   * the Scheduler class.
   */
  class ArchiveMount: public TapeMount {
37
    friend class Scheduler;
38
  protected:
39

40
41
42
    /**
     * Constructor.
     */
43
    ArchiveMount(NameServer & ns);
44

45
46
47
48
49
    /**
     * Constructor.
     *
     * @param dbMount The database representation of this mount.
     */
50
    ArchiveMount(NameServer & ns, std::unique_ptr<cta::SchedulerDatabase::ArchiveMount> dbMount);
51

52
  public:
53

54
55
    CTA_GENERATE_EXCEPTION_CLASS(WrongMountType);
    CTA_GENERATE_EXCEPTION_CLASS(NotImplemented);
56
57
58
59
60
61

    /**
     * Returns The type of this tape mount.
     *
     * @return The type of this tape mount.
     */
Steven Murray's avatar
Steven Murray committed
62
63
64
65
66
67
68
69
    virtual MountType::Enum getMountType() const throw();

    /**
     * Returns the volume identifier of the tape to be mounted.
     *
     * @return The volume identifier of the tape to be mounted.
     */
    virtual std::string getVid() const throw();
70
71
72
73
74
75
76
    
    /**
     * Returns the density of the tape to be mounted.
     *
     * @return The density of the tape to be mounted.
     */
    virtual std::string getDensity() const throw();
77
78
79
80
81
82
83
    
    /**
     * Returns the mount transaction id.
     *
     * @return The mount transaction id.
     */
    virtual std::string getMountTransactionId() const throw();
84

85
    /**
86
     * Indicates that the mount was completed.
87
88
89
90
91
     *
     * @param checksumOfTransfer The adler-32 checksum of the file as calculated
     * during the execution of the job.
     * @param fileSizeOfTransfer The size of the file as calculated during the
     * execution of the job.
92
     */
93
94
    virtual void complete();

95
    /**
96
     * Job factory
97
98
99
     *
     * @return A unique_ptr to the next archive job or NULL if there are no more
     * archive jobs left for this tape mount.
100
     */
101
    virtual std::unique_ptr<ArchiveJob> getNextJob();
102
    
103
104
105
106
107
108
109
110
111
112
113
114
115
116
    /**
     * Returns the tape pool of the tape to be mounted.
     *
     * @return The tape pool of the tape to be mounted.
     */
    virtual std::string getPoolName() const throw();
    
    /**
     * Returns the copy number of the tape to be mounted.
     *
     * @return The copy number of the tape to be mounted.
     */
    virtual int getCopyNumber() const throw();
    
117
118
119
120
121
    /**
     * Destructor.
     */
    virtual ~ArchiveMount() throw();

122
  private:
123
124
125
126

    /**
     * The database representation of this mount.
     */
127
    std::unique_ptr<cta::SchedulerDatabase::ArchiveMount> m_dbMount;
128
129
130
131
132
    
    /**
     * A reference to the name server.
     */
    NameServer & m_ns;
133
134
135
136

  }; // class ArchiveMount

} // namespace cta