RdbmsCatalogue.hpp 25.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
 * 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 "catalogue/Catalogue.hpp"
22
#include "catalogue/DbConn.hpp"
23
#include "catalogue/RequesterAndGroupMountPolicies.hpp"
24

25
#include <memory>
26
27
#include <mutex>

28
29
30
31
32
33
34
namespace cta {
namespace common {
namespace dataStructures {

/**
 * Forward declaration.
 */
35
class TapeFile;
36
37
38
39
40

} // namespace dataStructures
} // namespace catalogue
} // namespace cta

41
42
43
namespace cta {
namespace catalogue {

44
45
46
47
48
/**
 * Forward declaration.
 */
class ArchiveFileRow;

49
/**
Steven Murray's avatar
Steven Murray committed
50
 * CTA catalogue implemented using a relational database backend.
51
 */
52
class RdbmsCatalogue: public Catalogue {
53
protected:
54
55

  /**
56
   * Protected constructor only to be called by sub-classes.
57
   */
58
  RdbmsCatalogue();
59

60
61
public:

62
63
64
  /**
   * Destructor.
   */
65
  virtual ~RdbmsCatalogue();
66
  
67
  virtual void createBootstrapAdminAndHostNoAuth(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &username, const std::string &hostName, const std::string &comment);
68

69
70
  virtual void createAdminUser(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &username, const std::string &comment);
  virtual void deleteAdminUser(const std::string &username);
71
  virtual std::list<common::dataStructures::AdminUser> getAdminUsers() const;
72
  virtual void modifyAdminUserComment(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &username, const std::string &comment);
73

74
  virtual void createAdminHost(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &hostName, const std::string &comment);
75
  virtual void deleteAdminHost(const std::string &hostName);
76
77
  virtual std::list<common::dataStructures::AdminHost> getAdminHosts() const;
  virtual void modifyAdminHostComment(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &hostName, const std::string &comment);
78

79
  virtual void createStorageClass(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t nbCopies, const std::string &comment);
80
  virtual void deleteStorageClass(const std::string &name);
81
82
83
  virtual std::list<common::dataStructures::StorageClass> getStorageClasses() const;
  virtual void modifyStorageClassNbCopies(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t nbCopies);
  virtual void modifyStorageClassComment(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const std::string &comment);
84

85
  virtual void createTapePool(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t nbPartialTapes, const bool encryptionValue, const std::string &comment);
86
  virtual void deleteTapePool(const std::string &name);
87
88
89
90
  virtual std::list<common::dataStructures::TapePool> getTapePools() const;
  virtual void modifyTapePoolNbPartialTapes(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t nbPartialTapes);
  virtual void modifyTapePoolComment(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const std::string &comment);
  virtual void setTapePoolEncryption(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const bool encryptionValue);
91

92
  virtual void createArchiveRoute(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &storageClassName, const uint64_t copyNb, const std::string &tapePoolName, const std::string &comment);
93
  virtual void deleteArchiveRoute(const std::string &storageClassName, const uint64_t copyNb);
94
95
96
  virtual std::list<common::dataStructures::ArchiveRoute> getArchiveRoutes() const;
  virtual void modifyArchiveRouteTapePoolName(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &storageClassName, const uint64_t copyNb, const std::string &tapePoolName);
  virtual void modifyArchiveRouteComment(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &storageClassName, const uint64_t copyNb, const std::string &comment);
97

98
  virtual void createLogicalLibrary(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const std::string &comment);
99
  virtual void deleteLogicalLibrary(const std::string &name);
100
101
  virtual std::list<common::dataStructures::LogicalLibrary> getLogicalLibraries() const;
  virtual void modifyLogicalLibraryComment(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const std::string &comment);
102

103
  virtual void createTape(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const std::string &logicalLibraryName, const std::string &tapePoolName,
104
                          const std::string &encryptionKey, const uint64_t capacityInBytes, const bool disabledValue, const bool fullValue, const std::string &comment);
105
  virtual void deleteTape(const std::string &vid);
106
  virtual std::list<common::dataStructures::Tape> getTapes(const std::string &vid, const std::string &logicalLibraryName, const std::string &tapePoolName,
107
        const std::string &capacityInBytes, const std::string &disabledValue, const std::string &fullValue, const std::string &busyValue, const std::string &lbpValue);
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
  virtual void reclaimTape(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid);
  virtual void modifyTapeLogicalLibraryName(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const std::string &logicalLibraryName);
  virtual void modifyTapeTapePoolName(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const std::string &tapePoolName);
  virtual void modifyTapeCapacityInBytes(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const uint64_t capacityInBytes);
  virtual void modifyTapeEncryptionKey(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const std::string &encryptionKey);
  virtual void modifyTapeLabelLog(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const std::string &drive, const uint64_t timestamp); // internal function (noCLI)
  virtual void modifyTapeLastWrittenLog(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const std::string &drive, const uint64_t timestamp); // internal function (noCLI)
  virtual void modifyTapeLastReadLog(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const std::string &drive, const uint64_t timestamp); // internal function (noCLI)
  virtual void setTapeBusy(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const bool busyValue); // internal function not exposed to the Admin CLI
  virtual void setTapeFull(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const bool fullValue);
  virtual void setTapeDisabled(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const bool disabledValue);
  virtual void setTapeLbp(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const bool lbpValue); // internal function (noCLI)
  virtual void modifyTapeComment(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &vid, const std::string &comment);

