Scheduler.cpp 14.3 KB
Newer Older
1
/*
2
3
 * The CERN Tape Archive(CTA) project
 * Copyright(C) 2015  CERN
4
5
6
7
 *
 * 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
8
 *(at your option) any later version.
9
10
 *
 * This program is distributed in the hope that it will be useful,
11
12
13
 * but WITHOUT ANY WARRANTY {

} without even the implied warranty of
14
15
16
17
18
19
20
 * 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/>.
 */

21

22
#include "scheduler/Scheduler.hpp"
23

24
#include <iostream>
25
#include <sstream>
26
27
28
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
Eric Cano's avatar
Eric Cano committed
29
#include <algorithm>
30

31
//------------------------------------------------------------------------------
32
// deprecated constructor
33
//------------------------------------------------------------------------------
34
35
cta::Scheduler::Scheduler(
  catalogue::Catalogue &catalogue,
36
  SchedulerDatabase &db): m_catalogue(catalogue), m_db(db) {
37
}
38
39
40
41
42
43

//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
cta::Scheduler::~Scheduler() throw() {
}
44

45
46
47
48
49
50
51
//------------------------------------------------------------------------------
// authorizeCliIdentity
//------------------------------------------------------------------------------
void cta::Scheduler::authorizeCliIdentity(const cta::common::dataStructures::SecurityIdentity &cliIdentity){
  m_catalogue.isAdmin(cliIdentity);
}

52
//------------------------------------------------------------------------------
53
// queueArchiveRequest
54
//------------------------------------------------------------------------------
55
uint64_t cta::Scheduler::queueArchiveRequest(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const cta::common::dataStructures::ArchiveRequest &request) {  
56
  const uint64_t archiveFileId = m_catalogue.getNextArchiveFileId();
57
58
  const std::map<uint64_t, std::string> copyNbToPoolMap = m_catalogue.getCopyNbToTapePoolMap(request.storageClass);
  const cta::common::dataStructures::MountPolicy policy = m_catalogue.getArchiveMountPolicy(request.requester);
59
  std::unique_ptr<SchedulerDatabase::ArchiveRequestCreation> requestCreation(m_db.queue(request, archiveFileId, copyNbToPoolMap, policy));
60
61
  requestCreation->complete();
  
62
  return 0;
63
64
65
}

//------------------------------------------------------------------------------
66
// queueRetrieveRequest
67
//------------------------------------------------------------------------------
68
void cta::Scheduler::queueRetrieveRequest(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const cta::common::dataStructures::RetrieveRequest &request) {
69

70
71
72
}

//------------------------------------------------------------------------------
73
// deleteArchiveRequest
74
//------------------------------------------------------------------------------
75
void cta::Scheduler::deleteArchiveRequest(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const cta::common::dataStructures::DeleteArchiveRequest &request) {
76

77
78
79
}

//------------------------------------------------------------------------------
80
// cancelRetrieveRequest
81
//------------------------------------------------------------------------------
82
void cta::Scheduler::cancelRetrieveRequest(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const cta::common::dataStructures::CancelRetrieveRequest &request) {
83

84
85
86
}

//------------------------------------------------------------------------------
87
// updateFileInfoRequest
88
//------------------------------------------------------------------------------
89
void cta::Scheduler::updateFileInfoRequest(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const cta::common::dataStructures::UpdateFileInfoRequest &request) {
90

91
}
92

93
//------------------------------------------------------------------------------
94
// listStorageClassRequest
95
//------------------------------------------------------------------------------
96
std::list<cta::common::dataStructures::StorageClass> cta::Scheduler::listStorageClassRequest(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const cta::common::dataStructures::ListStorageClassRequest &request) {
97
  return std::list<cta::common::dataStructures::StorageClass>();
98
99
100
}

//------------------------------------------------------------------------------
101
// labelTape
102
//------------------------------------------------------------------------------
103
void cta::Scheduler::labelTape(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const bool force, const bool lbp, const std::string &tag) {
104
}
105

