RetrieveMount.hpp 3.91 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
/*
 * 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/exception/Exception.hpp"
#include "scheduler/RetrieveJob.hpp"
#include "scheduler/RetrieveMount.hpp"
#include "scheduler/SchedulerDatabase.hpp"
#include "scheduler/TapeMount.hpp"

#include <memory>

namespace cta {
  
  /**
   * The class driving a retrieve mount.
   * The class only has private constructors as it is instanciated by
   * the Scheduler class.
   */
  class RetrieveMount: public TapeMount {
    friend class Scheduler;
38
  protected:
39
    /**
40
     * Trivial constructor
41
42
     */
    RetrieveMount();
43
    
44
45
46
47
48
    /**
     * Constructor.
     *
     * @param dbMount The database representation of this mount.
     */
49
    RetrieveMount(std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> dbMount);
50
51
52
53
54
55
56
57
58
59
60

  public:

    CTA_GENERATE_EXCEPTION_CLASS(WrongMountType);
    CTA_GENERATE_EXCEPTION_CLASS(NotImplemented);

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

    /**
     * Returns the volume identifier of the tape to be mounted.
     *
     * @return The volume identifier of the tape to be mounted.
     */
68
    virtual std::string getVid() const;
69
    
70
71
72
73
74
    /**
     * Returns the mount transaction id.
     *
     * @return The mount transaction id.
     */
75
    virtual std::string getMountTransactionId() const;
76
77
78
79
80
81
82
    
    /**
     * Returns the mount transaction id.
     *
     * @return The mount transaction id.
     */
    virtual uint32_t getNbFiles() const;
83
84
85
86
    
    /**
     * Report a drive status change
     */
87
    virtual void setDriveStatus(cta::common::DriveStatus status);
88
89

    /**
90
91
     * Indicates that the disk thread of the mount was completed. This
     * will implicitly trigger the transition from DrainingToDisk to Up if necessary.
92
     */
93
    virtual void diskComplete();
94

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
    /**
     * Indicates that the tape thread of the mount was completed. This 
     * will implicitly trigger the transition from Unmounting to either Up or
     * DrainingToDisk, depending on the the disk thread's status.
     */
    virtual void tapeComplete();
    
    /**
     * Indicates that the we should cancel the mount (equivalent to diskComplete
     * + tapeComeplete).
     */
    virtual void abort();
    
    /**
     * Tests whether all threads are complete
     * @return true if both tape and disk are complete.
     */
    virtual bool bothSidesComplete();
    
114
    CTA_GENERATE_EXCEPTION_CLASS(SessionNotRunning);
115
116
117
118
119
120
    /**
     * Job factory
     *
     * @return A unique_ptr to the next archive job or NULL if there are no more
     * archive jobs left for this tape mount.
     */
121
    virtual std::unique_ptr<RetrieveJob> getNextJob();
122
123
124
125
126
127
128
129
130
131
132
133
    
    /**
     * Destructor.
     */
    virtual ~RetrieveMount() throw();

  private:

    /**
     * The database representation of this mount.
     */
    std::unique_ptr<cta::SchedulerDatabase::RetrieveMount> m_dbMount;
134
135
136
137
138
    
    /**
     * Internal tracking of the session completion
     */
    bool m_sessionRunning;
139
140
141
142
143
144
145
146
147
148
149
150
    
    /**
     * Internal tracking of the tape thread
     */
    bool m_tapeRunning;
    
    /**
     * Internal tracking of the disk thread
     */
    bool m_diskRunning;
    
    
151
152
153
154

  }; // class RetrieveMount

} // namespace cta