  virtual void modifyRequesterMountPolicy(const common::dataStructures::SecurityIdentity &cliIdentity, const common::dataStructures::UserIdentity &user, const std::string &mountPolicy);
  virtual void modifyRequesterComment(const common::dataStructures::SecurityIdentity &cliIdentity, const common::dataStructures::UserIdentity &user, const std::string &comment);
124

125
  virtual void createMountPolicy(
126
    const common::dataStructures::SecurityIdentity &cliIdentity,
127
128
129
130
131
132
133
134
    const std::string &name,
    const uint64_t archivePriority,
    const uint64_t minArchiveRequestAge,
    const uint64_t retrievePriority,
    const uint64_t minRetrieveRequestAge,
    const uint64_t maxDrivesAllowed,
    const std::string &comment);

135
  /**
136
   * Returns the list of all existing mount policies.
137
   *
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
   * @return the list of all existing mount policies.
   */
  virtual std::list<common::dataStructures::MountPolicy> getMountPolicies() const;

  /**
   * Deletes the specified mount policy.
   *
   * @param name The name of the mount policy.
   */
  virtual void deleteMountPolicy(const std::string &name);

  /**
   * Creates the rule that the specified mount policy will be used for the
   * specified requester.
   *
   * Please note that requester mount-rules overrule requester-group
   * mount-rules.
155
156
157
158
159
160
   *
   * @param cliIdentity The user of the command-line tool.
   * @param mountPolicyName The name of the mount policy.
   * @param requesterName The name of the requester.
   * @param comment Comment.
   */
161
  virtual void createRequesterMountRule(
162
163
164
165
166
167
    const common::dataStructures::SecurityIdentity &cliIdentity,
    const std::string &mountPolicyName,
    const std::string &requesterName,
    const std::string &comment);

  /**
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
   * Returns the rules that specify which mount policy is be used for which
   * requester.
   *
   * @return the rules that specify which mount policy is be used for which
   * requester.
   */
  virtual std::list<common::dataStructures::RequesterMountRule> getRequesterMountRules() const;

  /**
   * Deletes the specified mount rule.
   *
   * @param requesterName The name of the requester.
   */
  virtual void deleteRequesterMountRule(const std::string &requesterName);

  /**
   * Creates the rule that the specified mount policy will be used for the
   * specified requester group.
186
   *
187
188
   * Please note that requester mount-rules overrule requester-group
   * mount-rules.
189
   *
190
   * @param cliIdentity The user of the command-line tool.
191
   * @param mountPolicyName The name of the mount policy.
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
   * @param requesterGroupName The name of the requester group.
   * @param comment Comment.
   */
  virtual void createRequesterGroupMountRule(
    const common::dataStructures::SecurityIdentity &cliIdentity,
    const std::string &mountPolicyName,
    const std::string &requesterGroupName,
    const std::string &comment);

  /**
   * Returns the rules that specify which mount policy is be used for which
   * requester group.
   *
   * @return the rules that specify which mount policy is be used for which
   * requester group.
207
   */
208
209
210
211
212
213
214
215
  virtual std::list<common::dataStructures::RequesterGroupMountRule> getRequesterGroupMountRules() const;

