Catalogue.hpp 48 KB
Newer Older
1
/*
2
 * @project        The CERN Tape Archive (CTA)
3
 * @copyright      Copyright(C) 2015-2021 CERN
4
5
6
7
 * @license        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.
8
 *
9
10
11
12
 *                 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.
13
 *
14
15
 *                 You should have received a copy of the GNU General Public License
 *                 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17
18
19
 */

#pragma once

20
#include "catalogue/CatalogueItor.hpp"
21
#include "catalogue/CreateTapeAttributes.hpp"
22
23
#include "catalogue/MediaType.hpp"
#include "catalogue/MediaTypeWithLogs.hpp"
24
#include "catalogue/SchemaVersion.hpp"
25
#include "catalogue/TapeFileSearchCriteria.hpp"
26
#include "catalogue/TapeItemWrittenPointer.hpp"
27
28
#include "catalogue/TapeFileWritten.hpp"
#include "catalogue/TapeForWriting.hpp"
29
#include "catalogue/TapePool.hpp"
30
#include "catalogue/TapeSearchCriteria.hpp"
31
32
#include "common/dataStructures/AdminUser.hpp"
#include "common/dataStructures/ArchiveFile.hpp"
33
#include "common/dataStructures/ArchiveFileQueueCriteria.hpp"
34
#include "common/dataStructures/ArchiveFileQueueCriteriaAndFileId.hpp"
35
#include "common/dataStructures/ArchiveFileSummary.hpp"
36
37
38
#include "common/dataStructures/ArchiveJob.hpp"
#include "common/dataStructures/ArchiveRoute.hpp"
#include "common/dataStructures/CancelRetrieveRequest.hpp"
39
#include "common/dataStructures/DeleteArchiveRequest.hpp"
40
#include "common/dataStructures/DiskFileInfo.hpp"
Daniele Kruse's avatar
Daniele Kruse committed
41
#include "common/dataStructures/DriveState.hpp"
42
#include "common/dataStructures/FileRecycleLog.hpp"
43
44
45
46
#include "common/dataStructures/EntryLog.hpp"
#include "common/dataStructures/ListStorageClassRequest.hpp"
#include "common/dataStructures/LogicalLibrary.hpp"
#include "common/dataStructures/MountType.hpp"
47
#include "common/dataStructures/MountPolicy.hpp"
48
#include "common/dataStructures/ReadTestResult.hpp"
49
50
#include "common/dataStructures/RequesterGroupMountRule.hpp"
#include "common/dataStructures/RequesterMountRule.hpp"
51
#include "common/dataStructures/RetrieveFileQueueCriteria.hpp"
52
53
54
55
56
#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"
57
#include "common/dataStructures/TapeCopyToPoolMap.hpp"
58
#include "common/dataStructures/TapeFile.hpp"
59
#include "common/dataStructures/UpdateFileInfoRequest.hpp"
60
#include "common/dataStructures/RequesterIdentity.hpp"
61
#include "common/dataStructures/VirtualOrganization.hpp"
62
#include "common/dataStructures/VidToTapeMap.hpp"
63
#include "common/dataStructures/WriteTestResult.hpp"
64
#include "common/exception/FileSizeMismatch.hpp"
65
#include "common/exception/TapeFseqMismatch.hpp"
66
#include "common/exception/UserError.hpp"
67
#include "common/log/LogContext.hpp"
68
#include "common/log/Logger.hpp"
69
#include "common/optional.hpp"
70
#include "disk/DiskSystem.hpp"
71
#include "RecyleTapeFileSearchCriteria.hpp"
72
#include "CreateMountPolicyAttributes.hpp"
73
74
75

#include <list>
#include <map>
76
#include <memory>
77
78
79
#include <set>
#include <stdint.h>
#include <string>
80

81
namespace cta {
82
83

namespace catalogue {
84
85
  
CTA_GENERATE_EXCEPTION_CLASS(WrongSchemaVersionException);
86

87
88
89
90
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedANonExistentDiskSystem);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedANonEmptyDiskSystemAfterDelete);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedANonEmptyLogicalLibrary);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedANonEmptyTape);
91
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedANonExistentArchiveRoute);
92
93
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedANonExistentLogicalLibrary);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedANonExistentTape);
94
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedANonExistentTapePool);
95
96
97
98
99
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringComment);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringDiskSystemName);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringFileRegexp);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringFreeSpaceQueryURL);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAZeroRefreshInterval);
100
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAZeroSleepTime);
101
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAZeroTargetedFreeSpace);
102
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringActivity);
103
104
105
106
107
108
109
110
111
112
113
114
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringCartridge);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringDiskInstanceName);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringLogicalLibraryName);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringMediaType);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringMediaTypeName);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringStorageClassName);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringTapePoolName);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringUsername);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringVendor);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringVid);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringVo);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyTapePool);
115
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnOutOfRangeActivityWeight);
116
117
118
119
120
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAZeroCapacity);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAZeroCopyNb);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedMediaTypeUsedByTapes);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedStorageClassUsedByArchiveFiles);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedStorageClassUsedByArchiveRoutes);
121
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedStorageClassUsedByFileRecycleLogs);
122
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedTapePoolUsedInAnArchiveRoute);
123
124
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedANonExistentTapeState);
CTA_GENERATE_USER_EXCEPTION_CLASS(UserSpecifiedAnEmptyStringReasonWhenTapeStateNotActive);
125

