Catalogue.hpp 27 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
#include "catalogue/TapeItemWrittenPointer.hpp"
24
25
#include "catalogue/TapeFileWritten.hpp"
#include "catalogue/TapeForWriting.hpp"
26
#include "catalogue/TapePool.hpp"
27
#include "catalogue/TapeSearchCriteria.hpp"
28
29
#include "common/dataStructures/AdminUser.hpp"
#include "common/dataStructures/ArchiveFile.hpp"
30
#include "common/dataStructures/ArchiveFileQueueCriteria.hpp"
31
#include "common/dataStructures/ArchiveFileQueueCriteriaAndFileId.hpp"
32
#include "common/dataStructures/ArchiveFileSummary.hpp"
33
34
35
#include "common/dataStructures/ArchiveJob.hpp"
#include "common/dataStructures/ArchiveRoute.hpp"
#include "common/dataStructures/CancelRetrieveRequest.hpp"
36
#include "common/dataStructures/DiskFileInfo.hpp"
Daniele Kruse's avatar
Daniele Kruse committed
37
#include "common/dataStructures/DriveState.hpp"
38
39
40
41
#include "common/dataStructures/EntryLog.hpp"
#include "common/dataStructures/ListStorageClassRequest.hpp"
#include "common/dataStructures/LogicalLibrary.hpp"
#include "common/dataStructures/MountType.hpp"
42
#include "common/dataStructures/MountPolicy.hpp"
43
#include "common/dataStructures/ReadTestResult.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
#include "common/dataStructures/UpdateFileInfoRequest.hpp"
#include "common/dataStructures/UserIdentity.hpp"
#include "common/dataStructures/VerifyInfo.hpp"
57
#include "common/dataStructures/VidToTapeMap.hpp"
58
#include "common/dataStructures/WriteTestResult.hpp"
59
#include "common/exception/UserError.hpp"
60
#include "common/log/LogContext.hpp"
61
#include "common/log/Logger.hpp"
62
#include "common/optional.hpp"
63
64
65

#include <list>
#include <map>
66
67
68
#include <set>
#include <stdint.h>
#include <string>
69
#include <memory>
70

71
namespace cta {
72
73
74

namespace catalogue {

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

  /**
83
84
   * Destructor.
   */
85
  virtual ~Catalogue() = 0;
86

87
88
89
  //////////////////////////////////////////////////////////////////
  // START OF METHODS DIRECTLY INVOLVED DATA TRANSFER AND SCHEDULING
  //////////////////////////////////////////////////////////////////
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.
   */
97
  virtual void tapeLabelled(const std::string &vid, const std::string &drive) = 0;
98

99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
  /**
   * Checks the specified archival could take place and returns a new and
   * unique archive file identifier that can be used by a new archive file
   * within the catalogue.
   *
   * @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 new archive file identifier.
   */
  virtual uint64_t checkAndGetNextArchiveFileId(
    const std::string &diskInstanceName,
    const std::string &storageClassName,
    const common::dataStructures::UserIdentity &user) = 0;

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
  /**
   * Returns the information required to queue an 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 an archive request.
   */
  virtual common::dataStructures::ArchiveFileQueueCriteria getArchiveFileQueueCriteria(
    const std::string &diskInstanceName,
    const std::string &storageClassName,
    const common::dataStructures::UserIdentity &user) = 0;

139
140
141
142
143
144
  /**
   * 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.
145
   * @return The list of tapes for writing.
146
147
148
149
   */
  virtual std::list<TapeForWriting> getTapesForWriting(const std::string &logicalLibraryName) const = 0;

