VdqmProxy.hpp 6.82 KB
Newer Older
1
/******************************************************************************
2
 *                castor/legacymsg/VdqmProxy.hpp
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 *
 * This file is part of the Castor project.
 * See http://castor.web.cern.ch/castor
 *
 * Copyright (C) 2003  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 2
 * 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * @author Steven.Murray@cern.ch
 *****************************************************************************/

23
#pragma once
24
25

#include "castor/exception/Exception.hpp"
26
#include "castor/legacymsg/RtcpJobRqstMsgBody.hpp"
27

28
29
#include <sys/types.h>

30
31
namespace castor {
namespace legacymsg {
32
33
34

/**
 * Proxy class representing the vdqm daemon.
35
36
37
38
 *
 * The good-day sequence of events for a tape being mounted and then unmounted
 * is as follows:
 *
39
40
41
42
43
44
45
46
47
48
 * tapeserverd                           vdqm               rmcd
 *      |                                 |                  |
 *      | setDriveUp                      |                  |
 *      |-------------------------------->| schedule drive   |
 *      |                                 |------            |
 *      |                                 |      |           |
 *      |                         RtcpJob |<-----            |
 *      |<--------------------------------|                  |
 *      |                                 |                  |
 *      | fork                            |                  |
49
 *      |----------->DataTransferSession         |                  |
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
 *      |                 |               |                  |
 *      |                 | assignDrive   |                  |
 *      |                 |-------------->|                  |
 *      |                 |               |                  |
 *      |                 | mount tape    |                  |
 *      |                 |--------------------------------->|
 *      |                 |               |                  |
 *      |                 | tapeMounted   |                  |
 *      |                 |-------------->|                  |
 *      |  transfer files |               |                  |
 *      |           ------|               |                  |
 *      |          |      |               |                  |
 *      |           ----->| unmount tape  |                  |
 *      |                 |--------------------------------->|
 *      | waitpid         |               |                  |
 *      |---------------->|               |                  |
 *      |                                 |                  |
 *      |                                 |                  |
 *      | releaseDrive(forceUnmount)      |                  |
 *      |-------------------------------->|                  |
 *      |                                 |                  |
 *      | tapeUnmounted                   |                  |
 *      |-------------------------------->|                  |
 *      |                                 |                  |
 *      |                                 |                  |
75
 */
76
class VdqmProxy {
77
78
79
80
81
public:

  /**
   * Destructor.
   */
82
  virtual ~VdqmProxy() throw() = 0;
83

84
85
86
  /**
   * Sets the status of the specified tape drive to down.
   *
87
88
   * @param server The host name of the server to which the tape drive is
   * attached.
89
90
91
   * @param unitName The unit name of the tape drive. 
   * @param dgn The device group name of the tape drive.
   */
92
  virtual void setDriveDown(const std::string &server, const std::string &unitName, 
93
  const std::string &dgn)  = 0;
94
95
96
97

  /**
   * Sets the status of the specified tape drive to up.
   *
98
99
   * @param server The host name of the server to which the tape drive is
   * attached.
100
101
102
   * @param unitName The unit name of the tape drive.
   * @param dgn The device group name of the tape drive.
   */
103
  virtual void setDriveUp(const std::string &server, const std::string &unitName,
104
  const std::string &dgn)  = 0;
105

106
  /**
107
108
   * Assigns the specified mount session process to the specified tape
   * drive and mount transaction.
109
110
111
112
113
114
   *
   * @param server The host name of the server to which the tape drive is
   * attached.
   * @param unitName The unit name of the tape drive.
   * @param dgn The device group name of the tape drive.
   * @param mountTransactionId The mount transaction ID.
115
116
   * @param sessionPid The process ID of the tape-server daemon's mount-session
   * process.
117
   */
118
119
  virtual void assignDrive(const std::string &server, const std::string &unitName,
  const std::string &dgn, const uint32_t mountTransactionId, 
120
  const pid_t sessionPid)  = 0;
121

122
  /**
123
   * Notifies the vdqmd daemon of the specified tape mount.
124
125
126
127
128
   *
   * @param server The host name of the server to which the tape drive is
   * attached.
   * @param unitName The unit name of the tape drive.
   * @param dgn The device group name of the tape drive.
129
130
131
   * @param vid The volume identifier of the mounted tape.
   * @param sessionPid The process ID of the tape-server daemon's mount-session
   * process.
132
   */
133
134
  virtual void tapeMounted(const std::string &server, const std::string &unitName,
  const std::string &dgn, const std::string &vid, const pid_t sessionPid) 
135
   = 0;
136
137
138
139
140
141
142
143
144
145
146
147
148

  /**
   * Releases the specified tape drive.
   *
   * @param server The host name of the server to which the tape drive is
   * attached.
   * @param unitName The unit name of the tape drive.
   * @param dgn The device group name of the tape drive.
   * @param forceUnmount Set to true if the current tape mount should not bei
   * reused.
   * @param sessionPid The process ID of the tape-server daemon's mount-session
   * process.
   */
149
150
  virtual void releaseDrive(const std::string &server, const std::string &unitName, 
  const std::string &dgn, const bool forceUnmount, const pid_t sessionPid) 
151
   = 0;
152

153
154
155
156
157
158
159
160
161
  /**
   * Notifies the vdqmd daemon that the specified tape has been dismounted.
   *
   * @param server The host name of the server to which the tape drive is
   * attached.
   * @param unitName The unit name of the tape drive.
   * @param dgn The device group name of the tape drive.
   * @param vid The volume identifier of the mounted tape.
   */
162
  virtual void tapeUnmounted(const std::string &server, const std::string &unitName, 
163
  const std::string &dgn, const std::string &vid)  = 0;
164

165
}; // class VdqmProxy
166

167
} // namespace legacymsg
168
169
} // namespace castor