126
127
/**
 * Abstract class defining the interface to the CTA catalogue responsible for
128
 * storing critical information about archive files, tapes and tape files.
129
130
131
132
133
 */
class Catalogue {
public:

  /**
134
135
   * Destructor.
   */
136
  virtual ~Catalogue() = 0;
137

138
139
140
  //////////////////////////////////////////////////////////////////
  // START OF METHODS DIRECTLY INVOLVED DATA TRANSFER AND SCHEDULING
  //////////////////////////////////////////////////////////////////
141
142
143
144
145
146
147

  /**
   * 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.
   */
148
  virtual void tapeLabelled(const std::string &vid, const std::string &drive) = 0;
149

150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
  /**
   * 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,
169
    const common::dataStructures::RequesterIdentity &user) = 0;
170

171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
  /**
   * 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,
188
    const common::dataStructures::RequesterIdentity &user) = 0;
189

190
191
192
  /**
   * 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
193
   * disabled, not full, not read-only and are in the specified logical library.
194
195
   *
   * @param logicalLibraryName The name of the logical library.
196
   * @return The list of tapes for writing.
197
198
199
200
   */
  virtual std::list<TapeForWriting> getTapesForWriting(const std::string &logicalLibraryName) const = 0;

  /**
201
   * Notifies the catalogue that the specified files have been written to tape.
202
   *
203
   * @param events The tape file written events.
204
205
   * @throw TapeFseqMismatch If an unexpected tape file sequence number is encountered.
   * @throw FileSizeMismatch If an unexpected tape file size is encountered.
206
   */
207
  virtual void filesWrittenToTape(const std::set<TapeItemWrittenPointer> &event) = 0;
208

209
210
211
212
  /**
   * Notifies the CTA catalogue that the specified tape has been mounted in
   * order to archive files.
   *
213
214
215
   * The purpose of this method is to keep track of which drive mounted a given
   * tape for archiving files last.
   *
216
217
218
219
220
   * @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)

221
222
223
224
  /**
   * Prepares for a file retrieval by returning the information required to
   * queue the associated retrieve request(s).
   *
225
226
   * @param diskInstanceName The name of the instance from where the retrieval
   * request originated
227
228
229
230
231
   * @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.
232
233
   * @param activity The activity under which the user wants to start the retrieve
   * The call will fail if the activity is set and unknown. 
234
   * @param lc The log context.
235
236
237
238
   *
   * @return The information required to queue the associated retrieve request(s).
   */
  virtual common::dataStructures::RetrieveFileQueueCriteria prepareToRetrieveFile(
239
    const std::string &diskInstanceName,
240
    const uint64_t archiveFileId,
241
    const common::dataStructures::RequesterIdentity &user,
242
    const optional<std::string> & activity,
243
    log::LogContext &lc) = 0;
244

245
246
247
248
  /**
   * Notifies the CTA catalogue that the specified tape has been mounted in
   * order to retrieve files.
   *
249
250
251
   * The purpose of this method is to keep track of which drive mounted a given
   * tape for retrieving files last.
   *
252
253
254
255
   * @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)
256
257
258
259
260
261
262
263
264
265

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

  ////////////////////////////////////////////////////////////////
266
  // END OF METHODS DIRECTLY INVOLVED DATA TRANSFER AND SCHEDULING
267
268
  ////////////////////////////////////////////////////////////////

Steven Murray's avatar
Steven Murray committed
269
  virtual void createAdminUser(const common::dataStructures::SecurityIdentity &admin, const std::string &username, const std::string &comment) = 0;
270
  virtual void deleteAdminUser(const std::string &username) = 0;
271
  virtual std::list<common::dataStructures::AdminUser> getAdminUsers() const = 0;
Steven Murray's avatar
Steven Murray committed
272
  virtual void modifyAdminUserComment(const common::dataStructures::SecurityIdentity &admin, const std::string &username, const std::string &comment) = 0;
273

274
275
276
277
278
279
280
  /**
   * Creates the specified Virtual Organization
   * @param admin The administrator.
   * @param vo the Virtual Organization
   */
  virtual void createVirtualOrganization(const common::dataStructures::SecurityIdentity &admin, const common::dataStructures::VirtualOrganization &vo) = 0;
  
281
282
283
284
285
286
  /**
   * Deletes the specified Virtual Organization
   * @param voName the name of the VirtualOrganization to delete
   */
  virtual void deleteVirtualOrganization(const std::string &voName) = 0;
  
287
288
289
290
291
292
  /**
   * Get all the Virtual Organizations from the Catalogue
   * @return the list of all the Virtual Organizations
   */
  virtual std::list<common::dataStructures::VirtualOrganization> getVirtualOrganizations() const = 0;
  
293
294
295
296
297
298
299
300
301
302
303
304
305
306
  /**
   * Get the virtual organization corresponding to the tapepool passed in parameter
   * @param tapepoolName the name of the tapepool which we want the virtual organization
   * @return the VirtualOrganization associated to the tapepool passed in parameter
   */
  virtual common::dataStructures::VirtualOrganization getVirtualOrganizationOfTapepool(const std::string & tapepoolName) const = 0;
  