  /**
150
   * Notifies the catalogue that the specified files have been written to tape.
151
   *
152
   * @param events The tape file written events.
153
   */
154
  virtual void filesWrittenToTape(const std::set<TapeItemWrittenPointer> &event) = 0;
155

156
157
158
159
  /**
   * Notifies the CTA catalogue that the specified tape has been mounted in
   * order to archive files.
   *
160
161
162
   * The purpose of this method is to keep track of which drive mounted a given
   * tape for archiving files last.
   *
163
164
165
166
167
   * @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)

168
169
170
171
  /**
   * Prepares for a file retrieval by returning the information required to
   * queue the associated retrieve request(s).
   *
172
173
   * @param diskInstanceName The name of the instance from where the retrieval
   * request originated
174
175
176
177
178
   * @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.
179
   * @param lc The log context.
180
181
182
183
   *
   * @return The information required to queue the associated retrieve request(s).
   */
  virtual common::dataStructures::RetrieveFileQueueCriteria prepareToRetrieveFile(
184
    const std::string &diskInstanceName,
185
    const uint64_t archiveFileId,
186
187
    const common::dataStructures::UserIdentity &user,
    log::LogContext &lc) = 0;
188

189
190
191
192
  /**
   * Notifies the CTA catalogue that the specified tape has been mounted in
   * order to retrieve files.
   *
193
194
195
   * The purpose of this method is to keep track of which drive mounted a given
   * tape for retrieving files last.
   *
196
197
198
199
   * @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)
200
201
202
203
204
205
206
207
208
209

  /**
   * 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;

  ////////////////////////////////////////////////////////////////
210
  // END OF METHODS DIRECTLY INVOLVED DATA TRANSFER AND SCHEDULING
211
212
  ////////////////////////////////////////////////////////////////

Steven Murray's avatar
Steven Murray committed
213
  virtual void createAdminUser(const common::dataStructures::SecurityIdentity &admin, const std::string &username, const std::string &comment) = 0;
214
  virtual void deleteAdminUser(const std::string &username) = 0;
215
  virtual std::list<common::dataStructures::AdminUser> getAdminUsers() const = 0;
Steven Murray's avatar
Steven Murray committed
216
  virtual void modifyAdminUserComment(const common::dataStructures::SecurityIdentity &admin, const std::string &username, const std::string &comment) = 0;
217

218
219
220
  /**
   * Creates the specified storage class.
   *
Steven Murray's avatar
Steven Murray committed
221
   * @param admin The administrator.
222
223
224
   * @param storageClass The storage class.
   */
  virtual void createStorageClass(
Steven Murray's avatar
Steven Murray committed
225
    const common::dataStructures::SecurityIdentity &admin,
226
227
228
229
230
231
232
233
234
235
236
237
    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;

238
  virtual std::list<common::dataStructures::StorageClass> getStorageClasses() const = 0;
Steven Murray's avatar
Steven Murray committed
239
240
  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;
241

242
  virtual void createTapePool(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &vo, const uint64_t nbPartialTapes, const bool encryptionValue, const cta::optional<std::string> &supply, const std::string &comment) = 0;
243
  virtual void deleteTapePool(const std::string &name) = 0;
244
  virtual std::list<TapePool> getTapePools() const = 0;
245
  virtual void modifyTapePoolVo(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &vo) = 0;
Steven Murray's avatar
Steven Murray committed
246
247
248
  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;
249

250
  virtual void createArchiveRoute(
Steven Murray's avatar
Steven Murray committed
251
    const common::dataStructures::SecurityIdentity &admin,
252
253
    const std::string &diskInstanceName,
    const std::string &storageClassName,
254
    const uint32_t copyNb,
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
    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,
270
    const uint32_t copyNb) = 0;
271

272
  virtual std::list<common::dataStructures::ArchiveRoute> getArchiveRoutes() const = 0;
273
274
  virtual void modifyArchiveRouteTapePoolName(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &storageClassName, const uint32_t copyNb, const std::string &tapePoolName) = 0;
  virtual void modifyArchiveRouteComment(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &storageClassName, const uint32_t copyNb, const std::string &comment) = 0;
275

Steven Murray's avatar
Steven Murray committed
276
  virtual void createLogicalLibrary(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) = 0;
277
  virtual void deleteLogicalLibrary(const std::string &name) = 0;
278
  virtual std::list<common::dataStructures::LogicalLibrary> getLogicalLibraries() const = 0;
Steven Murray's avatar
Steven Murray committed
279
  virtual void modifyLogicalLibraryComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) = 0;
280

281
  /**
282
283
   * Creates a tape which is assumed to have logical block protection (LBP)
   * enabled.
284
   */
285
  virtual void createTape(
Steven Murray's avatar
Steven Murray committed
286
    const common::dataStructures::SecurityIdentity &admin,
287
    const std::string &vid,
288
289
    const std::string &mediaType,
    const std::string &vendor,
290
291
292
293
294
295
    const std::string &logicalLibraryName,
    const std::string &tapePoolName,
    const uint64_t capacityInBytes,
    const bool disabled,
    const bool full,
    const std::string &comment) = 0;
296

297
  virtual void deleteTape(const std::string &vid) = 0;
298
299
300
301
302
303
304
305
306
307