106
//------------------------------------------------------------------------------
107
// setTapeBusy
108
//------------------------------------------------------------------------------
109
110
void cta::Scheduler::setTapeBusy(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const bool busyValue) {
  m_catalogue.setTapeBusy(cliIdentity, vid, busyValue);
111
112
113
}

//------------------------------------------------------------------------------
114
// setTapeFull
115
//------------------------------------------------------------------------------
116
117
void cta::Scheduler::setTapeFull(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const bool fullValue) {
  m_catalogue.setTapeFull(cliIdentity, vid, fullValue);
118
119
120
}

//------------------------------------------------------------------------------
121
// setTapeDisabled
122
//------------------------------------------------------------------------------
123
124
void cta::Scheduler::setTapeDisabled(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const bool disabledValue) {
  m_catalogue.setTapeDisabled(cliIdentity, vid, disabledValue);
125
126
}

127
128
129
130
131
132
133
//------------------------------------------------------------------------------
// setTapeLbp
//------------------------------------------------------------------------------
void cta::Scheduler::setTapeLbp(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const bool lbpValue) {
  m_catalogue.setTapeLbp(cliIdentity, vid, lbpValue);
}

134
135
136
//------------------------------------------------------------------------------
// repack
//------------------------------------------------------------------------------
137
void cta::Scheduler::repack(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const std::string &tag, const cta::common::dataStructures::RepackType) {
138
139
140
141
142
}

//------------------------------------------------------------------------------
// cancelRepack
//------------------------------------------------------------------------------
143
void cta::Scheduler::cancelRepack(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid) {
144
145
146
147
148
}

//------------------------------------------------------------------------------
// getRepacks
//------------------------------------------------------------------------------
149
std::list<cta::common::dataStructures::RepackInfo> cta::Scheduler::getRepacks(const cta::common::dataStructures::SecurityIdentity &cliIdentity) {
150
151
152
153
154
155
  return std::list<cta::common::dataStructures::RepackInfo>(); 
}

//------------------------------------------------------------------------------
// getRepack
//------------------------------------------------------------------------------
156
cta::common::dataStructures::RepackInfo cta::Scheduler::getRepack(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid) {
157
158
159
160
161
162
  return cta::common::dataStructures::RepackInfo(); 
}

//------------------------------------------------------------------------------
// shrink
//------------------------------------------------------------------------------
163
void cta::Scheduler::shrink(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &tapepool) {
164
165
166
167
168
}

//------------------------------------------------------------------------------
// verify
//------------------------------------------------------------------------------
169
void cta::Scheduler::verify(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const std::string &tag, const uint64_t numberOfFiles) {
170
171
172
173
174
}

//------------------------------------------------------------------------------
// cancelVerify
//------------------------------------------------------------------------------
175
void cta::Scheduler::cancelVerify(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid) {
176
177
178
179
180
181

}

//------------------------------------------------------------------------------
// getVerifys
//------------------------------------------------------------------------------
182
std::list<cta::common::dataStructures::VerifyInfo> cta::Scheduler::getVerifys(const cta::common::dataStructures::SecurityIdentity &cliIdentity) const {
183
184
185
186
187
188
  return std::list<cta::common::dataStructures::VerifyInfo>(); 
}

//------------------------------------------------------------------------------
// getVerify
//------------------------------------------------------------------------------
189
cta::common::dataStructures::VerifyInfo cta::Scheduler::getVerify(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid) const {
190
191
192
  return cta::common::dataStructures::VerifyInfo(); 
}

193
//------------------------------------------------------------------------------
194
195
// readTest
//------------------------------------------------------------------------------
196
cta::common::dataStructures::ReadTestResult cta::Scheduler::readTest(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &driveName, const std::string &vid,
Daniele Kruse's avatar
Daniele Kruse committed
197
        const uint64_t firstFSeq, const uint64_t lastFSeq, const bool checkChecksum, const std::string &output, const std::string &tag) const {
198
199
200
201
202
203
  return cta::common::dataStructures::ReadTestResult(); 
}