  /**
   * Get, from the cache, the virtual organization corresponding to the tapepool passed in parameter
   * @param tapepoolName the name of the tapepool which we want the virtual organization
   * @return the VirtualOrganization associated to the tapepool passed in parameter
   */
  virtual common::dataStructures::VirtualOrganization getCachedVirtualOrganizationOfTapepool(const std::string & tapepoolName) const = 0;
  
307
308
309
310
311
312
313
314
  /**
   * Modifies the name of the specified Virtual Organization.
   *
   * @param currentVoName The current name of the Virtual Organization.
   * @param newVoName The new name of the Virtual Organization.
   */
  virtual void modifyVirtualOrganizationName(const common::dataStructures::SecurityIdentity &admin, const std::string &currentVoName, const std::string &newVoName) = 0;
  
315
316
317
318
  /**
   * Modifies the max number of allocated drives for read for the specified Virtual Organization
   * 
   * @param voName the VO name
319
   * @param readMaxDrives the new max number of allocated drives for read for the specified Virtual Organization
320
   */
321
  virtual void modifyVirtualOrganizationReadMaxDrives(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t readMaxDrives) = 0;
322
323
324
325
326
  
  /**
   * Modifies the max number of allocated drives for write for the specified Virtual Organization
   * 
   * @param voName the VO name
327
   * @param writeMaxDrives the new max number of allocated drives for write for the specified Virtual Organization
328
   */
329
  virtual void modifyVirtualOrganizationWriteMaxDrives(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const uint64_t writeMaxDrives) = 0;
330
  
331
332
333
334
335
336
337
  /**
   * Modifies the comment of the specified Virtual Organization
   *
   * @param voName The name of the Virtual Organization.
   * @param comment The new comment of the Virtual Organization.
   */
  virtual void modifyVirtualOrganizationComment(const common::dataStructures::SecurityIdentity &admin, const std::string &voName, const std::string &comment) = 0;
338
339
340
  /**
   * Creates the specified storage class.
   *
Steven Murray's avatar
Steven Murray committed
341
   * @param admin The administrator.
342
343
344
   * @param storageClass The storage class.
   */
  virtual void createStorageClass(
Steven Murray's avatar
Steven Murray committed
345
    const common::dataStructures::SecurityIdentity &admin,
346
347
348
349
350
    const common::dataStructures::StorageClass &storageClass) = 0;

  /**
   * Deletes the specified storage class.
   *
351
   * @param storageClassName The name of the storage class which is only
352
   * guaranteed to be unique within its disk instance.
353
   */
354
  virtual void deleteStorageClass(const std::string &storageClassName) = 0;
355

356
  virtual std::list<common::dataStructures::StorageClass> getStorageClasses() const = 0;
357
358
  virtual void modifyStorageClassNbCopies(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t nbCopies) = 0;
  virtual void modifyStorageClassComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) = 0;
359
  virtual void modifyStorageClassVo(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &vo) = 0;
360

361
362
363
364
365
366
  /**
   * Modifies the name of the specified storage class.
   *
   * @param currentName The current name of the storage class.
   * @param newName The new name of the storage class.
   */
367
  virtual void modifyStorageClassName(const common::dataStructures::SecurityIdentity &admin, const std::string &currentName, const std::string &newName) = 0;
368

369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
  /**
   * Creates a tape media type.
   *
   * @param admin The administrator.
   * @param mediaType The tape media type.
   */
  virtual void createMediaType(const common::dataStructures::SecurityIdentity &admin, const MediaType &mediaType) = 0;

  /**
   * Deletes the specified tape media type.
   *
   * @param name The name of the tape media type.
   */
  virtual void deleteMediaType(const std::string &name) = 0;

  /**
   * Returns all tape media types.
   *
   * @return All tape media types.
   */
  virtual std::list<MediaTypeWithLogs> getMediaTypes() const = 0;
