Catalogue.hpp 24.7 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
11
12
13
14
15
16
17
18
19
20
 *
 * 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 "catalogue/ArchiveFileItor.hpp"
22
#include "catalogue/TapeFileSearchCriteria.hpp"
23
24
#include "catalogue/TapeFileWritten.hpp"
#include "catalogue/TapeForWriting.hpp"
25
#include "catalogue/TapeSearchCriteria.hpp"
26
27
28
#include "common/dataStructures/AdminHost.hpp"
#include "common/dataStructures/AdminUser.hpp"
#include "common/dataStructures/ArchiveFile.hpp"
Steven Murray's avatar
Steven Murray committed
29
#include "common/dataStructures/ArchiveFileQueueCriteria.hpp"
30
#include "common/dataStructures/ArchiveFileSummary.hpp"
31
32
33
#include "common/dataStructures/ArchiveJob.hpp"
#include "common/dataStructures/ArchiveRoute.hpp"
#include "common/dataStructures/CancelRetrieveRequest.hpp"
34
#include "common/dataStructures/DiskFileInfo.hpp"
Daniele Kruse's avatar
Daniele Kruse committed
35
#include "common/dataStructures/DriveState.hpp"
36
37
38
39
#include "common/dataStructures/EntryLog.hpp"
#include "common/dataStructures/ListStorageClassRequest.hpp"
#include "common/dataStructures/LogicalLibrary.hpp"
#include "common/dataStructures/MountType.hpp"
40
#include "common/dataStructures/MountPolicy.hpp"
41
42
43
#include "common/dataStructures/ReadTestResult.hpp"
#include "common/dataStructures/RepackInfo.hpp"
#include "common/dataStructures/RepackType.hpp"
44
45
#include "common/dataStructures/RequesterGroupMountRule.hpp"
#include "common/dataStructures/RequesterMountRule.hpp"
46
#include "common/dataStructures/RetrieveFileQueueCriteria.hpp"
47
48
49
50
51
#include "common/dataStructures/RetrieveJob.hpp"
#include "common/dataStructures/RetrieveRequest.hpp"
#include "common/dataStructures/SecurityIdentity.hpp"
#include "common/dataStructures/StorageClass.hpp"
#include "common/dataStructures/Tape.hpp"
52
#include "common/dataStructures/TapeCopyToPoolMap.hpp"
53
#include "common/dataStructures/TapeFile.hpp"
54
55
56
57
#include "common/dataStructures/TapePool.hpp"
#include "common/dataStructures/UpdateFileInfoRequest.hpp"
#include "common/dataStructures/UserIdentity.hpp"
#include "common/dataStructures/VerifyInfo.hpp"
58
#include "common/dataStructures/VidToTapeMap.hpp"
59
#include "common/dataStructures/WriteTestResult.hpp"
60
61
62
63

#include <list>
#include <map>
#include <memory>
64
65
66
#include <set>
#include <stdint.h>
#include <string>
67

68
namespace cta {
69
70
71

namespace catalogue {

72
73
74
75
76
77
78
79
/**
 * Abstract class defining the interface to the CTA catalogue responsible for
 * storing crticial information about archive files, tapes and tape files.
 */
class Catalogue {
public:

  /**
80
81
   * Destructor.
   */
82
  virtual ~Catalogue() = 0;
83

84
85
86
  //////////////////////////////////////////////////////////////////
  // START OF METHODS DIRECTLY INVOLVED DATA TRANSFER AND SCHEDULING
  //////////////////////////////////////////////////////////////////
87
88
89
90
91
92
93
94
95
96