  /**
   * 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;

308
309
310
311
312
313
314
315
316
317
318
  /**
   * 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;

Steven Murray's avatar
Steven Murray committed
319
320
321
322
323
324
325
  /**
   * Returns all the tapes within the CTA catalogue.
   *
   * @return Map from tape volume identifier to tape.
   */
  virtual common::dataStructures::VidToTapeMap getAllTapes() const = 0;

326
327
328
329
330
331
332
333
334
335
  /**
   * 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
336
   * @param admin The administrator.
337
338
   * @param vid The volume identifier of the tape to be reclaimed.
   */
Steven Murray's avatar
Steven Murray committed
339
  virtual void reclaimTape(const common::dataStructures::SecurityIdentity &admin, const std::string &vid) = 0;
340
341
342
343
344
345
346
347
  
  /**
   * This method should ONLY be used for TESTS. It does exactly the same as the real reclaimTape but it does not verify the 
   * SUPERSEDED_BY_VID and SUPERSEDED_BY_FSEQ attributes
   * @param admin The administrator.
   * @param vid The volume identifier of the tape to be reclaimed.
   */
  virtual void fakeReclaimTapeForTests(const common::dataStructures::SecurityIdentity& admin, const std::string &vid) = 0;
348

349
350
  virtual void modifyTapeMediaType(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &mediaType) = 0;
  virtual void modifyTapeVendor(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &vendor) = 0;
Steven Murray's avatar
Steven Murray committed
351
352
353
354
  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;
355
356
357
358
359
360
361

  /**
   * 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
362
   * @param admin The administrator.
363
364
365
   * @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
366
  virtual void setTapeFull(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const bool fullValue) = 0;
367

Steven Murray's avatar
Steven Murray committed
368
369
  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;
370

Steven Murray's avatar
Steven Murray committed
371
372
373
374
  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;
375

376
   virtual void createMountPolicy(
Steven Murray's avatar
Steven Murray committed
377
    const common::dataStructures::SecurityIdentity &admin,
378
379
380
381
382
383
384
385
    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;

386
  /**
387
   * Returns the list of all existing mount policies.
388
   *
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
   * @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.
406
   *
Steven Murray's avatar
Steven Murray committed
407
   * @param admin The administrator.
408
   * @param mountPolicyName The name of the mount policy.
409
410
411
412
   * @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.
413
414
   * @param comment Comment.
   */
415
  virtual void createRequesterMountRule(
Steven Murray's avatar
Steven Murray committed
416
    const common::dataStructures::SecurityIdentity &admin,
417
    const std::string &mountPolicyName,
418
    const std::string &diskInstance,
419
420
421
422
    const std::string &requesterName,
    const std::string &comment) = 0;