//------------------------------------------------------------------------------
// writeTest
//------------------------------------------------------------------------------
204
cta::common::dataStructures::WriteTestResult cta::Scheduler::writeTest(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &driveName, const std::string &vid,
Daniele Kruse's avatar
Daniele Kruse committed
205
206
207
208
209
210
211
        const std::string &inputFile, const std::string &tag) const {
  return cta::common::dataStructures::WriteTestResult(); 
}

//------------------------------------------------------------------------------
// write_autoTest
//------------------------------------------------------------------------------
212
cta::common::dataStructures::WriteTestResult cta::Scheduler::write_autoTest(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &driveName, const std::string &vid,
Daniele Kruse's avatar
Daniele Kruse committed
213
        const uint64_t numberOfFiles, const uint64_t fileSize, const cta::common::dataStructures::TestSourceType testSourceType, const std::string &tag) const {
214
215
216
217
218
219
  return cta::common::dataStructures::WriteTestResult(); 
}

//------------------------------------------------------------------------------
// setDriveStatus
//------------------------------------------------------------------------------
220
void cta::Scheduler::setDriveStatus(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &driveName, const bool up, const bool force) {
221
222
223
224
225
226

}

//------------------------------------------------------------------------------
// reconcile
//------------------------------------------------------------------------------
227
std::list<cta::common::dataStructures::ArchiveFile> cta::Scheduler::reconcile(const cta::common::dataStructures::SecurityIdentity &cliIdentity) {
228
229
230
231
232
233
  return std::list<cta::common::dataStructures::ArchiveFile>(); 
}

//------------------------------------------------------------------------------
// getPendingArchiveJobs
//------------------------------------------------------------------------------
234
std::map<std::string, std::list<cta::common::dataStructures::ArchiveJob> > cta::Scheduler::getPendingArchiveJobs(const cta::common::dataStructures::SecurityIdentity &cliIdentity) const {
235
  return std::map<std::string, std::list<cta::common::dataStructures::ArchiveJob> >(); 
236
237
238
239
240
}

//------------------------------------------------------------------------------
// getPendingArchiveJobs
//------------------------------------------------------------------------------
241
std::list<cta::common::dataStructures::ArchiveJob> cta::Scheduler::getPendingArchiveJobs(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &tapePoolName) const {
242
243
244
245
246
247
  return std::list<cta::common::dataStructures::ArchiveJob>(); 
}

//------------------------------------------------------------------------------
// getPendingRetrieveJobs
//------------------------------------------------------------------------------
248
std::map<std::string, std::list<cta::common::dataStructures::RetrieveJob> > cta::Scheduler::getPendingRetrieveJobs(const cta::common::dataStructures::SecurityIdentity &cliIdentity) const {
249
  return std::map<std::string, std::list<cta::common::dataStructures::RetrieveJob> >(); 
250
251
252
253
254
}

//------------------------------------------------------------------------------
// getPendingRetrieveJobs
//------------------------------------------------------------------------------
255
std::list<cta::common::dataStructures::RetrieveJob> cta::Scheduler::getPendingRetrieveJobs(const cta::common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid) const {
256
  return std::list<cta::common::dataStructures::RetrieveJob>(); 
257
258
}

259
260
261
//------------------------------------------------------------------------------
// getDriveStates
//------------------------------------------------------------------------------
262
std::list<cta::common::dataStructures::DriveState> cta::Scheduler::getDriveStates(const cta::common::dataStructures::SecurityIdentity &cliIdentity) const {
263
  return std::list<cta::common::dataStructures::DriveState>(); 
264
}
265
266
267
268

//------------------------------------------------------------------------------
// getNextMount
//------------------------------------------------------------------------------
269
270
std::unique_ptr<cta::TapeMount> cta::Scheduler::getNextMount(const std::string &logicalLibraryName, const std::string &driveName) {
  return std::unique_ptr<TapeMount>();
271
}