  /**
   * Notifies the catalogue that the specified tape was labelled.
   *
   * @param vid The volume identifier of the tape.
   * @param drive The name of tape drive that was used to label the tape.
   * @param lbpIsOn Set to true if Logical Block Protection (LBP) was enabled.
   */
  virtual void tapeLabelled(const std::string &vid, const std::string &drive, const bool lbpIsOn) = 0;

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
  /**
   * Prepares the catalogue for a new archive file and returns the information
   * required to queue the associated archive request.
   *
   * @param diskInstanceName The name of the disk instance to which the
   * storage class belongs.
   * @param storageClassName The name of the storage class of the file to be
   * archived.  The storage class name is only guaranteed to be unique within
   * its disk instance.  The storage class name will be used by the Catalogue
   * to determine the destination 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.
   * @return The information required to queue the associated archive request.
   */
  virtual common::dataStructures::ArchiveFileQueueCriteria prepareForNewFile(
    const std::string &diskInstanceName,
    const std::string &storageClassName,
    const common::dataStructures::UserIdentity &user) = 0;

117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
  /**
   * Returns the list of tapes that can be written to by a tape drive in the
   * specified logical library, in other words tapes that are labelled, not
   * disabled, not full and are in the specified logical library.
   *
   * @param logicalLibraryName The name of the logical library.
   */
  virtual std::list<TapeForWriting> getTapesForWriting(const std::string &logicalLibraryName) const = 0;

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

133
134
135
136
  /**
   * Notifies the CTA catalogue that the specified tape has been mounted in
   * order to archive files.
   *
137
138
139
   * The purpose of this method is to keep track of which drive mounted a given
   * tape for archiving files last.
   *
140
141
142
143
144
   * @param vid The volume identifier of the tape.
   * @param drive The name of the drive where the tape was mounted.
   */
  virtual void tapeMountedForArchive(const std::string &vid, const std::string &drive) = 0; // internal function (noCLI)

145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
  /**
   * Prepares for a file retrieval by returning the information required to
   * queue the associated retrieve request(s).
   *
   * @param instanceName The name of the instance from where the retrieval request originated
   * @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 std::string &instanceName,
    const uint64_t archiveFileId,
    const common::dataStructures::UserIdentity &user) = 0;

163
164
165
166
  /**
   * Notifies the CTA catalogue that the specified tape has been mounted in
   * order to retrieve files.
   *
167
168
169
   * The purpose of this method is to keep track of which drive mounted a given
   * tape for retrieving files last.
   *
170
171
172
173
   * @param vid The volume identifier of the tape.
   * @param drive The name of the drive where the tape was mounted.
   */
  virtual void tapeMountedForRetrieve(const std::string &vid, const std::string &drive) = 0; // internal function (noCLI)
174
175
176
177
178
179
180
181
182
183

  /**
   * This method notifies the CTA catalogue that there is no more free space on
   * the specified tape.
   *
   * @param vid The volume identifier of the tape.
   */
  virtual void noSpaceLeftOnTape(const std::string &vid) = 0;

  ////////////////////////////////////////////////////////////////
184
  // END OF METHODS DIRECTLY INVOLVED DATA TRANSFER AND SCHEDULING
185
186
  ////////////////////////////////////////////////////////////////

Steven Murray's avatar
Steven Murray committed
187
  virtual void createAdminUser(const common::dataStructures::SecurityIdentity &admin, const std::string &username, const std::string &comment) = 0;
188
  virtual void deleteAdminUser(const std::string &username) = 0;
189
  virtual std::list<common::dataStructures::AdminUser> getAdminUsers() const = 0;
Steven Murray's avatar
Steven Murray committed
190
  virtual void modifyAdminUserComment(const common::dataStructures::SecurityIdentity &admin, const std::string &username, const std::string &comment) = 0;
191

Steven Murray's avatar
Steven Murray committed
192
  virtual void createAdminHost(const common::dataStructures::SecurityIdentity &admin, const std::string &hostName, const std::string &comment) = 0;
193
  virtual void deleteAdminHost(const std::string &hostName) = 0;
194
  virtual std::list<common::dataStructures::AdminHost> getAdminHosts() const = 0;
Steven Murray's avatar
Steven Murray committed
195
  virtual void modifyAdminHostComment(const common::dataStructures::SecurityIdentity &admin, const std::string &hostName, const std::string &comment) = 0;
196

197
198
199
  /**
   * Creates the specified storage class.
   *
Steven Murray's avatar
Steven Murray committed
200
   * @param admin The administrator.
201
202
203
   * @param storageClass The storage class.
   */
  virtual void createStorageClass(
Steven Murray's avatar
Steven Murray committed
204
    const common::dataStructures::SecurityIdentity &admin,
205
206
207
208
209
210
211
212
213
214
215
216
    const common::dataStructures::StorageClass &storageClass) = 0;