390
391
392
393
394
395
396
397
  
  /**
   * Return the media type associated to the tape corresponding to the
   * vid passed in parameter
   * @param vid the vid of the tape to return its media type
   * @return the media type associated to the tape corresponding to the vid passed in parameter
   */
  virtual MediaType getMediaTypeByVid(const std::string & vid) const = 0;
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479

  /**
   * Modifies the name of the specified tape media type.
   *
   * @param admin The administrator.
   * @param currentName The current name of the tape media type.
   * @param newName The new name of the tape media type.
   */
  virtual void modifyMediaTypeName(const common::dataStructures::SecurityIdentity &admin, const std::string &currentName, const std::string &newName) = 0;

  /**
   * Modifies the cartidge of the specified tape media type.
   *
   * @param admin The administrator.
   * @param name The name of the tape media type.
   * @param cartridge The new cartidge.
   */
  virtual void modifyMediaTypeCartridge(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &cartridge) = 0;

  /**
   * Modify the capacity in bytes of a tape media type.
   *
   * @param admin The administrator.
   * @param name The name of the tape media type.
   * @param capacityInBytes The new capacity in bytes.
   */
  virtual void modifyMediaTypeCapacityInBytes(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t capacityInBytes) = 0;

  /**
   * Modify the SCSI primary density code of a tape media type.
   *
   * @param admin The administrator.
   * @param name The name of the tape media type.
   * @param primaryDensityCode The new SCSI primary density code.
   */
  virtual void modifyMediaTypePrimaryDensityCode(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint8_t primaryDensityCode) = 0;

  /**
   * Modify the SCSI secondary density code of a tape media type.
   *
   * @param admin The administrator.
   * @param name The name of the tape media type.
   * @param secondaryDensityCode The new SCSI secondary density code.
   */
  virtual void modifyMediaTypeSecondaryDensityCode(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint8_t secondaryDensityCode) = 0;

  /**
   * Modify the number of tape wraps of a tape media type.
   *
   * @param admin The administrator.
   * @param name The name of the tape media type.
   * @param nbWraps The new number of tape wraps.
   */
  virtual void modifyMediaTypeNbWraps(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const cta::optional<std::uint32_t> &nbWraps) = 0;

  /**
   * Modify the minimum longitudinal tape position of a tape media type.
   *
   * @param admin The administrator.
   * @param name The name of the tape media type.
   * @param minLPos The new minimum longitudinal tape position.
   */
  virtual void modifyMediaTypeMinLPos(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const cta::optional<std::uint64_t> &minLPos) = 0;

  /**
   * Modify the maximum longitudinal tape position of a tape media type.
   *
   * @param admin The administrator.
   * @param name The name of the tape media type.
   * @param maxLPos The new maximum longitudinal tape position.
   */
  virtual void modifyMediaTypeMaxLPos(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const cta::optional<std::uint64_t> &maxLPos) = 0;

  /**
   * Modify the comment of a tape media type.
   *
   * @param admin The administrator.
   * @param name The name of the tape media type.
   * @param comment The new comment.
   */
  virtual void modifyMediaTypeComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) = 0;

480
  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;
481
482
483
484
485
486
487
488

 /**
  * Deletes the specified tape pool.

  * @name The name of th epatpe pool.
  * @throw UserSpecifiedTapePoolUsedInAnArchiveRoute If the specified tape pool
  *  is used in an archive route.
  */
489
  virtual void deleteTapePool(const std::string &name) = 0;
490

491
  virtual std::list<TapePool> getTapePools() const = 0;
492
493
494
495
496
497
498

  /**
   * @return The tape pool with the specified name.
   * @param tapePoolName The name of the tape pool.
   */
  virtual cta::optional<TapePool> getTapePool(const std::string &tapePoolName) const = 0;

499
  virtual void modifyTapePoolVo(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &vo) = 0;
Steven Murray's avatar
Steven Murray committed
500
501
502
  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;
503
  virtual void modifyTapePoolSupply(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &supply) = 0;
504

505
506
507
508
509
510
511
512
513
  /**
   * Modifies the name of the specified tape pool.
   *
   * @param admin The administrator.
   * @param currentName The current name of the tape pool.
   * @param newName The new name of the tape pool.
   */
  virtual void modifyTapePoolName(const common::dataStructures::SecurityIdentity &admin, const std::string &currentName, const std::string &newName) = 0;

514
  virtual void createArchiveRoute(
Steven Murray's avatar
Steven Murray committed
515
    const common::dataStructures::SecurityIdentity &admin,
516
    const std::string &storageClassName,
517
    const uint32_t copyNb,
518
519
520
521
522
523
    const std::string &tapePoolName,
    const std::string &comment) = 0;

  /**
   * Deletes the specified archive route.
   *
Steven Murray's avatar
Steven Murray committed
524
   * @param storageClassName The name of the storage class.
525
526
527
528
   * @param copyNb The copy number of the tape file.
   */
  virtual void deleteArchiveRoute(
    const std::string &storageClassName,
529
    const uint32_t copyNb) = 0;
530

531
  virtual std::list<common::dataStructures::ArchiveRoute> getArchiveRoutes() const = 0;