  /**
   * Deletes the specified mount rule.
   *
   * @param requesterGroupName The name of the requester group.
   */
  virtual void deleteRequesterGroupMountRule(const std::string &requesterGroupName);
216

217
218
219
220
221
222
223
224
225
226
227
228
  virtual void modifyMountPolicyArchivePriority(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t archivePriority);
  virtual void modifyMountPolicyArchiveMinFilesQueued(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t minArchiveFilesQueued);
  virtual void modifyMountPolicyArchiveMinBytesQueued(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t archiveMinBytesQueued);
  virtual void modifyMountPolicyArchiveMinRequestAge(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t minArchiveRequestAge);
  virtual void modifyMountPolicyRetrievePriority(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t retrievePriority);
  virtual void modifyMountPolicyRetrieveMinFilesQueued(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t minRetrieveFilesQueued);
  virtual void modifyMountPolicyRetrieveMinBytesQueued(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t retrieveMinBytesQueued);
  virtual void modifyMountPolicyRetrieveMinRequestAge(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t minRetrieveRequestAge);
  virtual void modifyMountPolicyMaxDrivesAllowed(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const uint64_t maxDrivesAllowed);
  virtual void modifyMountPolicyComment(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &name, const std::string &comment);

  virtual void createDedication(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &drivename, const common::dataStructures::DedicationType dedicationType,
229
230
   const std::string &tag, const std::string &vid, const uint64_t fromTimestamp, const uint64_t untilTimestamp,const std::string &comment);
  virtual void deleteDedication(const std::string &drivename);
231
232
233
234
235
236
237
238
239
  virtual std::list<common::dataStructures::Dedication> getDedications() const;
  virtual void modifyDedicationType(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &drivename, const common::dataStructures::DedicationType dedicationType);
  virtual void modifyDedicationTag(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &drivename, const std::string &tag);
  virtual void modifyDedicationVid(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &drivename, const std::string &vid);
  virtual void modifyDedicationFrom(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &drivename, const uint64_t fromTimestamp);
  virtual void modifyDedicationUntil(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &drivename, const uint64_t untilTimestamp);
  virtual void modifyDedicationComment(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &drivename, const std::string &comment);

  virtual std::list<common::dataStructures::ArchiveFile> getArchiveFiles(const std::string &id, const std::string &eosid,
240
   const std::string &copynb, const std::string &tapepool, const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path);
241
  virtual common::dataStructures::ArchiveFileSummary getArchiveFileSummary(const std::string &id, const std::string &eosid,
242
   const std::string &copynb, const std::string &tapepool, const std::string &vid, const std::string &owner, const std::string &group, const std::string &storageclass, const std::string &path);
243
244
245
246
247
248
249
250
251
252
253

  /**
   * Returns the archive file with the specified unique identifier.
   *
   * This method assumes that the archive file being requested exists and will
   * therefore throw an exception if it does not.
   *
   * @param id The unique identifier of the archive file.
   * @return The archive file.
   */
  virtual common::dataStructures::ArchiveFile getArchiveFileById(const uint64_t id);
254
  
255
  virtual void setDriveStatus(const common::dataStructures::SecurityIdentity &cliIdentity, const std::string &driveName, const bool up, const bool force);
256
257
258
259
260
261
262
263
264
265
  /**
   * Prepares the catalogue for a new archive file and returns the information
   * required to queue the associated archive request.
   *
   * @param storageClass The storage class of the file to be archived.  This
   * will be used by the Catalogue to determine the destinate tape pool for
   * each tape copy.
   * @param user The user for whom the file is to be archived.  This will be
   * used by the Catalogue to determine the mount policy to be used when
   * archiving the file.
Steven Murray's avatar
Steven Murray committed
266
   * @return The information required to queue the associated archive request.
267
   */
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
  virtual common::dataStructures::ArchiveFileQueueCriteria prepareForNewFile(
    const std::string &storageClass,
    const common::dataStructures::UserIdentity &user);

  /**
   * Notifies the catalogue that a file has been written to tape.
   *
   * @param event The tape file written event.
   */
  virtual void fileWrittenToTape(const TapeFileWritten &event);

  /**
   * Prepares for a file retrieval by returning the information required to
   * queue the associated retrieve request(s).
   *
   * @param archiveFileId The unique identifier of the archived file that is
   * to be retrieved.
   * @param user The user for whom the file is to be retrieved.  This will be
   * used by the Catalogue to determine the mount policy to be used when
   * retrieving the file.
   *
   * @return The information required to queue the associated retrieve request(s).
   */
  virtual common::dataStructures::RetrieveFileQueueCriteria prepareToRetrieveFile(
    const uint64_t archiveFileId,
293
    const common::dataStructures::UserIdentity &user);
294

295
  virtual common::dataStructures::TapeCopyToPoolMap getTapeCopyToPoolMap(const std::string &storageClass) const;
296
297