  /**
   * Deletes the specified storage class.
   *
   * @param diskInstanceName The name of the disk instance to which the
   * storage class belongs.
   * @param stoargeClassName The name of the storage class which is only
   * guaranteed to be unique within its disk isntance.
   */
  virtual void deleteStorageClass(const std::string &diskInstanceName, const std::string &storageClassName) = 0;

217
  virtual std::list<common::dataStructures::StorageClass> getStorageClasses() const = 0;
Steven Murray's avatar
Steven Murray committed
218
219
  virtual void modifyStorageClassNbCopies(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &name, const uint64_t nbCopies) = 0;
  virtual void modifyStorageClassComment(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &name, const std::string &comment) = 0;
220

Steven Murray's avatar
Steven Murray committed
221
  virtual void createTapePool(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t nbPartialTapes, const bool encryptionValue, const std::string &comment) = 0;
222
  virtual void deleteTapePool(const std::string &name) = 0;
223
  virtual std::list<common::dataStructures::TapePool> getTapePools() const = 0;
Steven Murray's avatar
Steven Murray committed
224
225
226
  virtual void modifyTapePoolNbPartialTapes(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t nbPartialTapes) = 0;
  virtual void modifyTapePoolComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) = 0;
  virtual void setTapePoolEncryption(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const bool encryptionValue) = 0;
227

228
  virtual void createArchiveRoute(
Steven Murray's avatar
Steven Murray committed
229
    const common::dataStructures::SecurityIdentity &admin,
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
    const std::string &diskInstanceName,
    const std::string &storageClassName,
    const uint64_t copyNb,
    const std::string &tapePoolName,
    const std::string &comment) = 0;

  /**
   * Deletes the specified archive route.
   *
   * @param diskInstanceName The name of the disk instance to which the storage
   * class belongs.
   * @param storageClassName The name of the storage class which is only
   * guaranteed to be unique within its disk instance.
   * @param copyNb The copy number of the tape file.
   */
  virtual void deleteArchiveRoute(
    const std::string &diskInstanceName,
    const std::string &storageClassName,
    const uint64_t copyNb) = 0;

250
  virtual std::list<common::dataStructures::ArchiveRoute> getArchiveRoutes() const = 0;
Steven Murray's avatar
Steven Murray committed
251
252
  virtual void modifyArchiveRouteTapePoolName(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &storageClassName, const uint64_t copyNb, const std::string &tapePoolName) = 0;
  virtual void modifyArchiveRouteComment(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &storageClassName, const uint64_t copyNb, const std::string &comment) = 0;
253

Steven Murray's avatar
Steven Murray committed
254
  virtual void createLogicalLibrary(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) = 0;
255
  virtual void deleteLogicalLibrary(const std::string &name) = 0;
256
  virtual std::list<common::dataStructures::LogicalLibrary> getLogicalLibraries() const = 0;
Steven Murray's avatar
Steven Murray committed
257
  virtual void modifyLogicalLibraryComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) = 0;
258

259
  /**
260
261
   * Creates a tape which is assumed to have logical block protection (LBP)
   * enabled.
262
263
264
265
   *
   * @param encryptionKey The optional identifier of the encrption key.  This
   * optional parameter should either have a non-empty string value or no value
   * at all.  Empty strings are prohibited.
266
   */
267
  virtual void createTape(
Steven Murray's avatar
Steven Murray committed
268
    const common::dataStructures::SecurityIdentity &admin,
269
270
271
    const std::string &vid,
    const std::string &logicalLibraryName,
    const std::string &tapePoolName,
272
    const optional<std::string> &encryptionKey,
273
274
275
276
    const uint64_t capacityInBytes,
    const bool disabled,
    const bool full,
    const std::string &comment) = 0;
277
  virtual void deleteTape(const std::string &vid) = 0;
278
279
280
281
282
283
284
285
286
287