532
533
534
535
536
537
538
539
540

  /**
   * @return the archive routes of the given storage class and destination tape
   * pool.
   *
   * Under normal circumstances this method should return either 0 or 1 route.
   * For a given storage class there should be no more than one route to any
   * given tape pool.
   *
Steven Murray's avatar
Steven Murray committed
541
   * @param storageClassName The name of the storage class.
542
543
544
   * @param tapePoolName The name of the tape pool.
   */
  virtual std::list<common::dataStructures::ArchiveRoute> getArchiveRoutes(
545
    const std::string &storageClassName,
546
547
    const std::string &tapePoolName) const = 0;

548
549
550
551
552
553
554
555
556
557
  /**
   * Modifies the tape pool of the specified archive route.
   *
   * @param admin The administrator.
   * @param storageClassName The name of the storage class.
   * @param copyNb The copy number.
   * @param tapePoolName The name of the tape pool.
   * @throw UserSpecifiedANonExistentTapePool if the user specified a
   * non-existent tape pool.
   */
558
  virtual void modifyArchiveRouteTapePoolName(const common::dataStructures::SecurityIdentity &admin, const std::string &storageClassName, const uint32_t copyNb, const std::string &tapePoolName) = 0;
559

560
  virtual void modifyArchiveRouteComment(const common::dataStructures::SecurityIdentity &admin, const std::string &storageClassName, const uint32_t copyNb, const std::string &comment) = 0;
561

562
  virtual void createLogicalLibrary(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const bool isDisabled, const std::string &comment) = 0;
563
  virtual void deleteLogicalLibrary(const std::string &name) = 0;
564
  virtual std::list<common::dataStructures::LogicalLibrary> getLogicalLibraries() const = 0;
565
566
567
568
569
570
571
572
573
574

  /**
   * Modifies the name of the specified logical library.
   *
   * @param admin The administrator.
   * @param currentName The current name of the logical library.
   * @param newName The new name of the logical library.
   */
  virtual void modifyLogicalLibraryName(const common::dataStructures::SecurityIdentity &admin, const std::string &currentName, const std::string &newName) = 0;

Steven Murray's avatar
Steven Murray committed
575
  virtual void modifyLogicalLibraryComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) = 0;
576
  virtual void setLogicalLibraryDisabled(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const bool disabledValue) = 0;
577

578
  /**
579
580
581
582
   * Creates a tape which is assumed to have isFromCastor disabled.
   *
   * @param admin The administrator.
   * @param tape The attributes of the tape to be created.
583
584
585
   */
  virtual void createTape(
    const common::dataStructures::SecurityIdentity &admin,
586
    const CreateTapeAttributes &tape) = 0;
587

588
  virtual void deleteTape(const std::string &vid) = 0;
589
590
591
592
593
594

  /**
   * Returns the list of tapes that meet the specified search criteria.
   *
   * @param searchCriteria The search criteria.
   * @return The list of tapes.
595
596
   * @throw UserSpecifiedANonExistentTapePool if the user specified a
   * non-existent tape pool.
597
598
599
600
   */
  virtual std::list<common::dataStructures::Tape> getTapes(
    const TapeSearchCriteria &searchCriteria = TapeSearchCriteria()) const = 0;

601
602
603
604
605
606
607
608
609
610
611
  /**
   * 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
612
  /**
613
   * Returns map from VID to logical library name for specified set of VIDs.
Steven Murray's avatar
Steven Murray committed
614
   *
615
   * @param vids The tape volume identifiers (VIDs).
616
   * @return map from VID to logical library name.
Steven Murray's avatar
Steven Murray committed
617
   */
618
  virtual std::map<std::string, std::string> getVidToLogicalLibrary(const std::set<std::string> &vids) const = 0;
Steven Murray's avatar
Steven Murray committed
619

620
621
622
623
624
625
626
627
628
629
  /**
   * 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
630
   * @param admin The administrator.
631
   * @param vid The volume identifier of the tape to be reclaimed.
632
   * @param lc the logContext
633
   */
634
  virtual void reclaimTape(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, cta::log::LogContext & lc) = 0;
635
636
637
638
639
640
641
642
643
644
645
646
647
  
  /**
   * Checks the specified tape for the tape label command.
   *
   * This method checks if the tape is safe to be labeled and will throw an 
   * exception if the specified tape does not ready to be labeled.
   *
   * @param vid The volume identifier of the tape to be checked.
   */
  virtual void checkTapeForLabel(const std::string &vid) = 0;
  
  /**
   * Returns the number of any files contained in the tape identified by its vid
648
   * @param vid the vid in which we will the number of files
649
650
651
   * @return the number of files on the tape
   */
  virtual uint64_t getNbFilesOnTape(const std::string &vid) const = 0 ;
652

653
654
  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
655
656
  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;