  /**
423
424
425
426
427
428
429
430
431
432
433
   * 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.
   *
434
435
436
437
   * @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.
438
   */
439
  virtual void deleteRequesterMountRule(const std::string &diskInstanceName, const std::string &requesterName) = 0;
440

441
  /**   
442
443
   * Creates the rule that the specified mount policy will be used for the
   * specified requester group.
444
   *
445
446
   * Please note that requester mount-rules overrule requester-group
   * mount-rules.
447
   *
Steven Murray's avatar
Steven Murray committed
448
   * @param admin The administrator.
449
   * @param mountPolicyName The name of the mount policy.
450
451
452
453
   * @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.
454
   * @param comment Comment.
455
   */
456
  virtual void createRequesterGroupMountRule(
Steven Murray's avatar
Steven Murray committed
457
    const common::dataStructures::SecurityIdentity &admin,
458
    const std::string &mountPolicyName,
459
    const std::string &diskInstanceName,
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
    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.
   *
475
476
477
478
   * @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.
479
   */
480
481
482
  virtual void deleteRequesterGroupMountRule(
    const std::string &diskInstanceName,
    const std::string &requesterGroupName) = 0;
483

Steven Murray's avatar
Steven Murray committed
484
485
486
487
488
489
  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;
490

491
  /**
492
493
   * Returns the specified archive files.  Please note that the list of files
   * is ordered by archive file ID.
494
495
   *
   * @param searchCriteria The search criteria.
496
   * @return The archive files.
497
   */
498
  virtual ArchiveFileItor getArchiveFilesItor(
499
    const TapeFileSearchCriteria &searchCriteria = TapeFileSearchCriteria()) const = 0;
500

501
  /**
502
   * Returns the specified files in tape file sequence order.
503
504
505
506
507
   *
   * @param vid The volume identifier of the tape.
   * @param startFSeq The file sequence number of the first file.  Please note
   * that there might not be a file with this exact file sequence number.
   * @param maxNbFiles The maximum number of files to be returned.
508
   * @return The specified files in tape file sequence order.
509
   */
510
  virtual std::list<common::dataStructures::ArchiveFile> getFilesForRepack(
511
512
513
514
    const std::string &vid,
    const uint64_t startFSeq,
    const uint64_t maxNbFiles) const = 0;

515
516
517
518
519
520
521
522
523
524
525
526
527
528
  /**
   * Returns all the tape copies (no matter their VIDs) of the archive files
   * associated with the tape files on the specified tape in FSEQ order
   * starting at the specified startFSeq.
   *
   * @param vid The volume identifier of the tape.
   * @param startFSeq The file sequence number of the first file.  Please note
   * that there might not be a file with this exact file sequence number.
   * @return The specified files in FSEQ order.
   */
  virtual ArchiveFileItor getArchiveFilesForRepackItor(
    const std::string &vid,
    const uint64_t startFSeq) const = 0;

529
  /**
530
   * Returns a summary of the tape files that meet the specified search
531
532
533
534
535
   * criteria.
   *
   * @param searchCriteria The search criteria.
   * @return The summary.
   */
536
  virtual common::dataStructures::ArchiveFileSummary getTapeFileSummary(
537
    const TapeFileSearchCriteria &searchCriteria = TapeFileSearchCriteria()) const = 0;
538
539
540
541
542
543
544
545
546
547
548

  /**
   * 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;
549

550
551
552
553
  /**
   * Deletes the specified archive file and its associated tape copies from the
   * catalogue.
   *
554
555
556
557
   * 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.
   *
558
559
560
   * Please note that this method is idempotent.  If the file to be deleted does
   * not exist in the CTA catalogue then this method returns without error.
   *
561
562
   * @param instanceName The name of the instance from where the deletion request
   * originated
563
   * @param archiveFileId The unique identifier of the archive file.
564
   * @param lc The log context.
565
566
567
   * @return The metadata of the deleted archive file including the metadata of
   * the associated and also deleted tape copies.
   */
568
569
  virtual void deleteArchiveFile(const std::string &instanceName, const uint64_t archiveFileId,
    log::LogContext &lc) = 0;
570

571
572
573
574
  /**
   * 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
575
   * @param admin The administrator.
576
577
578
   * @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
579
  virtual bool isAdmin(const common::dataStructures::SecurityIdentity &admin) const = 0;
580

581
  /**
582
   * Checks that the most trivial query goes through. Throws an exception if not.
583
   */
584
  virtual void ping() = 0;
585

586
587
588
589
590
591
592
593
  /**
   * 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;

594
595
596
597
598
599
600
  /**
   * 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;
601
602
603
  
  /**
   * Returns true if non superseded files exist after fSeq in the tape where vid is passed in parameter
604
   * If there is only superseded files after fSeq, these tape files will be deleted
605
606
607
608
609
   * 
   * @param vid the vid of the tape to check if non superseded files exist after fSeq
   * @param fSeq the fSeq after which we want to check if non superseded files exist
   * @return true if non superseded files exist, false otherwise
   */
610
  virtual bool existNonSupersededFilesAfterFSeqAndDeleteTapeFilesForWriting(const std::string &vid, const uint64_t fSeq) const  = 0;
611

612
613
}; // class Catalogue

614
} // namespace catalogue
615
} // namespace cta