  /**
   * Returns the list of tapes that meet the specified search criteria.
   *
   * @param searchCriteria The search criteria.
   * @return The list of tapes.
   */
  virtual std::list<common::dataStructures::Tape> getTapes(
    const TapeSearchCriteria &searchCriteria = TapeSearchCriteria()) const = 0;

288
289
290
291
292
293
294
295
296
297
298
  /**
   * Returns the tapes with the specified volume identifiers.
   *
   * This method will throw an exception if it cannot find ALL of the specified
   * tapes.
   *
   * @param vids The tape volume identifiers (VIDs).
   * @return Map from tape volume identifier to tape.
   */
  virtual common::dataStructures::VidToTapeMap getTapesByVid(const std::set<std::string> &vids) const = 0;

299
300
301
302
303
304
305
306
307
308
  /**
   * Reclaims the specified tape.
   *
   * This method will throw an exception if the specified tape does not exist.
   *
   * This method will throw an exception if the specified tape is not FULL.
   *
   * This method will throw an exception if there is still at least one tape
   * file recorded in the cataligue as being on the specified tape.
   *
Steven Murray's avatar
Steven Murray committed
309
   * @param admin The administrator.
310
311
   * @param vid The volume identifier of the tape to be reclaimed.
   */
Steven Murray's avatar
Steven Murray committed
312
  virtual void reclaimTape(const common::dataStructures::SecurityIdentity &admin, const std::string &vid) = 0;
313

Steven Murray's avatar
Steven Murray committed
314
315
316
317
  virtual void modifyTapeLogicalLibraryName(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &logicalLibraryName) = 0;
  virtual void modifyTapeTapePoolName(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &tapePoolName) = 0;
  virtual void modifyTapeCapacityInBytes(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const uint64_t capacityInBytes) = 0;
  virtual void modifyTapeEncryptionKey(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &encryptionKey) = 0;
318
319
320
321
322
323
324

  /**
   * Sets the full status of the specified tape.
   *
   * Please note that this method is to be called by the CTA front-end in
   * response to a command from the CTA command-line interface (CLI).
   *
Steven Murray's avatar
Steven Murray committed
325
   * @param admin The administrator.
326
327
328
   * @param vid The volume identifier of the tape to be marked as full.
   * @param fullValue Set to true if the tape is full.
   */
Steven Murray's avatar
Steven Murray committed
329
  virtual void setTapeFull(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const bool fullValue) = 0;
330

Steven Murray's avatar
Steven Murray committed
331
332
  virtual void setTapeDisabled(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const bool disabledValue) = 0;
  virtual void modifyTapeComment(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &comment) = 0;
333

Steven Murray's avatar
Steven Murray committed
334
335
336
337
  virtual void modifyRequesterMountRulePolicy(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &requesterName, const std::string &mountPolicy) = 0;
  virtual void modifyRequesteMountRuleComment(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &requesterName, const std::string &comment) = 0;
  virtual void modifyRequesterGroupMountRulePolicy(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &requesterGroupName, const std::string &mountPolicy) = 0;
  virtual void modifyRequesterGroupMountRuleComment(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &requesterGroupName, const std::string &comment) = 0;
338

339
   virtual void createMountPolicy(
Steven Murray's avatar
Steven Murray committed
340
    const common::dataStructures::SecurityIdentity &admin,
341
342
343
344
345
346
347
348
    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) = 0;

349
  /**
350
   * Returns the list of all existing mount policies.
351
   *
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
   * @return the list of all existing mount policies.
   */
  virtual std::list<common::dataStructures::MountPolicy> getMountPolicies() const = 0;

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