657
  virtual void modifyTapeEncryptionKeyName(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string &encryptionKeyName) = 0;
658
659
  /**
   * Modify the state of the specified tape
660
   * @param admin, the person or the system who modified the state of the tape
661
662
663
664
   * @param vid the VID of the tape to change the state
   * @param state the new state
   * @param stateReason the reason why the state changes, if the state is ACTIVE and the stateReason is nullopt, the state will be reset to null
   */
665
  virtual void modifyTapeState(const common::dataStructures::SecurityIdentity &admin,const std::string &vid, const common::dataStructures::Tape::State & state, const cta::optional<std::string> & stateReason) = 0;
666
667
668
669
670
671
  /**
   * 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
672
   * @param admin The administrator.
673
674
675
   * @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
676
  virtual void setTapeFull(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const bool fullValue) = 0;
677
  
678
679
680
681
682
683
684
  /**
   * This method notifies the CTA catalogue to set the specified tape is from CASTOR.
   * This method only for unitTests and MUST never be called in CTA!!! 
   *
   * @param vid The volume identifier of the tape.
   */
  virtual void setTapeIsFromCastorInUnitTests(const std::string &vid) = 0;
685

686
  virtual void setTapeDisabled(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const std::string & reason) = 0;
687
688
689
  
  virtual void setTapeDirty(const std::string & vid) = 0;
  
690
691
692
693
694
695
696
697
  /**
   * Modifies the tape comment
   * If the comment == cta::nullopt, it will delete the comment from the tape table
   * @param admin the admin who removes the comment
   * @param vid the vid of the tape to remove the comment
   * @param comment the new comment. If comment == cta::nullopt, the comment will be deleted.
   */
  virtual void modifyTapeComment(const common::dataStructures::SecurityIdentity &admin, const std::string &vid, const cta::optional<std::string> &comment) = 0;
698

Steven Murray's avatar
Steven Murray committed
699
700
701
702
  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;
703

704
   virtual void createMountPolicy(const common::dataStructures::SecurityIdentity &admin, const CreateMountPolicyAttributes & mountPolicy) = 0;
705

706
  /**
707
   * Returns the list of all existing mount policies.
708
   *
709
710
711
   * @return the list of all existing mount policies.
   */
  virtual std::list<common::dataStructures::MountPolicy> getMountPolicies() const = 0;
712
713
714
715
716
717
718
  
  /**
   * Returns the cached list of all existing mount policies.
   *
   * @return the list of all existing mount policies.
   */
  virtual std::list<common::dataStructures::MountPolicy> getCachedMountPolicies() const = 0;
719
720
721
722
723
724
725
726
727
728
729
730
731
732

  /**
   * 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.
733
   *
Steven Murray's avatar
Steven Murray committed
734
   * @param admin The administrator.
735
   * @param mountPolicyName The name of the mount policy.
736
737
738
739
   * @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.
740
741
   * @param comment Comment.
   */
742
  virtual void createRequesterMountRule(
Steven Murray's avatar
Steven Murray committed
743
    const common::dataStructures::SecurityIdentity &admin,
744
    const std::string &mountPolicyName,
745
    const std::string &diskInstance,
746
747
748
749
    const std::string &requesterName,
    const std::string &comment) = 0;

  /**
750
751
752
753
754
755
756
757
758
759
760
   * 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.
   *
761
762
763
764
   * @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.
765
   */
766
  virtual void deleteRequesterMountRule(const std::string &diskInstanceName, const std::string &requesterName) = 0;
767

768
  /**   
769
770
   * Creates the rule that the specified mount policy will be used for the
   * specified requester group.
771
   *
772
773
   * Please note that requester mount-rules overrule requester-group
   * mount-rules.
774
   *
Steven Murray's avatar
Steven Murray committed
775
   * @param admin The administrator.
776
   * @param mountPolicyName The name of the mount policy.
777
778
779
780
   * @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.
781
   * @param comment Comment.
782
   */
783
  virtual void createRequesterGroupMountRule(
Steven Murray's avatar
Steven Murray committed
784
    const common::dataStructures::SecurityIdentity &admin,
785
    const std::string &mountPolicyName,
786
    const std::string &diskInstanceName,
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
    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.
   *
802
803
804
805
   * @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.
806
   */
807
808
809
  virtual void deleteRequesterGroupMountRule(
    const std::string &diskInstanceName,
    const std::string &requesterGroupName) = 0;
810

Steven Murray's avatar
Steven Murray committed
811
812
813
814
815
  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 modifyMountPolicyComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) = 0;
816

817
818
819
820
821
822
823
  virtual void createActivitiesFairShareWeight(const common::dataStructures::SecurityIdentity &admin, const std::string & diskInstanceName, const std::string & acttivity,
    double weight, const std::string & comment) = 0;
  virtual void modifyActivitiesFairShareWeight(const common::dataStructures::SecurityIdentity &admin, const std::string & diskInstanceName, const std::string & acttivity,
    double weight, const std::string & comment) = 0;
  virtual void deleteActivitiesFairShareWeight(const common::dataStructures::SecurityIdentity &admin, const std::string & diskInstanceName, const std::string & acttivity) = 0;
  virtual std::list<common::dataStructures::ActivitiesFairShareWeights> getActivitiesFairShareWeights() const = 0;
  