  /**
298
   * Returns the mount policy for the specified end user.
299
   *
300
301
   * @param username The name of the end user.
   * @return The mount policy.
302
   */
303
  virtual common::dataStructures::MountPolicy getMountPolicyForAUser(const std::string &username) const;
304

305
306
307
  /**
   * Returns true if the specified user has admin privileges.
   *
308
   * @param cliIdentity The user of the command-line tool.
309
310
   * @return True if the specified user has admin privileges.:w
   */
311
  virtual bool isAdmin(const common::dataStructures::SecurityIdentity &cliIdentity) const;
312

313
314
315
316
317
318
319
320
  /**
   * Returns the list of tapes that can be written to be a tape drive in the
   * specified logical library.
   *
   * @param logicalLibraryName The name of the logical library.
   */
  virtual std::list<TapeForWriting> getTapesForWriting(const std::string &logicalLibraryName) const;

321
protected:
322

323
  /**
324
   * Returns true if the specified admin user exists.
325
   *
326
327
   * @param adminUsername The name of the admin user.
   * @return True if the admin user exists.
328
   */
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
  bool adminUserExists(const std::string adminUsername) const;

  /**
   * Returns true if the specified admin host exists.
   *
   * @param adminHost The name of the admin host.
   * @return True if the admin host exists.
   */
  bool adminHostExists(const std::string adminHost) const;

  /**
   * Returns true if the specified storage class exists.
   *
   * @param storageClassName The name of the storage class.
   * @return True if the storage class exists.
   */
  bool storageClassExists(const std::string &storageClassName) const;

  /**
   * Returns true if the specified tape pool exists.
   *
   * @param tapePoolName The name of the tape pool.
   * @return True if the tape pool exists.
   */
  bool tapePoolExists(const std::string &tapePoolName) const;

  /**
   * Returns true if the specified tape exists.
   *
   * @param vid The volume identifier of the tape.
   * @return True if the tape exists.
   */
  bool tapeExists(const std::string &vid) const;

  /**
   * Returns true if the specified logical library exists.
   *
   * @param logicalLibraryName The name of the logical library.
   * @return True if the logical library exists.
   */
  bool logicalLibraryExists(const std::string &logicalLibraryName) const;

  /**
   * Returns true if the specified mount policy exists.
   *
   * @param mountPolicyName The name of the mount policy
   * @return True if the mount policy exists.
   */
  bool mountPolicyExists(const std::string &mountPolicyName) const;
378

379
380
381
382
383
384
385
386
387
388
389
390
  /**
   * Returns true if the specified requester exists.
   *
   * @param requesterName The username of the requester.
   * @return True if the requester exists.
   */
  bool requesterExists(const std::string &requesterName) const;

  /**
   * Returns the specified requester mount-policy or NULL if one does not exist.
   *
   * @param requesterName The name of the requester.
391
   * @return The mount policy or NULL if one does not exists.
392
393
394
395
396
397
398
399
400
401
402
   */
  common::dataStructures::MountPolicy *getRequesterMountPolicy(const std::string &requesterName) const;

  /**
   * Returns true if the specified requester group exists.
   *
   * @param requesterGroupName The name of the requester group.
   * @return True if the requester group exists.
   */
  bool requesterGroupExists(const std::string &requesterGroupName) const;

403
404
405
406
407
408
409
410
411
  /**
   * Returns the specified requester-group mount-policy or NULL if one does not
   * exist.
   *
   * @param requesterGroupName The name of the requester group.
   * @return The mount policy or NULL if one does not exists.
   */
  common::dataStructures::MountPolicy *getRequesterGroupMountPolicy(const std::string &requesterGroupName) const;

412
  /**
413
414
   * An RdbmsCatalogue specific method that inserts the specified row into the
   * ArchiveFile table.
415
   *
416
   * @param row The row to be inserted.
417
   */
418
  void insertArchiveFile(const ArchiveFileRow &row);
419

420
421
422
423
424
  /**
   * Mutex to be used to a take a global lock on the in-memory database.
   */
  std::mutex m_mutex;

425
426
427
  /**
   * The connection to the underlying relational database.
   */
Steven Murray's avatar
Steven Murray committed
428
  std::unique_ptr<DbConn> m_conn;
429
430
431
432
433
434

  /**
   * Creates the database schema.
   */
  void createDbSchema();

Steven Murray's avatar
Steven Murray committed
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
  /**
   * Returns true if the specified user name is listed in the ADMIN_USER table.
   *
   * @param userName The name of the user to be search for in the ADMIN_USER
   * table.
   * @return true if the specified user name is listed in the ADMIN_USER table.
   */
  bool userIsAdmin(const std::string &userName) const;