  /**
   * 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.
369
   *
Steven Murray's avatar
Steven Murray committed
370
   * @param admin The administrator.
371
   * @param mountPolicyName The name of the mount policy.
372
373
374
375
   * @param diskInstance The name of the disk instance to which the requester
   * belongs.
   * @param requesterName The name of the requester which is only guarantted to
   * be unique within its disk instance.
376
377
   * @param comment Comment.
   */
378
  virtual void createRequesterMountRule(
Steven Murray's avatar
Steven Murray committed
379
    const common::dataStructures::SecurityIdentity &admin,
380
    const std::string &mountPolicyName,
381
    const std::string &diskInstance,
382
383
384
385
    const std::string &requesterName,
    const std::string &comment) = 0;

  /**
386
387
388
389
390
391
392
393
394
395
396
   * 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 = 0;

  /**
   * Deletes the specified mount rule.
   *
397
398
399
400
   * @param diskInstanceName The name of the disk instance to which the
   * requester belongs.
   * @param requesterName The name of the requester which is only guaranteed to
   * be unique within its disk instance.
401
   */
402
  virtual void deleteRequesterMountRule(const std::string &diskInstanceName, const std::string &requesterName) = 0;
403

404
  /**   
405
406
   * Creates the rule that the specified mount policy will be used for the
   * specified requester group.
407
   *
408
409
   * Please note that requester mount-rules overrule requester-group
   * mount-rules.
410
   *
Steven Murray's avatar
Steven Murray committed
411
   * @param admin The administrator.
412
   * @param mountPolicyName The name of the mount policy.
413
414
415
416
   * @param diskInstanceName The name of the disk instance to which the
   * requester group belongs.
   * @param requesterGroupName The name of the requester group which is only
   * guarantted to be unique within its disk instance.
417
   * @param comment Comment.
418
   */
419
  virtual void createRequesterGroupMountRule(
Steven Murray's avatar
Steven Murray committed
420
    const common::dataStructures::SecurityIdentity &admin,
421
    const std::string &mountPolicyName,
422
    const std::string &diskInstanceName,
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
    const std::string &requesterGroupName,
    const std::string &comment) = 0;

  /**
   * 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.
   */
  virtual std::list<common::dataStructures::RequesterGroupMountRule> getRequesterGroupMountRules() const = 0;

  /**
   * Deletes the specified mount rule.
   *
438
439
440
441
   * @param diskInstanceName The name of the disk instance to which the
   * requester group belongs.
   * @param requesterGroupName The name of the requester group which is only
   * guaranteed to be unique within its disk instance.
442
   */
443
444
445
  virtual void deleteRequesterGroupMountRule(
    const std::string &diskInstanceName,
    const std::string &requesterGroupName) = 0;
446

Steven Murray's avatar
Steven Murray committed
447
448
449
450
451
452
  virtual void modifyMountPolicyArchivePriority(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t archivePriority) = 0;
  virtual void modifyMountPolicyArchiveMinRequestAge(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t minArchiveRequestAge) = 0;
  virtual void modifyMountPolicyRetrievePriority(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t retrievePriority) = 0;
  virtual void modifyMountPolicyRetrieveMinRequestAge(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t minRetrieveRequestAge) = 0;
  virtual void modifyMountPolicyMaxDrivesAllowed(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t maxDrivesAllowed) = 0;
  virtual void modifyMountPolicyComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) = 0;
453