824
825
826
827
828
829
  /**
   * Returns all the disk systems within the CTA catalogue.
   *
   * @return The disk systems.
   * requester group.
   */
830
  virtual disk::DiskSystemList getAllDiskSystems() const = 0;
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
  
  /**
   * Creates a disk system.
   * 
   * @param admin The administrator.
   * @param name The name of the disk system.
   * @param fileRegexp The regular expression allowing matching destination URLs
   * for this disk system.
   * @param freeSpaceQueryURL The query URL that describes a method to query the
   * free space from the disk system.
   * @param refreshInterval The refresh interval (seconds) defining how long do 
   * we use a free space value.
   * @param targetedFreeSpace The targeted free space (margin) based on the free
   * space update latency (inherent to the file system and induced by the refresh 
   * interval), and the expected external bandwidth from sources external to CTA.
   * @param comment Comment.
   */
  virtual void createDiskSystem(
    const common::dataStructures::SecurityIdentity &admin,
    const std::string &name,
    const std::string &fileRegexp,
    const std::string &freeSpaceQueryURL,
    const uint64_t refreshInterval,
    const uint64_t targetedFreeSpace,
855
    const uint64_t sleepTime,
856
857
858
859
860
861
862
    const std::string &comment) = 0;
  
  /**
   * Deletes a disk system.
   * 
   * @param name The name of the disk system.
   */
863
  virtual void deleteDiskSystem(const std::string &name) = 0;
864
  
865
866
867
868
869
870
871
872
  virtual void modifyDiskSystemFileRegexp(const common::dataStructures::SecurityIdentity &admin,
    const std::string &name, const std::string &fileRegexp) = 0;
  virtual void modifyDiskSystemFreeSpaceQueryURL(const common::dataStructures::SecurityIdentity &admin,
    const std::string &name, const std::string &freeSpaceQueryURL) = 0;
  virtual void modifyDiskSystemRefreshInterval(const common::dataStructures::SecurityIdentity &admin,
    const std::string &name, const uint64_t refreshInterval) = 0;
  virtual void modifyDiskSystemTargetedFreeSpace(const common::dataStructures::SecurityIdentity &admin,
    const std::string &name, const uint64_t targetedFreeSpace) = 0;
873
874
  virtual void modifyDiskSystemSleepTime(const common::dataStructures::SecurityIdentity &admin,
    const std::string &name, const uint64_t sleepTime) = 0;
875
876
  virtual void modifyDiskSystemComment(const common::dataStructures::SecurityIdentity &admin,
    const std::string &name, const std::string &comment) = 0;
877
878

  typedef CatalogueItor<common::dataStructures::ArchiveFile> ArchiveFileItor;
879
      
880
  /**
881
882
   * Returns the specified archive files.  Please note that the list of files
   * is ordered by archive file ID.
883
884
   *
   * @param searchCriteria The search criteria.
885
   * @return The archive files.
886
   */
887
  virtual ArchiveFileItor getArchiveFilesItor(
888
    const TapeFileSearchCriteria &searchCriteria = TapeFileSearchCriteria()) const = 0;
889

890
891
892
893
894
895
896
897
  
  typedef CatalogueItor<common::dataStructures::FileRecycleLog> FileRecycleLogItor;
  
  /**
   * Returns all the currently deleted files by looking at the FILE_RECYCLE_LOG table
   *
   * @return The deleted archive files ordered by archive file ID.
   */
898
  virtual FileRecycleLogItor getFileRecycleLogItor(const RecycleTapeFileSearchCriteria & searchCriteria = RecycleTapeFileSearchCriteria()) const = 0;
899

900
  /**
901
   * Returns the specified files in tape file sequence order.
902
903
904
905
906
   *
   * @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.
907
   * @return The specified files in tape file sequence order.
908
   */
909
  virtual std::list<common::dataStructures::ArchiveFile> getFilesForRepack(
910
911
912
913
    const std::string &vid,
    const uint64_t startFSeq,
    const uint64_t maxNbFiles) const = 0;

914
915
916
917
918
919
920
921
922
923
924
925
926
927
  /**
   * 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;

928
  /**
929
   * Returns a summary of the tape files that meet the specified search
930
931
932
933
934
   * criteria.
   *
   * @param searchCriteria The search criteria.
   * @return The summary.
   */
935
  virtual common::dataStructures::ArchiveFileSummary getTapeFileSummary(
936
    const TapeFileSearchCriteria &searchCriteria = TapeFileSearchCriteria()) const = 0;