  /**
   * Returns true if the specified host name is listed in the ADMIN_HOST table.
   *
   * @param userName The name of the host to be search for in the ADMIN_HOST
   * table.
   * @return true if the specified host name is listed in the ADMIN_HOST table.
   */
  bool hostIsAdmin(const std::string &userName) const;

453
454
455
456
457
458
459
460
461
462
  /**
   * Returns the expected number of archive routes for the specified storage
   * class as specified by the call to the createStorageClass() method as
   * opposed to the actual number entered so far using the createArchiveRoute()
   * method.
   *
   * @return The expected number of archive routes.
   */
  uint64_t getExpectedNbArchiveRoutes(const std::string &storageClass) const;

463
  /**
464
   * Inserts the specified tape file into the Tape table.
465
466
467
468
469
   *
   * @param tapeFile The tape file.
   * @param archiveFileId The identifier of the archive file of which the tape
   * file is a copy.
   */
470
  void insertTapeFile(const common::dataStructures::TapeFile &tapeFile, const uint64_t archiveFileId);
471

472
473
474
475
476
477
478
479
480
  /**
   * Sets the last FSeq of the specified tape to the specified value.
   *
   * @param vid The volume identifier of the tape.
   * @param lastFseq The new value of the last FSeq.
   */
  void setTapeLastFSeq(const std::string &vid, const uint64_t lastFSeq);

  /**
481
   * Returns the last FSeq of the specified tape.
482
483
484
485
486
487
   *
   * @param vid The volume identifier of the tape.
   * @return The last FSeq.
   */
  uint64_t getTapeLastFSeq(const std::string &vid) const;

488
489
490
491
492
493
494
495
  /**
   * Updates the lastFSeq column of the specified tape within the Tape table.
   *
   * @param vid The volume identifier of the tape.
   * @param lastFseq The new value of the lastFseq column.
   */
  void updateTapeLastFSeq(const std::string &vid, const uint64_t lastFSeq);

496
  /**
497
   * Returns the specified archive file or a NULL pointer if it does not exist.
498
499
   *
   * @param archiveFileId The identifier of the archive file.
500
   * @return The archive file or NULL.
501
502
   * an empty list.
   */
503
  std::unique_ptr<common::dataStructures::ArchiveFile> getArchiveFile(const uint64_t archiveFileId) const;
504

505
506
507
508
509
510
511
512
513
  /**
   * Throws an exception if the there is a mismatch between the expected and
   * actual common event data.
   *
   * @param expected The expected event data.
   * @param actual The actual event data.
   */
  void throwIfCommonEventDataMismatch(const common::dataStructures::ArchiveFile &expected,
    const TapeFileWritten &actual) const;
514
515
516
517
518
519
520
521
522

  /**
   * Returns the tape files for the specified archive file.
   *
   * @param archiveFileId The unique identifier of the archive file.
   * @return The tape files as a map from tape copy number to tape file.
   */
  std::map<uint64_t, common::dataStructures::TapeFile>getTapeFiles(const uint64_t archiveFileId) const;

523
524
525
526
527
528
529
530
531
532
  /**
   * Returns the mount policies for the specified requester and requester group.
   *
   * @param requesterName The name of the requester.
   * @param requesterGroupName The name of the requester group.
   * @return The mount policies.
   */
  RequesterAndGroupMountPolicies getMountPolicies(const std::string &requesterName,
    const std::string &requesterGroupName);

533
534
535
536
537
538
539
540
541
542
  /**
   * Returns a unique archive ID that can be used by a new archive file within
   * the catalogue.
   *
   * This method must be implemented by the sub-classes of RdbmsCatalogue
   * because different database technologies propose different solution to the
   * problem of generating ever increasing numeric identifiers.
   */
  virtual uint64_t getNextArchiveFileId() = 0;

543
544
545
546
547
548
549
550
551
552
553
  /**
   * Selects the specified tape within th eTape table for update.
   *
   * This method must be implemented by the sub-classes of RdbmsCatalogue
   * because some database technologies directly support SELECT FOR UPDATE
   * whilst others do not.
   *
   * @param vid The volume identifier of the tape.
   */
  virtual common::dataStructures::Tape selectTapeForUpdate(const std::string &vid) = 0;

554
}; // class RdbmsCatalogue
555
556
557

} // namespace catalogue
} // namespace cta