454
455
  /**
   * Returns an iterator over the list of archive files that meet the specified
456
457
458
459
460
461
462
   * search criteria.
   *
   * Please note that the list is ordered by archive file ID.
   *
   * Please note that this method will throw an exception if the
   * nbArchiveFilesToPrefetch parameter is set to 0.  The parameter must be set
   * to a value greater than or equal to 1.
463
464
465
   *
   * @param searchCriteria The search criteria.
   * @param nbArchiveFilesToPrefetch The number of archive files to prefetch.
466
   * This parameter must be set to a value equal to or greater than 1.
467
468
469
   * @return An iterator over the list of archive files.
   */
  virtual std::unique_ptr<ArchiveFileItor> getArchiveFileItor(
470
    const TapeFileSearchCriteria &searchCriteria = TapeFileSearchCriteria(),
471
472
473
    const uint64_t nbArchiveFilesToPrefetch = 1000) const = 0;

  /**
474
   * Returns a summary of the tape files that meet the specified search
475
476
477
478
479
   * criteria.
   *
   * @param searchCriteria The search criteria.
   * @return The summary.
   */
480
  virtual common::dataStructures::ArchiveFileSummary getTapeFileSummary(
481
    const TapeFileSearchCriteria &searchCriteria = TapeFileSearchCriteria()) const = 0;
482
483
484
485
486
487
488
489
490
491
492

  /**
   * 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) = 0;
493

494
495
496
497
  /**
   * Deletes the specified archive file and its associated tape copies from the
   * catalogue.
   *
498
499
500
501
   * Please note that the name of the disk instance is specified in order to
   * prevent a disk instance deleting an archive file that belongs to another
   * disk instance.
   *
502
503
   * @param instanceName The name of the instance from where the deletion request
   * originated
504
505
506
507
   * @param archiveFileId The unique identifier of the archive file.
   * @return The metadata of the deleted archive file including the metadata of
   * the associated and also deleted tape copies.
   */
508
509
  virtual common::dataStructures::ArchiveFile deleteArchiveFile(const std::string &instanceName, 
    const uint64_t archiveFileId) = 0;
510

511
512
513
514
  /**
   * Returns true if the specified user running the CTA command-line tool on
   * the specified host has administrator privileges.
   *
Steven Murray's avatar
Steven Murray committed
515
   * @param admin The administrator.
516
517
518
   * @return True if the specified user running the CTA command-line tool on
   * the specified host has administrator privileges.
   */
Steven Murray's avatar
Steven Murray committed
519
  virtual bool isAdmin(const common::dataStructures::SecurityIdentity &admin) const = 0;
520

521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
  /**
   * Returns true if SCHEMA_STATUS column of the CTA_TABLE contains the value
   * LOCKED.
   *
   * @return True if SCHEMA_STATUS column of the CTA_TABLE contains the value
   * LOCKED.
   */
  virtual bool schemaIsLocked() const = 0;

  /**
   * Sets the value of the SCHEMA_STATUS column of the CTA_TABLE to LOCKED.
   *
   * Please note that this method is idempotent.
   */
  virtual void lockSchema() = 0;

  /**
   * Sets the value of the SCHEMA_STATUS column of the CTA_TABLE to UNLOCKED.
   *
   * Please note that this method is idempotent.
   */
  virtual void unlockSchema() = 0;

544
  /**
545
   * Checks that the most trivial query goes through. Throws an exception if not.
546
   */
547
  virtual void ping() = 0;
548

549
550
551
552
553
554
555
556
  /**
   * Returns true if the specified tape pool exists.
   *
   * @param tapePoolName The name of the tape pool.
   * @return True if the tape pool exists.
   */
  virtual bool tapePoolExists(const std::string &tapePoolName) const = 0;

557
558
559
560
561
562
563
564
  /**
   * Returns true if the specified tape exists.
   *
   * @param vid The volume identifier of the tape.
   * @return True if the tape exists.
   */
  virtual bool tapeExists(const std::string &vid) const = 0;

565
566
}; // class Catalogue

567
} // namespace catalogue
568
} // namespace cta