937
938
939
940
941
942
943

  /**
   * 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.
   *
944
945
946
   * Please note that an archive file with no associated tape files is
   * considered not to exist by this method.
   *
947
948
949
   * @param id The unique identifier of the archive file.
   * @return The archive file.
   */
950
  virtual common::dataStructures::ArchiveFile getArchiveFileById(const uint64_t id) const = 0;
951

952
  /**
953
   * !!!!!!!!!!!!!!!!!!! THIS METHOD SHOULD NOT BE USED !!!!!!!!!!!!!!!!!!!!!!!
954
955
956
   * Deletes the specified archive file and its associated tape copies from the
   * catalogue.
   *
957
958
959
960
   * 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.
   *
961
962
963
   * 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.
   *
964
965
   * @param instanceName The name of the instance from where the deletion request
   * originated
966
   * @param archiveFileId The unique identifier of the archive file.
967
   * @param lc The log context.
968
969
970
   * @return The metadata of the deleted archive file including the metadata of
   * the associated and also deleted tape copies.
   */
971
  virtual void DO_NOT_USE_deleteArchiveFile_DO_NOT_USE(const std::string &instanceName, const uint64_t archiveFileId,
972
    log::LogContext &lc) = 0;
973

974
975
976
977
  /**
   * 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
978
   * @param admin The administrator.
979
980
981
   * @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
982
  virtual bool isAdmin(const common::dataStructures::SecurityIdentity &admin) const = 0;
983

984
  /**
985
   * Checks that the most trivial query goes through. Throws an exception if not.
986
   */
987
  virtual void ping() = 0;
988
  
989
990
991
992
993
  /**
   * Checks that the online database schema MAJOR version number matches the schema MAJOR version number defined in version.h
   */
  virtual void verifySchemaVersion() = 0;
  
994
  /**
995
996
997
998
999
   * Returns the SchemaVersion object corresponding to the catalogue schema version:
   * - SCHEMA_VERSION_MAJOR
   * - SCHEMA_VERSION_MINOR
   * - SCHEMA_VERSION_MAJOR_NEXT (future major version number of the schema in case of upgrade)
   * - SCHEMA_VERSION_MINOR_NEXT (future minor version number of the schema in case of upgrade)
1000
   * - STATUS (UPGRADING or PRODUCTION)	
1001
   * 
1002
   * @return The SchemaVersion object corresponding to the catalogue schema version
1003
   */
1004
  virtual SchemaVersion getSchemaVersion() const = 0;
1005

1006
1007
1008
1009
1010
1011
1012
1013
  /**
   * 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;

1014
1015
1016
1017
1018
1019
1020
  /**
   * 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;
1021
1022
1023
1024
1025
1026
1027
1028
  
  /**
   * Returns true if the specified disk system exists.
   *
   * @param name The name identifier of the disk system.
   * @return True if the tape exists.
   */
  virtual bool diskSystemExists(const std::string &name) const = 0;  
1029

1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
  /**
   * Updates the disk file ID of the specified archive file.
   *
   * @param archiveFileId The unique identifier of the archive file.
   * @param diskInstance The instance name of the source disk system.
   * @param diskFileId The identifier of the source disk file which is unique
   * within it's host disk system.  Two files from different disk systems may
   * have the same identifier.  The combination of diskInstance and diskFileId
   * must be globally unique, in other words unique within the CTA catalogue.
   */
  virtual void updateDiskFileId(uint64_t archiveFileId, const std::string &diskInstance,
    const std::string &diskFileId) = 0;
1042
1043
  
  /**
1044
1045
1046
   * Insert the ArchiveFile and all its tape files in the FILE_RECYCLE_LOG table.
   * There will be one entry on the FILE_RECYCLE_LOG table per deleted tape file
   * 
1047
1048
1049
   * @param request the DeleteRequest object that holds information about the file to delete.
   * @param lc the logContext
   */
1050
  virtual void moveArchiveFileToRecycleLog(const common::dataStructures::DeleteArchiveRequest &request, 
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
  log::LogContext & lc) = 0;
  
   /**
   *
   * Deletes the specified archive file and its associated tape copies from the
   * recycle-bin
   *
   * 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.
   *
   * @param archiveFileId The unique identifier of the archive file.
   * @param lc The log context.
   */
  virtual void deleteFileFromRecycleBin(const uint64_t archiveFileId, log::LogContext &lc) = 0;
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
  
  /**
   * Deletes all the log entries corresponding to the vid passed in parameter.
   * 
   * Please note that this method is idempotent.  If there are no recycle log
   * entries associated to the vid passed in parameter, the method will return
   * without any error.
   * 
   * @param vid, the vid of the files to be deleted
   * @param lc, the logContext
   */
  virtual void deleteFilesFromRecycleLog(const std::string & vid, log::LogContext & lc) = 0;
1077

1078
1079
}; // class Catalogue

1080
} // namespace catalogue
1081
} // namespace cta