diff --git a/catalogue/1.1/mysql_catalogue_schema.sql b/catalogue/1.1/mysql_catalogue_schema.sql index 999a0ab16d3aee5e2f803eec25ebb0a67a4a55ec..7ac473a4345afb98d7e81a75439720c8ebcab9c4 100644 --- a/catalogue/1.1/mysql_catalogue_schema.sql +++ b/catalogue/1.1/mysql_catalogue_schema.sql @@ -66,7 +66,7 @@ CREATE TABLE STORAGE_CLASS( LAST_UPDATE_HOST_NAME VARCHAR(100) CONSTRAINT STORAGE_CLASS_LUHN_NN NOT NULL, LAST_UPDATE_TIME BIGINT UNSIGNED CONSTRAINT STORAGE_CLASS_LUT_NN NOT NULL, CONSTRAINT STORAGE_CLASS_PK PRIMARY KEY(STORAGE_CLASS_ID), - CONSTRAINT STORAGE_CLASS_DIN_SCN_UN UNIQUE(DISK_INSTANCE_NAME, STORAGE_CLASS_NAME) + CONSTRAINT STORAGE_CLASS_SCN_UN UNIQUE(STORAGE_CLASS_NAME) ); CREATE TABLE TAPE_POOL( TAPE_POOL_ID BIGINT UNSIGNED CONSTRAINT TAPE_POOL_TPI_NN NOT NULL, diff --git a/catalogue/1.1/oracle_catalogue_schema.sql b/catalogue/1.1/oracle_catalogue_schema.sql index 5d1c171dbc5d4f9d1d72904edab847bce8d8a177..a19d3db8e13ddfa424f1b77b2bcd2740beef1f71 100644 --- a/catalogue/1.1/oracle_catalogue_schema.sql +++ b/catalogue/1.1/oracle_catalogue_schema.sql @@ -88,7 +88,7 @@ CREATE TABLE STORAGE_CLASS( LAST_UPDATE_HOST_NAME VARCHAR2(100) CONSTRAINT STORAGE_CLASS_LUHN_NN NOT NULL, LAST_UPDATE_TIME NUMERIC(20, 0) CONSTRAINT STORAGE_CLASS_LUT_NN NOT NULL, CONSTRAINT STORAGE_CLASS_PK PRIMARY KEY(STORAGE_CLASS_ID), - CONSTRAINT STORAGE_CLASS_DIN_SCN_UN UNIQUE(DISK_INSTANCE_NAME, STORAGE_CLASS_NAME) + CONSTRAINT STORAGE_CLASS_SCN_UN UNIQUE(STORAGE_CLASS_NAME) ); CREATE TABLE TAPE_POOL( TAPE_POOL_ID NUMERIC(20, 0) CONSTRAINT TAPE_POOL_TPI_NN NOT NULL, diff --git a/catalogue/1.1/postgres_catalogue_schema.sql b/catalogue/1.1/postgres_catalogue_schema.sql index c94158c7e3dfc761bb5da44537741cc30719d378..9ac1f6d668db8ccd611ca8d8dc5fe8546d9085fc 100644 --- a/catalogue/1.1/postgres_catalogue_schema.sql +++ b/catalogue/1.1/postgres_catalogue_schema.sql @@ -73,7 +73,7 @@ CREATE TABLE STORAGE_CLASS( LAST_UPDATE_HOST_NAME VARCHAR(100) CONSTRAINT STORAGE_CLASS_LUHN_NN NOT NULL, LAST_UPDATE_TIME NUMERIC(20, 0) CONSTRAINT STORAGE_CLASS_LUT_NN NOT NULL, CONSTRAINT STORAGE_CLASS_PK PRIMARY KEY(STORAGE_CLASS_ID), - CONSTRAINT STORAGE_CLASS_DIN_SCN_UN UNIQUE(DISK_INSTANCE_NAME, STORAGE_CLASS_NAME) + CONSTRAINT STORAGE_CLASS_SCN_UN UNIQUE(STORAGE_CLASS_NAME) ); CREATE TABLE TAPE_POOL( TAPE_POOL_ID NUMERIC(20, 0) CONSTRAINT TAPE_POOL_TPI_NN NOT NULL, diff --git a/catalogue/1.1/sqlite_catalogue_schema.sql b/catalogue/1.1/sqlite_catalogue_schema.sql index bf495f31a6f7849eada7e0aa39e5a54ac8b27823..e8d862a971a0e128c29718ac901b4b0311d79279 100644 --- a/catalogue/1.1/sqlite_catalogue_schema.sql +++ b/catalogue/1.1/sqlite_catalogue_schema.sql @@ -57,7 +57,7 @@ CREATE TABLE STORAGE_CLASS( LAST_UPDATE_HOST_NAME VARCHAR(100) CONSTRAINT STORAGE_CLASS_LUHN_NN NOT NULL, LAST_UPDATE_TIME INTEGER CONSTRAINT STORAGE_CLASS_LUT_NN NOT NULL, CONSTRAINT STORAGE_CLASS_PK PRIMARY KEY(STORAGE_CLASS_ID), - CONSTRAINT STORAGE_CLASS_DIN_SCN_UN UNIQUE(DISK_INSTANCE_NAME, STORAGE_CLASS_NAME) + CONSTRAINT STORAGE_CLASS_SCN_UN UNIQUE(STORAGE_CLASS_NAME) ); CREATE TABLE TAPE_POOL( TAPE_POOL_ID INTEGER CONSTRAINT TAPE_POOL_TPI_NN NOT NULL, diff --git a/catalogue/AllCatalogueSchema.hpp b/catalogue/AllCatalogueSchema.hpp index 6dc2238148c713f4c6f39c423cadb3d80cab8424..c62a9c8063f6e6ac811351459982decc732c5eaf 100644 --- a/catalogue/AllCatalogueSchema.hpp +++ b/catalogue/AllCatalogueSchema.hpp @@ -1314,7 +1314,7 @@ namespace catalogue{ " LAST_UPDATE_HOST_NAME VARCHAR2(100) CONSTRAINT STORAGE_CLASS_LUHN_NN NOT NULL," " LAST_UPDATE_TIME NUMERIC(20, 0) CONSTRAINT STORAGE_CLASS_LUT_NN NOT NULL," " CONSTRAINT STORAGE_CLASS_PK PRIMARY KEY(STORAGE_CLASS_ID)," - " CONSTRAINT STORAGE_CLASS_DIN_SCN_UN UNIQUE(DISK_INSTANCE_NAME, STORAGE_CLASS_NAME)" + " CONSTRAINT STORAGE_CLASS_SCN_UN UNIQUE(STORAGE_CLASS_NAME)" ");" "CREATE TABLE TAPE_POOL(" " TAPE_POOL_ID NUMERIC(20, 0) CONSTRAINT TAPE_POOL_TPI_NN NOT NULL," @@ -1619,7 +1619,7 @@ namespace catalogue{ " LAST_UPDATE_HOST_NAME VARCHAR(100) CONSTRAINT STORAGE_CLASS_LUHN_NN NOT NULL," " LAST_UPDATE_TIME BIGINT UNSIGNED CONSTRAINT STORAGE_CLASS_LUT_NN NOT NULL," " CONSTRAINT STORAGE_CLASS_PK PRIMARY KEY(STORAGE_CLASS_ID)," - " CONSTRAINT STORAGE_CLASS_DIN_SCN_UN UNIQUE(DISK_INSTANCE_NAME, STORAGE_CLASS_NAME)" + " CONSTRAINT STORAGE_CLASS_SCN_UN UNIQUE(STORAGE_CLASS_NAME)" ");" "CREATE TABLE TAPE_POOL(" " TAPE_POOL_ID BIGINT UNSIGNED CONSTRAINT TAPE_POOL_TPI_NN NOT NULL," @@ -1914,7 +1914,7 @@ namespace catalogue{ " LAST_UPDATE_HOST_NAME VARCHAR(100) CONSTRAINT STORAGE_CLASS_LUHN_NN NOT NULL," " LAST_UPDATE_TIME INTEGER CONSTRAINT STORAGE_CLASS_LUT_NN NOT NULL," " CONSTRAINT STORAGE_CLASS_PK PRIMARY KEY(STORAGE_CLASS_ID)," - " CONSTRAINT STORAGE_CLASS_DIN_SCN_UN UNIQUE(DISK_INSTANCE_NAME, STORAGE_CLASS_NAME)" + " CONSTRAINT STORAGE_CLASS_SCN_UN UNIQUE(STORAGE_CLASS_NAME)" ");" "CREATE TABLE TAPE_POOL(" " TAPE_POOL_ID INTEGER CONSTRAINT TAPE_POOL_TPI_NN NOT NULL," @@ -2223,7 +2223,7 @@ namespace catalogue{ " LAST_UPDATE_HOST_NAME VARCHAR(100) CONSTRAINT STORAGE_CLASS_LUHN_NN NOT NULL," " LAST_UPDATE_TIME NUMERIC(20, 0) CONSTRAINT STORAGE_CLASS_LUT_NN NOT NULL," " CONSTRAINT STORAGE_CLASS_PK PRIMARY KEY(STORAGE_CLASS_ID)," - " CONSTRAINT STORAGE_CLASS_DIN_SCN_UN UNIQUE(DISK_INSTANCE_NAME, STORAGE_CLASS_NAME)" + " CONSTRAINT STORAGE_CLASS_SCN_UN UNIQUE(STORAGE_CLASS_NAME)" ");" "CREATE TABLE TAPE_POOL(" " TAPE_POOL_ID NUMERIC(20, 0) CONSTRAINT TAPE_POOL_TPI_NN NOT NULL," diff --git a/catalogue/Catalogue.hpp b/catalogue/Catalogue.hpp index 5b21f89d0a483bc88088cc578e01c2a319b8e746..b76a9d0abd3d17f9f62965b024f059fa84f0fda4 100644 --- a/catalogue/Catalogue.hpp +++ b/catalogue/Catalogue.hpp @@ -238,26 +238,22 @@ public: /** * 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 + * @param storageClassName 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; + virtual void deleteStorageClass(const std::string &storageClassName) = 0; virtual std::list<common::dataStructures::StorageClass> getStorageClasses() const = 0; - 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; + 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; /** * Modifies the name of the specified storage class. * - * @param diskInstanceName The name of the disk instance to which the - * storage class belongs. * @param currentName The current name of the storage class. * @param newName The new name of the storage class. */ - virtual void modifyStorageClassName(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string ¤tName, const std::string &newName) = 0; + virtual void modifyStorageClassName(const common::dataStructures::SecurityIdentity &admin, const std::string ¤tName, const std::string &newName) = 0; 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; virtual void deleteTapePool(const std::string &name) = 0; @@ -279,7 +275,6 @@ public: virtual void createArchiveRoute( const common::dataStructures::SecurityIdentity &admin, - const std::string &diskInstanceName, const std::string &storageClassName, const uint32_t copyNb, const std::string &tapePoolName, @@ -288,14 +283,10 @@ public: /** * 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 storageClassName The name of the storage class which is unique * @param copyNb The copy number of the tape file. */ virtual void deleteArchiveRoute( - const std::string &diskInstanceName, const std::string &storageClassName, const uint32_t copyNb) = 0; @@ -309,18 +300,15 @@ public: * For a given storage class there should be no more than one route to any * given tape pool. * - * @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 storageClassName The name of the storage class which is unique * @param tapePoolName The name of the tape pool. */ virtual std::list<common::dataStructures::ArchiveRoute> getArchiveRoutes( - const std::string &diskInstanceName, const std::string &storageClassName, + const std::string &storageClassName, const std::string &tapePoolName) const = 0; - 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; + virtual void modifyArchiveRouteTapePoolName(const common::dataStructures::SecurityIdentity &admin, const std::string &storageClassName, const uint32_t copyNb, const std::string &tapePoolName) = 0; + virtual void modifyArchiveRouteComment(const common::dataStructures::SecurityIdentity &admin, const std::string &storageClassName, const uint32_t copyNb, const std::string &comment) = 0; virtual void createLogicalLibrary(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const bool isDisabled, const std::string &comment) = 0; virtual void deleteLogicalLibrary(const std::string &name) = 0; diff --git a/catalogue/CatalogueRetryWrapper.hpp b/catalogue/CatalogueRetryWrapper.hpp index 86635925f30deeb8d39fb41decf15e33f2dad4bf..57d023c857fa2ef0f8192b0fc9bdbdbfb9049dd9 100644 --- a/catalogue/CatalogueRetryWrapper.hpp +++ b/catalogue/CatalogueRetryWrapper.hpp @@ -120,24 +120,24 @@ public: return retryOnLostConnection(m_log, [&]{return m_catalogue->createStorageClass(admin, storageClass);}, m_maxTriesToConnect); } - void deleteStorageClass(const std::string &diskInstanceName, const std::string &storageClassName) override { - return retryOnLostConnection(m_log, [&]{return m_catalogue->deleteStorageClass(diskInstanceName, storageClassName);}, m_maxTriesToConnect); + void deleteStorageClass(const std::string &storageClassName) override { + return retryOnLostConnection(m_log, [&]{return m_catalogue->deleteStorageClass(storageClassName);}, m_maxTriesToConnect); } std::list<common::dataStructures::StorageClass> getStorageClasses() const override { return retryOnLostConnection(m_log, [&]{return m_catalogue->getStorageClasses();}, m_maxTriesToConnect); } - void modifyStorageClassNbCopies(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &name, const uint64_t nbCopies) override { - return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyStorageClassNbCopies(admin, instanceName, name, nbCopies);}, m_maxTriesToConnect); + void modifyStorageClassNbCopies(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t nbCopies) override { + return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyStorageClassNbCopies(admin, name, nbCopies);}, m_maxTriesToConnect); } - void modifyStorageClassComment(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &name, const std::string &comment) override { - return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyStorageClassComment(admin, instanceName, name, comment);}, m_maxTriesToConnect); + void modifyStorageClassComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) override { + return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyStorageClassComment(admin, name, comment);}, m_maxTriesToConnect); } - void modifyStorageClassName(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string ¤tName, const std::string &newName) override { - return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyStorageClassName(admin, instanceName, currentName, newName);}, m_maxTriesToConnect); + void modifyStorageClassName(const common::dataStructures::SecurityIdentity &admin, const std::string ¤tName, const std::string &newName) override { + return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyStorageClassName(admin, currentName, newName);}, m_maxTriesToConnect); } 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) override { @@ -176,28 +176,28 @@ public: return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyTapePoolName(admin, currentName, newName);}, m_maxTriesToConnect); } - void createArchiveRoute(const common::dataStructures::SecurityIdentity &admin, const std::string &diskInstanceName, const std::string &storageClassName, const uint32_t copyNb, const std::string &tapePoolName, const std::string &comment) override { - return retryOnLostConnection(m_log, [&]{return m_catalogue->createArchiveRoute(admin, diskInstanceName, storageClassName, copyNb, tapePoolName, comment);}, m_maxTriesToConnect); + void createArchiveRoute(const common::dataStructures::SecurityIdentity &admin, const std::string &storageClassName, const uint32_t copyNb, const std::string &tapePoolName, const std::string &comment) override { + return retryOnLostConnection(m_log, [&]{return m_catalogue->createArchiveRoute(admin, storageClassName, copyNb, tapePoolName, comment);}, m_maxTriesToConnect); } - void deleteArchiveRoute(const std::string &diskInstanceName, const std::string &storageClassName, const uint32_t copyNb) override { - return retryOnLostConnection(m_log, [&]{return m_catalogue->deleteArchiveRoute(diskInstanceName, storageClassName, copyNb);}, m_maxTriesToConnect); + void deleteArchiveRoute(const std::string &storageClassName, const uint32_t copyNb) override { + return retryOnLostConnection(m_log, [&]{return m_catalogue->deleteArchiveRoute(storageClassName, copyNb);}, m_maxTriesToConnect); } std::list<common::dataStructures::ArchiveRoute> getArchiveRoutes() const override { return retryOnLostConnection(m_log, [&]{return m_catalogue->getArchiveRoutes();}, m_maxTriesToConnect); } - std::list<common::dataStructures::ArchiveRoute> getArchiveRoutes(const std::string &diskInstanceName, const std::string &storageClassName, const std::string &tapePoolName) const override { - return retryOnLostConnection(m_log, [&]{return m_catalogue->getArchiveRoutes(diskInstanceName, storageClassName, tapePoolName);}, m_maxTriesToConnect); + std::list<common::dataStructures::ArchiveRoute> getArchiveRoutes(const std::string &storageClassName, const std::string &tapePoolName) const override { + return retryOnLostConnection(m_log, [&]{return m_catalogue->getArchiveRoutes(storageClassName, tapePoolName);}, m_maxTriesToConnect); } - void modifyArchiveRouteTapePoolName(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &storageClassName, const uint32_t copyNb, const std::string &tapePoolName) override { - return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyArchiveRouteTapePoolName(admin, instanceName, storageClassName, copyNb, tapePoolName);}, m_maxTriesToConnect); + void modifyArchiveRouteTapePoolName(const common::dataStructures::SecurityIdentity &admin, const std::string &storageClassName, const uint32_t copyNb, const std::string &tapePoolName) override { + return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyArchiveRouteTapePoolName(admin, storageClassName, copyNb, tapePoolName);}, m_maxTriesToConnect); } - void modifyArchiveRouteComment(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &storageClassName, const uint32_t copyNb, const std::string &comment) override { - return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyArchiveRouteComment(admin, instanceName, storageClassName, copyNb, comment);}, m_maxTriesToConnect); + void modifyArchiveRouteComment(const common::dataStructures::SecurityIdentity &admin, const std::string &storageClassName, const uint32_t copyNb, const std::string &comment) override { + return retryOnLostConnection(m_log, [&]{return m_catalogue->modifyArchiveRouteComment(admin, storageClassName, copyNb, comment);}, m_maxTriesToConnect); } void createLogicalLibrary(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const bool isDisabled, const std::string &comment) override { diff --git a/catalogue/CatalogueTest.cpp b/catalogue/CatalogueTest.cpp index f60d5055d4d531918343944196666a8e9e07c81f..9ae8ead02c7f3a6864b0542101530a2b2302a582 100644 --- a/catalogue/CatalogueTest.cpp +++ b/catalogue/CatalogueTest.cpp @@ -112,7 +112,7 @@ void cta_catalogue_CatalogueTest::SetUp() { { const std::list<common::dataStructures::ArchiveRoute> archiveRoutes = m_catalogue->getArchiveRoutes(); for(auto &archiveRoute: archiveRoutes) { - m_catalogue->deleteArchiveRoute(archiveRoute.diskInstanceName, archiveRoute.storageClassName, + m_catalogue->deleteArchiveRoute(archiveRoute.storageClassName, archiveRoute.copyNb); } } @@ -153,7 +153,7 @@ void cta_catalogue_CatalogueTest::SetUp() { { const std::list<common::dataStructures::StorageClass> storageClasses = m_catalogue->getStorageClasses(); for(auto &storageClass: storageClasses) { - m_catalogue->deleteStorageClass(storageClass.diskInstance, storageClass.name); + m_catalogue->deleteStorageClass(storageClass.name); } } { @@ -609,42 +609,6 @@ TEST_P(cta_catalogue_CatalogueTest, createStorageClass_emptyStringComment) { catalogue::UserSpecifiedAnEmptyStringComment); } -TEST_P(cta_catalogue_CatalogueTest, createStorageClass_same_name_different_disk_instance) { - using namespace cta; - - common::dataStructures::StorageClass storageClass1; - storageClass1.diskInstance = "disk_instance_1"; - storageClass1.name = "storage_class"; - storageClass1.nbCopies = 2; - storageClass1.comment = "Create storage class"; - - common::dataStructures::StorageClass storageClass2 = storageClass1; - storageClass2.diskInstance = "disk_instance_2"; - - m_catalogue->createStorageClass(m_admin, storageClass1); - m_catalogue->createStorageClass(m_admin, storageClass2); - - const std::list<common::dataStructures::StorageClass> storageClasses = m_catalogue->getStorageClasses(); - - ASSERT_EQ(2, storageClasses.size()); - - { - auto eqStorageClass1 = [&storageClass1](const common::dataStructures::StorageClass &obj) { - return obj.diskInstance == storageClass1.diskInstance && obj.name == storageClass1.name; - }; - auto itor = std::find_if(storageClasses.begin(), storageClasses.end(), eqStorageClass1); - ASSERT_FALSE(itor == storageClasses.end()); - } - - { - auto eqStorageClass2 = [&storageClass2](const common::dataStructures::StorageClass &obj) { - return obj.diskInstance == storageClass2.diskInstance && obj.name == storageClass2.name; - }; - auto itor = std::find_if(storageClasses.begin(), storageClasses.end(), eqStorageClass2); - ASSERT_FALSE(itor == storageClasses.end()); - } -} - TEST_P(cta_catalogue_CatalogueTest, deleteStorageClass) { using namespace cta; @@ -674,7 +638,7 @@ TEST_P(cta_catalogue_CatalogueTest, deleteStorageClass) { const common::dataStructures::EntryLog lastModificationLog = storageClasses.front().lastModificationLog; ASSERT_EQ(creationLog, lastModificationLog); - m_catalogue->deleteStorageClass(storageClass.diskInstance, storageClass.name); + m_catalogue->deleteStorageClass(storageClass.name); ASSERT_TRUE(m_catalogue->getStorageClasses().empty()); } @@ -682,7 +646,7 @@ TEST_P(cta_catalogue_CatalogueTest, deleteStorageClass_non_existent) { using namespace cta; ASSERT_TRUE(m_catalogue->getStorageClasses().empty()); - ASSERT_THROW(m_catalogue->deleteStorageClass("non_existent_disk_instance", "non_existent_storage_class"), + ASSERT_THROW(m_catalogue->deleteStorageClass("non_existent_storage_class"), exception::UserError); } @@ -717,7 +681,7 @@ TEST_P(cta_catalogue_CatalogueTest, modifyStorageClassNbCopies) { } const uint64_t modifiedNbCopies = 5; - m_catalogue->modifyStorageClassNbCopies(m_admin, storageClass.diskInstance, storageClass.name, modifiedNbCopies); + m_catalogue->modifyStorageClassNbCopies(m_admin, storageClass.name, modifiedNbCopies); { const std::list<common::dataStructures::StorageClass> storageClasses = m_catalogue->getStorageClasses(); @@ -743,7 +707,7 @@ TEST_P(cta_catalogue_CatalogueTest, modifyStorageClassNbCopies_nonExistentStorag const std::string diskInstance = "disk_instance"; const std::string storageClassName = "storage_class"; const uint64_t nbCopies = 5; - ASSERT_THROW(m_catalogue->modifyStorageClassNbCopies(m_admin, diskInstance, storageClassName, nbCopies), + ASSERT_THROW(m_catalogue->modifyStorageClassNbCopies(m_admin, storageClassName, nbCopies), exception::UserError); } @@ -778,7 +742,7 @@ TEST_P(cta_catalogue_CatalogueTest, modifyStorageClassComment) { } const std::string modifiedComment = "Modified comment"; - m_catalogue->modifyStorageClassComment(m_admin, storageClass.diskInstance, storageClass.name, modifiedComment); + m_catalogue->modifyStorageClassComment(m_admin, storageClass.name, modifiedComment); { const std::list<common::dataStructures::StorageClass> storageClasses = m_catalogue->getStorageClasses(); @@ -804,7 +768,7 @@ TEST_P(cta_catalogue_CatalogueTest, modifyStorageClassComment_nonExistentStorage const std::string diskInstance = "disk_instance"; const std::string storageClassName = "storage_class"; const std::string comment = "Comment"; - ASSERT_THROW(m_catalogue->modifyStorageClassComment(m_admin, diskInstance, storageClassName, comment), + ASSERT_THROW(m_catalogue->modifyStorageClassComment(m_admin, storageClassName, comment), exception::UserError); } @@ -839,7 +803,7 @@ TEST_P(cta_catalogue_CatalogueTest, modifyStorageClassName) { } const std::string newStorageClassName = "new_storage_class_name"; - m_catalogue->modifyStorageClassName(m_admin, storageClass.diskInstance, storageClass.name, newStorageClassName); + m_catalogue->modifyStorageClassName(m_admin, storageClass.name, newStorageClassName); { const std::list<common::dataStructures::StorageClass> storageClasses = m_catalogue->getStorageClasses(); @@ -865,10 +829,35 @@ TEST_P(cta_catalogue_CatalogueTest, modifyStorageClassName_nonExistentStorageCla const std::string diskInstance = "disk_instance"; const std::string currentStorageClassName = "storage_class"; const std::string newStorageClassName = "new_storage_class"; - ASSERT_THROW(m_catalogue->modifyStorageClassName(m_admin, diskInstance, currentStorageClassName, newStorageClassName), + ASSERT_THROW(m_catalogue->modifyStorageClassName(m_admin, currentStorageClassName, newStorageClassName), exception::UserError); } +TEST_P(cta_catalogue_CatalogueTest, modifyStorageClassName_newNameAlreadyExists) { + using namespace cta; + + ASSERT_TRUE(m_catalogue->getStorageClasses().empty()); + + common::dataStructures::StorageClass storageClass; + storageClass.diskInstance = "disk_instance"; + storageClass.name = "storage_class"; + storageClass.nbCopies = 2; + storageClass.comment = "Create storage class"; + + m_catalogue->createStorageClass(m_admin,storageClass); + + common::dataStructures::StorageClass storageClass2; + storageClass2.diskInstance = "disk_instance"; + storageClass2.name = "storage_class2"; + storageClass2.nbCopies = 2; + storageClass2.comment = "Create storage class"; + + m_catalogue->createStorageClass(m_admin,storageClass2); + + //Try to rename the first storage class with the name of the second one + ASSERT_THROW(m_catalogue->modifyStorageClassName(m_admin,storageClass.name,storageClass2.name),exception::UserError); +} + TEST_P(cta_catalogue_CatalogueTest, createTapePool) { using namespace cta; @@ -1733,11 +1722,11 @@ TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute) { const cta::optional<std::string> supply("value for the supply pool mechanism"); m_catalogue->createTapePool(m_admin, tapePoolName, vo, nbPartialTapes, isEncrypted, supply, "Create tape pool"); - ASSERT_TRUE(m_catalogue->getArchiveRoutes(storageClass.diskInstance, storageClass.name, tapePoolName).empty()); + ASSERT_TRUE(m_catalogue->getArchiveRoutes(storageClass.name, tapePoolName).empty()); const uint32_t copyNb = 1; const std::string comment = "Create archive route"; - m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, tapePoolName, comment); + m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, comment); { const std::list<common::dataStructures::ArchiveRoute> routes = m_catalogue->getArchiveRoutes(); @@ -1745,7 +1734,6 @@ TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute) { ASSERT_EQ(1, routes.size()); const common::dataStructures::ArchiveRoute route = routes.front(); - ASSERT_EQ(storageClass.diskInstance, route.diskInstanceName); ASSERT_EQ(storageClass.name, route.storageClassName); ASSERT_EQ(copyNb, route.copyNb); ASSERT_EQ(tapePoolName, route.tapePoolName); @@ -1761,12 +1749,11 @@ TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute) { { const std::list<common::dataStructures::ArchiveRoute> routes = m_catalogue->getArchiveRoutes( - storageClass.diskInstance, storageClass.name, tapePoolName); + storageClass.name, tapePoolName); ASSERT_EQ(1, routes.size()); const common::dataStructures::ArchiveRoute route = routes.front(); - ASSERT_EQ(storageClass.diskInstance, route.diskInstanceName); ASSERT_EQ(storageClass.name, route.storageClassName); ASSERT_EQ(copyNb, route.copyNb); ASSERT_EQ(tapePoolName, route.tapePoolName); @@ -1896,34 +1883,6 @@ TEST_P(cta_catalogue_CatalogueTest, modifyTapePoolName_emptyStringNewTapePoolNam catalogue::UserSpecifiedAnEmptyStringTapePoolName); } -TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute_emptyStringDiskInstanceName) { - using namespace cta; - - ASSERT_TRUE(m_catalogue->getStorageClasses().empty()); - ASSERT_TRUE(m_catalogue->getTapePools().empty()); - ASSERT_TRUE(m_catalogue->getArchiveRoutes().empty()); - - common::dataStructures::StorageClass storageClass; - storageClass.diskInstance = "disk_instance"; - storageClass.name = "storage_class"; - storageClass.nbCopies = 2; - storageClass.comment = "Create storage class"; - m_catalogue->createStorageClass(m_admin, storageClass); - - const std::string tapePoolName = "tape_pool"; - const std::string vo = "vo"; - const uint64_t nbPartialTapes = 2; - const bool isEncrypted = true; - const cta::optional<std::string> supply("value for the supply pool mechanism"); - m_catalogue->createTapePool(m_admin, tapePoolName, vo, nbPartialTapes, isEncrypted, supply, "Create tape pool"); - - const std::string diskInstanceName = ""; - const uint32_t copyNb = 1; - const std::string comment = "Create archive route"; - ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, diskInstanceName, storageClass.name, copyNb, tapePoolName, - comment), catalogue::UserSpecifiedAnEmptyStringDiskInstanceName); -} - TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute_emptyStringStorageClassName) { using namespace cta; @@ -1948,7 +1907,7 @@ TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute_emptyStringStorageClassNa const std::string storageClassName = ""; const uint32_t copyNb = 1; const std::string comment = "Create archive route"; - ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClassName, copyNb, + ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, storageClassName, copyNb, tapePoolName, comment), catalogue::UserSpecifiedAnEmptyStringStorageClassName); } @@ -1975,7 +1934,7 @@ TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute_zeroCopyNb) { const uint32_t copyNb = 0; const std::string comment = "Create archive route"; - ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, + ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, comment), catalogue::UserSpecifiedAZeroCopyNb); } @@ -1996,7 +1955,7 @@ TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute_emptyStringTapePoolName) const std::string tapePoolName = ""; const uint32_t copyNb = 1; const std::string comment = "Create archive route"; - ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, + ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, comment), catalogue::UserSpecifiedAnEmptyStringTapePoolName); } @@ -2023,7 +1982,7 @@ TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute_emptyStringComment) { const uint32_t copyNb = 1; const std::string comment = ""; - ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, + ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, comment), catalogue::UserSpecifiedAnEmptyStringComment); } @@ -2046,7 +2005,7 @@ TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute_non_existent_storage_clas const uint32_t copyNb = 1; const std::string comment = "Create archive route"; - ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, diskInstanceName, storageClassName, copyNb, tapePoolName, + ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, storageClassName, copyNb, tapePoolName, comment), exception::UserError); } @@ -2069,70 +2028,9 @@ TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute_non_existent_tape_pool) { const uint32_t copyNb = 1; const std::string comment = "Create archive route"; - ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, + ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, comment), exception::UserError); } - -TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute_same_name_different_disk_instance) { - using namespace cta; - - ASSERT_TRUE(m_catalogue->getStorageClasses().empty()); - ASSERT_TRUE(m_catalogue->getTapePools().empty()); - ASSERT_TRUE(m_catalogue->getArchiveRoutes().empty()); - - common::dataStructures::StorageClass storageClass1DiskInstance1; - storageClass1DiskInstance1.diskInstance = "disk_instance_1"; - storageClass1DiskInstance1.name = "storage_class_1"; - storageClass1DiskInstance1.nbCopies = 2; - storageClass1DiskInstance1.comment = "Create storage class"; - - common::dataStructures::StorageClass storageClass1DiskInstance2; - storageClass1DiskInstance2.diskInstance = "disk_instance_2"; - storageClass1DiskInstance2.name = "storage_class_1"; - storageClass1DiskInstance2.nbCopies = 2; - storageClass1DiskInstance2.comment = "Create storage class"; - - m_catalogue->createStorageClass(m_admin, storageClass1DiskInstance1); - m_catalogue->createStorageClass(m_admin, storageClass1DiskInstance2); - - const std::string tapePoolName = "tape_pool"; - const std::string vo = "vo"; - const uint64_t nbPartialTapes = 2; - const bool isEncrypted = true; - const cta::optional<std::string> supply("value for the supply pool mechanism"); - m_catalogue->createTapePool(m_admin, tapePoolName, vo, nbPartialTapes, isEncrypted, supply, "Create tape pool"); - - const uint32_t copyNb = 1; - const std::string comment = "Create archive route"; - m_catalogue->createArchiveRoute(m_admin, storageClass1DiskInstance1.diskInstance, storageClass1DiskInstance1.name, - copyNb, tapePoolName, comment); - m_catalogue->createArchiveRoute(m_admin, storageClass1DiskInstance2.diskInstance, storageClass1DiskInstance2.name, - copyNb, tapePoolName, comment); - - const std::list<common::dataStructures::ArchiveRoute> routes = m_catalogue->getArchiveRoutes(); - - ASSERT_EQ(2, routes.size()); - - { - auto routeForStorageClass1DiskInstance1 = - [&storageClass1DiskInstance1](const common::dataStructures::ArchiveRoute &ar) { - return ar.diskInstanceName == storageClass1DiskInstance1.diskInstance && - ar.storageClassName == storageClass1DiskInstance1.name; - }; - auto itor = std::find_if(routes.begin(), routes.end(), routeForStorageClass1DiskInstance1); - ASSERT_FALSE(itor == routes.end()); - } - - { - auto routeForStorageClass1DiskInstance2 = - [&storageClass1DiskInstance2](const common::dataStructures::ArchiveRoute &ar) { - return ar.diskInstanceName == storageClass1DiskInstance2.diskInstance && - ar.storageClassName == storageClass1DiskInstance2.name; - }; - auto itor = std::find_if(routes.begin(), routes.end(), routeForStorageClass1DiskInstance2); - ASSERT_FALSE(itor == routes.end()); - } -} TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute_same_twice) { using namespace cta; @@ -2157,8 +2055,8 @@ TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute_same_twice) { const uint32_t copyNb = 1; const std::string comment = "Create archive route"; - m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, tapePoolName, comment); - ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, + m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, comment); + ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, comment), exception::Exception); } @@ -2185,11 +2083,11 @@ TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute_two_routes_same_pool) { const uint32_t copyNb1 = 1; const std::string comment1 = "Create archive route for copy 1"; - m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb1, tapePoolName, comment1); + m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb1, tapePoolName, comment1); const uint32_t copyNb2 = 2; const std::string comment2 = "Create archive route for copy 2"; - ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb2, + ASSERT_THROW(m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb2, tapePoolName, comment2), exception::UserError); } @@ -2216,14 +2114,13 @@ TEST_P(cta_catalogue_CatalogueTest, deleteArchiveRoute) { const uint32_t copyNb = 1; const std::string comment = "Create archive route"; - m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, tapePoolName, comment); + m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, comment); const std::list<common::dataStructures::ArchiveRoute> routes = m_catalogue->getArchiveRoutes(); ASSERT_EQ(1, routes.size()); const common::dataStructures::ArchiveRoute route = routes.front(); - ASSERT_EQ(storageClass.diskInstance, route.diskInstanceName); ASSERT_EQ(storageClass.name, route.storageClassName); ASSERT_EQ(copyNb, route.copyNb); ASSERT_EQ(tapePoolName, route.tapePoolName); @@ -2236,7 +2133,7 @@ TEST_P(cta_catalogue_CatalogueTest, deleteArchiveRoute) { const common::dataStructures::EntryLog lastModificationLog = route.lastModificationLog; ASSERT_EQ(creationLog, lastModificationLog); - m_catalogue->deleteArchiveRoute(storageClass.diskInstance, storageClass.name, copyNb); + m_catalogue->deleteArchiveRoute(storageClass.name, copyNb); ASSERT_TRUE(m_catalogue->getArchiveRoutes().empty()); } @@ -2245,7 +2142,7 @@ TEST_P(cta_catalogue_CatalogueTest, deleteArchiveRoute_non_existent) { using namespace cta; ASSERT_TRUE(m_catalogue->getArchiveRoutes().empty()); - ASSERT_THROW(m_catalogue->deleteArchiveRoute("non_existent_disk_instance", "non_existent_storage_class", 1234), + ASSERT_THROW(m_catalogue->deleteArchiveRoute("non_existent_storage_class", 1234), exception::UserError); } @@ -2270,14 +2167,13 @@ TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute_deleteStorageClass) { const uint32_t copyNb = 1; const std::string comment = "Create archive route"; - m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, tapePoolName, comment); + m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, comment); const std::list<common::dataStructures::ArchiveRoute> routes = m_catalogue->getArchiveRoutes(); ASSERT_EQ(1, routes.size()); const common::dataStructures::ArchiveRoute route = routes.front(); - ASSERT_EQ(storageClass.diskInstance, route.diskInstanceName); ASSERT_EQ(storageClass.name, route.storageClassName); ASSERT_EQ(copyNb, route.copyNb); ASSERT_EQ(tapePoolName, route.tapePoolName); @@ -2291,10 +2187,10 @@ TEST_P(cta_catalogue_CatalogueTest, createArchiveRoute_deleteStorageClass) { route.lastModificationLog; ASSERT_EQ(creationLog, lastModificationLog); - ASSERT_THROW(m_catalogue->deleteStorageClass(storageClass.diskInstance, storageClass.name), + ASSERT_THROW(m_catalogue->deleteStorageClass(storageClass.name), catalogue::UserSpecifiedStorageClassUsedByArchiveRoutes); - ASSERT_THROW(m_catalogue->deleteStorageClass(storageClass.diskInstance, storageClass.name), + ASSERT_THROW(m_catalogue->deleteStorageClass(storageClass.name), exception::UserError); } @@ -2325,7 +2221,7 @@ TEST_P(cta_catalogue_CatalogueTest, modifyArchiveRouteTapePoolName) { const uint32_t copyNb = 1; const std::string comment = "Create archive route"; - m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, tapePoolName, comment); + m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, comment); { const std::list<common::dataStructures::ArchiveRoute> routes = m_catalogue->getArchiveRoutes(); @@ -2333,7 +2229,6 @@ TEST_P(cta_catalogue_CatalogueTest, modifyArchiveRouteTapePoolName) { ASSERT_EQ(1, routes.size()); const common::dataStructures::ArchiveRoute route = routes.front(); - ASSERT_EQ(storageClass.diskInstance, route.diskInstanceName); ASSERT_EQ(storageClass.name, route.storageClassName); ASSERT_EQ(copyNb, route.copyNb); ASSERT_EQ(tapePoolName, route.tapePoolName); @@ -2347,7 +2242,7 @@ TEST_P(cta_catalogue_CatalogueTest, modifyArchiveRouteTapePoolName) { ASSERT_EQ(creationLog, lastModificationLog); } - m_catalogue->modifyArchiveRouteTapePoolName(m_admin, storageClass.diskInstance, storageClass.name, copyNb, + m_catalogue->modifyArchiveRouteTapePoolName(m_admin, storageClass.name, copyNb, anotherTapePoolName); { @@ -2356,7 +2251,6 @@ TEST_P(cta_catalogue_CatalogueTest, modifyArchiveRouteTapePoolName) { ASSERT_EQ(1, routes.size()); const common::dataStructures::ArchiveRoute route = routes.front(); - ASSERT_EQ(storageClass.diskInstance, route.diskInstanceName); ASSERT_EQ(storageClass.name, route.storageClassName); ASSERT_EQ(copyNb, route.copyNb); ASSERT_EQ(anotherTapePoolName, route.tapePoolName); @@ -2390,7 +2284,7 @@ TEST_P(cta_catalogue_CatalogueTest, modifyArchiveRouteTapePoolName_nonExistentAr m_catalogue->createTapePool(m_admin, tapePoolName, vo, nbPartialTapes, isEncrypted, supply, "Create tape pool"); const uint32_t copyNb = 1; - ASSERT_THROW(m_catalogue->modifyArchiveRouteTapePoolName(m_admin, storageClass.diskInstance, storageClass.name, + ASSERT_THROW(m_catalogue->modifyArchiveRouteTapePoolName(m_admin, storageClass.name, copyNb, tapePoolName), exception::UserError); } @@ -2417,7 +2311,7 @@ TEST_P(cta_catalogue_CatalogueTest, modifyArchiveRouteComment) { const uint32_t copyNb = 1; const std::string comment = "Create archive route"; - m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, tapePoolName, + m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, comment); { @@ -2426,7 +2320,6 @@ TEST_P(cta_catalogue_CatalogueTest, modifyArchiveRouteComment) { ASSERT_EQ(1, routes.size()); const common::dataStructures::ArchiveRoute route = routes.front(); - ASSERT_EQ(storageClass.diskInstance, route.diskInstanceName); ASSERT_EQ(storageClass.name, route.storageClassName); ASSERT_EQ(copyNb, route.copyNb); ASSERT_EQ(tapePoolName, route.tapePoolName); @@ -2441,7 +2334,7 @@ TEST_P(cta_catalogue_CatalogueTest, modifyArchiveRouteComment) { } const std::string modifiedComment = "Modified comment"; - m_catalogue->modifyArchiveRouteComment(m_admin, storageClass.diskInstance, storageClass.name, copyNb, + m_catalogue->modifyArchiveRouteComment(m_admin, storageClass.name, copyNb, modifiedComment); { @@ -2450,7 +2343,6 @@ TEST_P(cta_catalogue_CatalogueTest, modifyArchiveRouteComment) { ASSERT_EQ(1, routes.size()); const common::dataStructures::ArchiveRoute route = routes.front(); - ASSERT_EQ(storageClass.diskInstance, route.diskInstanceName); ASSERT_EQ(storageClass.name, route.storageClassName); ASSERT_EQ(copyNb, route.copyNb); ASSERT_EQ(tapePoolName, route.tapePoolName); @@ -2485,7 +2377,7 @@ TEST_P(cta_catalogue_CatalogueTest, modifyArchiveRouteComment_nonExistentArchive const uint32_t copyNb = 1; const std::string comment = "Comment"; - ASSERT_THROW(m_catalogue->modifyArchiveRouteComment(m_admin, storageClass.diskInstance, storageClass.name, copyNb, + ASSERT_THROW(m_catalogue->modifyArchiveRouteComment(m_admin, storageClass.name, copyNb, comment), exception::UserError); } @@ -7486,7 +7378,7 @@ TEST_P(cta_catalogue_CatalogueTest, checkAndGetNextArchiveFileId_no_mount_rules) const uint32_t copyNb = 1; const std::string archiveRouteComment = "Create archive route"; - m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, tapePoolName, + m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, archiveRouteComment); const std::list<common::dataStructures::ArchiveRoute> routes = m_catalogue->getArchiveRoutes(); @@ -7573,7 +7465,7 @@ TEST_P(cta_catalogue_CatalogueTest, checkAndGetNextArchiveFileId_requester_mount const uint32_t copyNb = 1; const std::string archiveRouteComment = "Create archive route"; - m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, tapePoolName, + m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, archiveRouteComment); const std::list<common::dataStructures::ArchiveRoute> routes = m_catalogue->getArchiveRoutes(); @@ -7664,7 +7556,7 @@ TEST_P(cta_catalogue_CatalogueTest, checkAndGetNextArchiveFileId_requester_group const uint32_t copyNb = 1; const std::string archiveRouteComment = "Create archive route"; - m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, tapePoolName, + m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, archiveRouteComment); const std::list<common::dataStructures::ArchiveRoute> routes = m_catalogue->getArchiveRoutes(); @@ -7774,7 +7666,7 @@ TEST_P(cta_catalogue_CatalogueTest, checkAndGetNextArchiveFileId_requester_mount const uint32_t copyNb = 1; const std::string archiveRouteComment = "Create archive route"; - m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, tapePoolName, + m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, archiveRouteComment); const std::list<common::dataStructures::ArchiveRoute> routes = m_catalogue->getArchiveRoutes(); @@ -7924,7 +7816,7 @@ TEST_P(cta_catalogue_CatalogueTest, getArchiveFileQueueCriteria_requester_mount_ const uint32_t copyNb = 1; const std::string archiveRouteComment = "Create archive route"; - m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, tapePoolName, + m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, archiveRouteComment); const std::list<common::dataStructures::ArchiveRoute> routes = m_catalogue->getArchiveRoutes(); @@ -8007,7 +7899,7 @@ TEST_P(cta_catalogue_CatalogueTest, getArchiveFileQueueCriteria_requester_group_ const uint32_t copyNb = 1; const std::string archiveRouteComment = "Create archive route"; - m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, tapePoolName, + m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, archiveRouteComment); const std::list<common::dataStructures::ArchiveRoute> routes = m_catalogue->getArchiveRoutes(); @@ -8109,7 +8001,7 @@ TEST_P(cta_catalogue_CatalogueTest, getArchiveFileQueueCriteria_requester_mount_ const uint32_t copyNb = 1; const std::string archiveRouteComment = "Create archive route"; - m_catalogue->createArchiveRoute(m_admin, storageClass.diskInstance, storageClass.name, copyNb, tapePoolName, + m_catalogue->createArchiveRoute(m_admin, storageClass.name, copyNb, tapePoolName, archiveRouteComment); const std::list<common::dataStructures::ArchiveRoute> routes = m_catalogue->getArchiveRoutes(); @@ -10850,10 +10742,10 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_1_archive_file_1_tape_cop ASSERT_TRUE(m_catalogue->getArchiveRoutes().empty()); - ASSERT_THROW(m_catalogue->deleteStorageClass(storageClass.diskInstance, storageClass.name), + ASSERT_THROW(m_catalogue->deleteStorageClass(storageClass.name), catalogue::UserSpecifiedStorageClassUsedByArchiveFiles); - ASSERT_THROW(m_catalogue->deleteStorageClass(storageClass.diskInstance, storageClass.name), + ASSERT_THROW(m_catalogue->deleteStorageClass(storageClass.name), exception::UserError); } diff --git a/catalogue/DummyCatalogue.hpp b/catalogue/DummyCatalogue.hpp index 961d60d7feba842c1cde264467a6a0e74d7cec33..7572c9b9443346b778a12f5f3e4471d2d6618d76 100644 --- a/catalogue/DummyCatalogue.hpp +++ b/catalogue/DummyCatalogue.hpp @@ -36,7 +36,7 @@ public: void createActivitiesFairShareWeight(const common::dataStructures::SecurityIdentity& admin, const std::string& diskInstanceName, const std::string& acttivity, double weight, const std::string & comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void createAdminUser(const common::dataStructures::SecurityIdentity& admin, const std::string& username, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } - void createArchiveRoute(const common::dataStructures::SecurityIdentity& admin, const std::string& diskInstanceName, const std::string& storageClassName, const uint32_t copyNb, const std::string& tapePoolName, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } + void createArchiveRoute(const common::dataStructures::SecurityIdentity& admin, const std::string& storageClassName, const uint32_t copyNb, const std::string& tapePoolName, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void createLogicalLibrary(const common::dataStructures::SecurityIdentity& admin, const std::string& name, const bool isDisabled, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void createMountPolicy(const common::dataStructures::SecurityIdentity& admin, 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) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void createRequesterGroupMountRule(const common::dataStructures::SecurityIdentity& admin, const std::string& mountPolicyName, const std::string& diskInstanceName, const std::string& requesterGroupName, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } @@ -47,12 +47,12 @@ public: void deleteActivitiesFairShareWeight(const common::dataStructures::SecurityIdentity& admin, const std::string& diskInstanceName, const std::string& acttivity) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void deleteAdminUser(const std::string& username) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void deleteArchiveFile(const std::string& instanceName, const uint64_t archiveFileId, log::LogContext &lc) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } - void deleteArchiveRoute(const std::string& diskInstanceName, const std::string& storageClassName, const uint32_t copyNb) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } + void deleteArchiveRoute(const std::string& storageClassName, const uint32_t copyNb) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void deleteLogicalLibrary(const std::string& name) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void deleteMountPolicy(const std::string& name) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void deleteRequesterGroupMountRule(const std::string& diskInstanceName, const std::string& requesterGroupName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void deleteRequesterMountRule(const std::string& diskInstanceName, const std::string& requesterName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } - void deleteStorageClass(const std::string& diskInstanceName, const std::string& storageClassName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } + void deleteStorageClass(const std::string& storageClassName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void deleteTape(const std::string& vid) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void deleteTapePool(const std::string& name) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void filesWrittenToTape(const std::set<TapeItemWrittenPointer>& event) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } @@ -72,7 +72,7 @@ public: std::list<common::dataStructures::ArchiveFile> getFilesForRepack(const std::string &vid, const uint64_t startFSeq, const uint64_t maxNbFiles) const override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } ArchiveFileItor getArchiveFilesForRepackItor(const std::string &vid, const uint64_t startFSeq) const override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } std::list<common::dataStructures::ArchiveRoute> getArchiveRoutes() const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } - std::list<common::dataStructures::ArchiveRoute> getArchiveRoutes(const std::string &diskInstanceName, const std::string &storageClassName, const std::string &tapePoolName) const override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } + std::list<common::dataStructures::ArchiveRoute> getArchiveRoutes(const std::string &storageClassName, const std::string &tapePoolName) const override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } std::list<common::dataStructures::LogicalLibrary> getLogicalLibraries() const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } std::list<common::dataStructures::MountPolicy> getMountPolicies() const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } std::list<common::dataStructures::RequesterGroupMountRule> getRequesterGroupMountRules() const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } @@ -87,8 +87,8 @@ public: bool isAdmin(const common::dataStructures::SecurityIdentity& admin) const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void modifyActivitiesFairShareWeight(const common::dataStructures::SecurityIdentity& admin, const std::string& diskInstanceName, const std::string& acttivity, double weight, const std::string & comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void modifyAdminUserComment(const common::dataStructures::SecurityIdentity& admin, const std::string& username, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } - void modifyArchiveRouteComment(const common::dataStructures::SecurityIdentity& admin, const std::string& instanceName, const std::string& storageClassName, const uint32_t copyNb, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } - void modifyArchiveRouteTapePoolName(const common::dataStructures::SecurityIdentity& admin, const std::string& instanceName, const std::string& storageClassName, const uint32_t copyNb, const std::string& tapePoolName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } + void modifyArchiveRouteComment(const common::dataStructures::SecurityIdentity& admin, const std::string& storageClassName, const uint32_t copyNb, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } + void modifyArchiveRouteTapePoolName(const common::dataStructures::SecurityIdentity& admin, const std::string& storageClassName, const uint32_t copyNb, const std::string& tapePoolName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void modifyLogicalLibraryName(const common::dataStructures::SecurityIdentity &admin, const std::string ¤tName, const std::string &newName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void modifyLogicalLibraryComment(const common::dataStructures::SecurityIdentity& admin, const std::string& name, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void setLogicalLibraryDisabled(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const bool disabledValue) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } @@ -102,9 +102,9 @@ public: void modifyRequesterGroupMountRuleComment(const common::dataStructures::SecurityIdentity& admin, const std::string& instanceName, const std::string& requesterGroupName, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void modifyRequesterGroupMountRulePolicy(const common::dataStructures::SecurityIdentity& admin, const std::string& instanceName, const std::string& requesterGroupName, const std::string& mountPolicy) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void modifyRequesterMountRulePolicy(const common::dataStructures::SecurityIdentity& admin, const std::string& instanceName, const std::string& requesterName, const std::string& mountPolicy) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } - void modifyStorageClassComment(const common::dataStructures::SecurityIdentity& admin, const std::string& instanceName, const std::string& name, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } - void modifyStorageClassName(const common::dataStructures::SecurityIdentity& admin, const std::string& instanceName, const std::string& currentName, const std::string& newName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } - void modifyStorageClassNbCopies(const common::dataStructures::SecurityIdentity& admin, const std::string& instanceName, const std::string& name, const uint64_t nbCopies) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } + void modifyStorageClassComment(const common::dataStructures::SecurityIdentity& admin, const std::string& name, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } + void modifyStorageClassName(const common::dataStructures::SecurityIdentity& admin, const std::string& currentName, const std::string& newName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } + void modifyStorageClassNbCopies(const common::dataStructures::SecurityIdentity& admin, const std::string& name, const uint64_t nbCopies) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void modifyTapeCapacityInBytes(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const uint64_t capacityInBytes) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void modifyTapeComment(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const std::string& comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } void modifyTapeEncryptionKeyName(const common::dataStructures::SecurityIdentity& admin, const std::string& vid, const std::string& encryptionKeyName) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); } diff --git a/catalogue/RdbmsCatalogue.cpp b/catalogue/RdbmsCatalogue.cpp index 99811fc0229c2d4c9ebd73f8bdc31d0574216b28..5d00c3f6ac96a50c7fbd118ac2cdef18e6f458a3 100644 --- a/catalogue/RdbmsCatalogue.cpp +++ b/catalogue/RdbmsCatalogue.cpp @@ -323,8 +323,8 @@ void RdbmsCatalogue::createStorageClass( } auto conn = m_connPool.getConn(); - if(storageClassExists(conn, storageClass.diskInstance, storageClass.name)) { - throw exception::UserError(std::string("Cannot create storage class ") + storageClass.diskInstance + ":" + + if(storageClassExists(conn, storageClass.name)) { + throw exception::UserError(std::string("Cannot create storage class : ") + storageClass.name + " because it already exists"); } const uint64_t storageClassId = getNextStorageClassId(conn); @@ -389,20 +389,17 @@ void RdbmsCatalogue::createStorageClass( //------------------------------------------------------------------------------ // storageClassExists //------------------------------------------------------------------------------ -bool RdbmsCatalogue::storageClassExists(rdbms::Conn &conn, const std::string &diskInstanceName, +bool RdbmsCatalogue::storageClassExists(rdbms::Conn &conn, const std::string &storageClassName) const { try { const char *const sql = "SELECT " - "DISK_INSTANCE_NAME AS DISK_INSTANCE_NAME, " "STORAGE_CLASS_NAME AS STORAGE_CLASS_NAME " "FROM " "STORAGE_CLASS " "WHERE " - "DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME AND " "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME"; auto stmt = conn.createStmt(sql); - stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":STORAGE_CLASS_NAME", storageClassName); auto rset = stmt.executeQuery(); return rset.next(); @@ -417,7 +414,7 @@ bool RdbmsCatalogue::storageClassExists(rdbms::Conn &conn, const std::string &di //------------------------------------------------------------------------------ // deleteStorageClass //------------------------------------------------------------------------------ -void RdbmsCatalogue::deleteStorageClass(const std::string &diskInstanceName, const std::string &storageClassName) { +void RdbmsCatalogue::deleteStorageClass(const std::string &storageClassName) { try { auto conn = m_connPool.getConn(); @@ -435,16 +432,14 @@ void RdbmsCatalogue::deleteStorageClass(const std::string &diskInstanceName, con "DELETE FROM " "STORAGE_CLASS " "WHERE " - "DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME AND " "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME"; auto stmt = conn.createStmt(sql); - stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":STORAGE_CLASS_NAME", storageClassName); stmt.executeNonQuery(); if(0 == stmt.getNbAffectedRows()) { - throw exception::UserError(std::string("Cannot delete storage-class ") + diskInstanceName + ":" + + throw exception::UserError(std::string("Cannot delete storage-class : ") + storageClassName + " because it does not exist"); } } catch(exception::UserError &) { @@ -569,7 +564,7 @@ std::list<common::dataStructures::StorageClass> RdbmsCatalogue::getStorageClasse // modifyStorageClassNbCopies //------------------------------------------------------------------------------ void RdbmsCatalogue::modifyStorageClassNbCopies(const common::dataStructures::SecurityIdentity &admin, - const std::string &instanceName, const std::string &name, const uint64_t nbCopies) { + const std::string &name, const uint64_t nbCopies) { try { const time_t now = time(nullptr); const char *const sql = @@ -579,7 +574,6 @@ void RdbmsCatalogue::modifyStorageClassNbCopies(const common::dataStructures::Se "LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME," "LAST_UPDATE_TIME = :LAST_UPDATE_TIME " "WHERE " - "DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME AND " "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME"; auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); @@ -587,12 +581,11 @@ void RdbmsCatalogue::modifyStorageClassNbCopies(const common::dataStructures::Se stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username); stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host); stmt.bindUint64(":LAST_UPDATE_TIME", now); - stmt.bindString(":DISK_INSTANCE_NAME", instanceName); stmt.bindString(":STORAGE_CLASS_NAME", name); stmt.executeNonQuery(); if(0 == stmt.getNbAffectedRows()) { - throw exception::UserError(std::string("Cannot modify storage class ") + instanceName + ":" + name + + throw exception::UserError(std::string("Cannot modify storage class : ") + name + " because it does not exist"); } } catch(exception::UserError &) { @@ -607,7 +600,7 @@ void RdbmsCatalogue::modifyStorageClassNbCopies(const common::dataStructures::Se // modifyStorageClassComment //------------------------------------------------------------------------------ void RdbmsCatalogue::modifyStorageClassComment(const common::dataStructures::SecurityIdentity &admin, - const std::string &instanceName, const std::string &name, const std::string &comment) { + const std::string &name, const std::string &comment) { try { const time_t now = time(nullptr); const char *const sql = @@ -617,7 +610,6 @@ void RdbmsCatalogue::modifyStorageClassComment(const common::dataStructures::Sec "LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME," "LAST_UPDATE_TIME = :LAST_UPDATE_TIME " "WHERE " - "DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME AND " "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME"; auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); @@ -625,12 +617,11 @@ void RdbmsCatalogue::modifyStorageClassComment(const common::dataStructures::Sec stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username); stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host); stmt.bindUint64(":LAST_UPDATE_TIME", now); - stmt.bindString(":DISK_INSTANCE_NAME", instanceName); stmt.bindString(":STORAGE_CLASS_NAME", name); stmt.executeNonQuery(); if(0 == stmt.getNbAffectedRows()) { - throw exception::UserError(std::string("Cannot modify storage class ") + instanceName + ":" + name + + throw exception::UserError(std::string("Cannot modify storage class : ") + name + " because it does not exist"); } } catch(exception::UserError &) { @@ -645,7 +636,7 @@ void RdbmsCatalogue::modifyStorageClassComment(const common::dataStructures::Sec // modifyStorageClassName //------------------------------------------------------------------------------ void RdbmsCatalogue::modifyStorageClassName(const common::dataStructures::SecurityIdentity &admin, - const std::string &instanceName, const std::string ¤tName, const std::string &newName) { + const std::string ¤tName, const std::string &newName) { try { const time_t now = time(nullptr); const char *const sql = @@ -655,20 +646,23 @@ void RdbmsCatalogue::modifyStorageClassName(const common::dataStructures::Securi "LAST_UPDATE_HOST_NAME = :LAST_UPDATE_HOST_NAME," "LAST_UPDATE_TIME = :LAST_UPDATE_TIME " "WHERE " - "DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME AND " "STORAGE_CLASS_NAME = :CURRENT_STORAGE_CLASS_NAME"; auto conn = m_connPool.getConn(); + if(newName != currentName){ + if(storageClassExists(conn,newName)){ + throw exception::UserError(std::string("Cannot modify the storage class name ") + currentName +". The new name : " + newName+" already exists in the database."); + } + } auto stmt = conn.createStmt(sql); stmt.bindString(":NEW_STORAGE_CLASS_NAME", newName); stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username); stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host); stmt.bindUint64(":LAST_UPDATE_TIME", now); - stmt.bindString(":DISK_INSTANCE_NAME", instanceName); stmt.bindString(":CURRENT_STORAGE_CLASS_NAME", currentName); stmt.executeNonQuery(); if(0 == stmt.getNbAffectedRows()) { - throw exception::UserError(std::string("Cannot modify storage class ") + instanceName + ":" + currentName + + throw exception::UserError(std::string("Cannot modify storage class : ") + currentName + " because it does not exist"); } } catch(exception::UserError &) { @@ -952,7 +946,7 @@ bool RdbmsCatalogue::diskFileGroupExists(rdbms::Conn &conn, const std::string &d //------------------------------------------------------------------------------ // archiveRouteExists //------------------------------------------------------------------------------ -bool RdbmsCatalogue::archiveRouteExists(rdbms::Conn &conn, const std::string &diskInstanceName, +bool RdbmsCatalogue::archiveRouteExists(rdbms::Conn &conn, const std::string &storageClassName, const uint32_t copyNb) const { try { const char *const sql = @@ -964,11 +958,9 @@ bool RdbmsCatalogue::archiveRouteExists(rdbms::Conn &conn, const std::string &di "INNER JOIN STORAGE_CLASS ON " "ARCHIVE_ROUTE.STORAGE_CLASS_ID = STORAGE_CLASS.STORAGE_CLASS_ID " "WHERE " - "STORAGE_CLASS.DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME AND " "STORAGE_CLASS.STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME AND " "ARCHIVE_ROUTE.COPY_NB = :COPY_NB"; auto stmt = conn.createStmt(sql); - stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":STORAGE_CLASS_NAME", storageClassName); stmt.bindUint64(":COPY_NB", copyNb); auto rset = stmt.executeQuery(); @@ -1349,16 +1341,11 @@ void RdbmsCatalogue::modifyTapePoolName(const common::dataStructures::SecurityId //------------------------------------------------------------------------------ void RdbmsCatalogue::createArchiveRoute( const common::dataStructures::SecurityIdentity &admin, - const std::string &diskInstanceName, const std::string &storageClassName, const uint32_t copyNb, const std::string &tapePoolName, const std::string &comment) { try { - if(diskInstanceName.empty()) { - throw UserSpecifiedAnEmptyStringDiskInstanceName("Cannot create archive route because disk instance name is an" - " empty string"); - } if(storageClassName.empty()) { throw UserSpecifiedAnEmptyStringStorageClassName("Cannot create archive route because storage class name is an" " empty string"); @@ -1376,31 +1363,31 @@ void RdbmsCatalogue::createArchiveRoute( const time_t now = time(nullptr); auto conn = m_connPool.getConn(); - if(archiveRouteExists(conn, diskInstanceName, storageClassName, copyNb)) { + if(archiveRouteExists(conn, storageClassName, copyNb)) { exception::UserError ue; - ue.getMessage() << "Cannot create archive route " << diskInstanceName << ":" << storageClassName << "," << copyNb + ue.getMessage() << "Cannot create archive route " << ": " << storageClassName << "," << copyNb << "->" << tapePoolName << " because it already exists"; throw ue; } { - const auto routes = getArchiveRoutes(conn, diskInstanceName, storageClassName, tapePoolName); + const auto routes = getArchiveRoutes(conn, storageClassName, tapePoolName); if(!routes.empty()) { exception::UserError ue; - ue.getMessage() << "Cannot create archive route " << diskInstanceName << ":" << storageClassName << "," << copyNb + ue.getMessage() << "Cannot create archive route " << ": " << storageClassName << "," << copyNb << "->" << tapePoolName << " because a route already exists for this storage class and tape pool"; throw ue; } } - if(!storageClassExists(conn, diskInstanceName, storageClassName)) { + if(!storageClassExists(conn, storageClassName)) { exception::UserError ue; - ue.getMessage() << "Cannot create archive route " << diskInstanceName << ":" << storageClassName << "," << copyNb - << "->" << tapePoolName << " because storage class " << diskInstanceName << ":" << storageClassName << + ue.getMessage() << "Cannot create archive route " << ": " << storageClassName << "," << copyNb + << "->" << tapePoolName << " because storage class " << ":" << storageClassName << " does not exist"; throw ue; } if(!tapePoolExists(conn, tapePoolName)) { exception::UserError ue; - ue.getMessage() << "Cannot create archive route " << diskInstanceName << ":" << storageClassName << "," << copyNb + ue.getMessage() << "Cannot create archive route " << ": " << storageClassName << "," << copyNb << "->" << tapePoolName << " because tape pool " << tapePoolName + " does not exist"; throw ue; } @@ -1437,11 +1424,9 @@ void RdbmsCatalogue::createArchiveRoute( "FROM " "STORAGE_CLASS " "WHERE " - "DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME AND " "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME"; auto stmt = conn.createStmt(sql); - stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":STORAGE_CLASS_NAME", storageClassName); stmt.bindUint64(":COPY_NB", copyNb); stmt.bindString(":TAPE_POOL_NAME", tapePoolName); @@ -1468,7 +1453,7 @@ void RdbmsCatalogue::createArchiveRoute( //------------------------------------------------------------------------------ // deleteArchiveRoute //------------------------------------------------------------------------------ -void RdbmsCatalogue::deleteArchiveRoute(const std::string &diskInstanceName, const std::string &storageClassName, +void RdbmsCatalogue::deleteArchiveRoute(const std::string &storageClassName, const uint32_t copyNb) { try { const char *const sql = @@ -1481,19 +1466,17 @@ void RdbmsCatalogue::deleteArchiveRoute(const std::string &diskInstanceName, con "FROM " "STORAGE_CLASS " "WHERE " - "DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME AND " "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME) AND " "COPY_NB = :COPY_NB"; auto conn = m_connPool.getConn(); auto stmt = conn.createStmt(sql); - stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":STORAGE_CLASS_NAME", storageClassName); stmt.bindUint64(":COPY_NB", copyNb); stmt.executeNonQuery(); if(0 == stmt.getNbAffectedRows()) { exception::UserError ue; - ue.getMessage() << "Cannot delete archive route for storage-class " << diskInstanceName + ":" + storageClassName + + ue.getMessage() << "Cannot delete archive route for storage-class " << ":" + storageClassName + " and copy number " << copyNb << " because it does not exist"; throw ue; } @@ -1513,7 +1496,6 @@ std::list<common::dataStructures::ArchiveRoute> RdbmsCatalogue::getArchiveRoutes std::list<common::dataStructures::ArchiveRoute> routes; const char *const sql = "SELECT " - "STORAGE_CLASS.DISK_INSTANCE_NAME AS DISK_INSTANCE_NAME," "STORAGE_CLASS.STORAGE_CLASS_NAME AS STORAGE_CLASS_NAME," "ARCHIVE_ROUTE.COPY_NB AS COPY_NB," "TAPE_POOL.TAPE_POOL_NAME AS TAPE_POOL_NAME," @@ -1541,7 +1523,6 @@ std::list<common::dataStructures::ArchiveRoute> RdbmsCatalogue::getArchiveRoutes while (rset.next()) { common::dataStructures::ArchiveRoute route; - route.diskInstanceName = rset.columnString("DISK_INSTANCE_NAME"); route.storageClassName = rset.columnString("STORAGE_CLASS_NAME"); route.copyNb = rset.columnUint64("COPY_NB"); route.tapePoolName = rset.columnString("TAPE_POOL_NAME"); @@ -1569,11 +1550,11 @@ std::list<common::dataStructures::ArchiveRoute> RdbmsCatalogue::getArchiveRoutes // getArchiveRoutes //------------------------------------------------------------------------------ std::list<common::dataStructures::ArchiveRoute> RdbmsCatalogue::getArchiveRoutes( - const std::string &diskInstanceName, const std::string &storageClassName, + const std::string &storageClassName, const std::string &tapePoolName) const { try { auto conn = m_connPool.getConn(); - return getArchiveRoutes(conn, diskInstanceName, storageClassName, tapePoolName); + return getArchiveRoutes(conn, storageClassName, tapePoolName); } catch(exception::UserError &) { throw; } catch(exception::Exception &ex) { @@ -1586,12 +1567,11 @@ std::list<common::dataStructures::ArchiveRoute> RdbmsCatalogue::getArchiveRoutes // getArchiveRoutes //------------------------------------------------------------------------------ std::list<common::dataStructures::ArchiveRoute> RdbmsCatalogue::getArchiveRoutes(rdbms::Conn &conn, - const std::string &diskInstanceName, const std::string &storageClassName, const std::string &tapePoolName) const { + const std::string &storageClassName, const std::string &tapePoolName) const { try { std::list<common::dataStructures::ArchiveRoute> routes; const char *const sql = "SELECT" "\n" - "STORAGE_CLASS.DISK_INSTANCE_NAME AS DISK_INSTANCE_NAME," "\n" "STORAGE_CLASS.STORAGE_CLASS_NAME AS STORAGE_CLASS_NAME," "\n" "ARCHIVE_ROUTE.COPY_NB AS COPY_NB," "\n" "TAPE_POOL.TAPE_POOL_NAME AS TAPE_POOL_NAME," "\n" @@ -1612,20 +1592,17 @@ std::list<common::dataStructures::ArchiveRoute> RdbmsCatalogue::getArchiveRoutes "INNER JOIN TAPE_POOL ON" "\n" "ARCHIVE_ROUTE.TAPE_POOL_ID = TAPE_POOL.TAPE_POOL_ID" "\n" "WHERE" "\n" - "STORAGE_CLASS.DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME AND" "\n" "STORAGE_CLASS.STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME AND" "\n" "TAPE_POOL.TAPE_POOL_NAME = :TAPE_POOL_NAME" "\n" "ORDER BY" "\n" "DISK_INSTANCE_NAME, STORAGE_CLASS_NAME, COPY_NB"; auto stmt = conn.createStmt(sql); - stmt.bindString(":DISK_INSTANCE_NAME", diskInstanceName); stmt.bindString(":STORAGE_CLASS_NAME", storageClassName); stmt.bindString(":TAPE_POOL_NAME", tapePoolName); auto rset = stmt.executeQuery(); while (rset.next()) { common::dataStructures::ArchiveRoute route; - route.diskInstanceName = rset.columnString("DISK_INSTANCE_NAME"); route.storageClassName = rset.columnString("STORAGE_CLASS_NAME"); route.copyNb = rset.columnUint64("COPY_NB"); route.tapePoolName = rset.columnString("TAPE_POOL_NAME"); @@ -1653,7 +1630,7 @@ std::list<common::dataStructures::ArchiveRoute> RdbmsCatalogue::getArchiveRoutes // modifyArchiveRouteTapePoolName //------------------------------------------------------------------------------ void RdbmsCatalogue::modifyArchiveRouteTapePoolName(const common::dataStructures::SecurityIdentity &admin, - const std::string &instanceName, const std::string &storageClassName, const uint32_t copyNb, + const std::string &storageClassName, const uint32_t copyNb, const std::string &tapePoolName) { try { const time_t now = time(nullptr); @@ -1670,7 +1647,6 @@ void RdbmsCatalogue::modifyArchiveRouteTapePoolName(const common::dataStructures "FROM " "STORAGE_CLASS " "WHERE " - "DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME AND " "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME) AND " "COPY_NB = :COPY_NB"; auto conn = m_connPool.getConn(); @@ -1679,14 +1655,13 @@ void RdbmsCatalogue::modifyArchiveRouteTapePoolName(const common::dataStructures stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username); stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host); stmt.bindUint64(":LAST_UPDATE_TIME", now); - stmt.bindString(":DISK_INSTANCE_NAME", instanceName); stmt.bindString(":STORAGE_CLASS_NAME", storageClassName); stmt.bindUint64(":COPY_NB", copyNb); stmt.executeNonQuery(); if(0 == stmt.getNbAffectedRows()) { exception::UserError ue; - ue.getMessage() << "Cannot modify archive route for storage-class " << instanceName + ":" + storageClassName + + ue.getMessage() << "Cannot modify archive route for storage-class " << ":" + storageClassName + " and copy number " << copyNb << " because either it or tape pool " + tapePoolName + " does not exist"; throw ue; } @@ -1702,7 +1677,7 @@ void RdbmsCatalogue::modifyArchiveRouteTapePoolName(const common::dataStructures // modifyArchiveRouteComment //------------------------------------------------------------------------------ void RdbmsCatalogue::modifyArchiveRouteComment(const common::dataStructures::SecurityIdentity &admin, - const std::string &instanceName, const std::string &storageClassName, const uint32_t copyNb, + const std::string &storageClassName, const uint32_t copyNb, const std::string &comment) { try { const time_t now = time(nullptr); @@ -1719,7 +1694,6 @@ void RdbmsCatalogue::modifyArchiveRouteComment(const common::dataStructures::Sec "FROM " "STORAGE_CLASS " "WHERE " - "DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME AND " "STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME) AND " "COPY_NB = :COPY_NB"; auto conn = m_connPool.getConn(); @@ -1728,14 +1702,13 @@ void RdbmsCatalogue::modifyArchiveRouteComment(const common::dataStructures::Sec stmt.bindString(":LAST_UPDATE_USER_NAME", admin.username); stmt.bindString(":LAST_UPDATE_HOST_NAME", admin.host); stmt.bindUint64(":LAST_UPDATE_TIME", now); - stmt.bindString(":DISK_INSTANCE_NAME", instanceName); stmt.bindString(":STORAGE_CLASS_NAME", storageClassName); stmt.bindUint64(":COPY_NB", copyNb); stmt.executeNonQuery(); if(0 == stmt.getNbAffectedRows()) { exception::UserError ue; - ue.getMessage() << "Cannot modify archive route for storage-class " << instanceName + ":" + storageClassName + + ue.getMessage() << "Cannot modify archive route for storage-class " << ":" + storageClassName + " and copy number " << copyNb << " because it does not exist"; throw ue; } @@ -5445,7 +5418,7 @@ void RdbmsCatalogue::modifyDiskSystemSleepTime(const common::dataStructures::Sec //------------------------------------------------------------------------------ void RdbmsCatalogue::insertArchiveFile(rdbms::Conn &conn, const ArchiveFileRow &row) { try { - if(!storageClassExists(conn, row.diskInstance, row.storageClassName)) { + if(!storageClassExists(conn, row.storageClassName)) { throw exception::UserError(std::string("Storage class ") + row.diskInstance + ":" + row.storageClassName + " does not exist"); } @@ -5583,8 +5556,8 @@ void RdbmsCatalogue::checkTapeFileSearchCriteria(const TapeFileSearchCriteria &s } if(searchCriteria.diskInstance && searchCriteria.storageClass) { - if(!storageClassExists(conn, searchCriteria.diskInstance.value(), searchCriteria.storageClass.value())) { - throw exception::UserError(std::string("Storage class ") + searchCriteria.diskInstance.value() + "::" + + if(!storageClassExists(conn, searchCriteria.storageClass.value())) { + throw exception::UserError(std::string("Storage class ") + "::" + searchCriteria.storageClass.value() + " does not exist"); } } @@ -5927,19 +5900,19 @@ void RdbmsCatalogue::tapeLabelled(const std::string &vid, const std::string &dri uint64_t RdbmsCatalogue::checkAndGetNextArchiveFileId(const std::string &diskInstanceName, const std::string &storageClassName, const common::dataStructures::RequesterIdentity &user) { try { - const auto storageClass = StorageClass(diskInstanceName, storageClassName); + const auto storageClass = StorageClass(storageClassName); const auto copyToPoolMap = getCachedTapeCopyToPoolMap(storageClass); const auto expectedNbRoutes = getCachedExpectedNbArchiveRoutes(storageClass); // Check that the number of archive routes is correct if(copyToPoolMap.empty()) { exception::UserError ue; - ue.getMessage() << "Storage class " << diskInstanceName << ":" << storageClassName << " has no archive routes"; + ue.getMessage() << "Storage class " << storageClassName << " has no archive routes"; throw ue; } if(copyToPoolMap.size() != expectedNbRoutes) { exception::UserError ue; - ue.getMessage() << "Storage class " << diskInstanceName << ":" << storageClassName << " does not have the" + ue.getMessage() << "Storage class " << storageClassName << " does not have the" " expected number of archive routes routes: expected=" << expectedNbRoutes << ", actual=" << copyToPoolMap.size(); throw ue; @@ -5980,19 +5953,19 @@ common::dataStructures::ArchiveFileQueueCriteria RdbmsCatalogue::getArchiveFileQ const std::string &diskInstanceName, const std::string &storageClassName, const common::dataStructures::RequesterIdentity &user) { try { - const StorageClass storageClass = StorageClass(diskInstanceName, storageClassName); + const StorageClass storageClass = StorageClass(storageClassName); const common::dataStructures::TapeCopyToPoolMap copyToPoolMap = getCachedTapeCopyToPoolMap(storageClass); const uint64_t expectedNbRoutes = getCachedExpectedNbArchiveRoutes(storageClass); // Check that the number of archive routes is correct if(copyToPoolMap.empty()) { exception::UserError ue; - ue.getMessage() << "Storage class " << diskInstanceName << ":" << storageClassName << " has no archive routes"; + ue.getMessage() << "Storage class " << diskInstanceName << ": " << storageClassName << " has no archive routes"; throw ue; } if(copyToPoolMap.size() != expectedNbRoutes) { exception::UserError ue; - ue.getMessage() << "Storage class " << diskInstanceName << ":" << storageClassName << " does not have the" + ue.getMessage() << "Storage class " << diskInstanceName << ": " << storageClassName << " does not have the" " expected number of archive routes routes: expected=" << expectedNbRoutes << ", actual=" << copyToPoolMap.size(); throw ue; @@ -6057,10 +6030,8 @@ common::dataStructures::TapeCopyToPoolMap RdbmsCatalogue::getTapeCopyToPoolMap(r "INNER JOIN TAPE_POOL ON " "ARCHIVE_ROUTE.TAPE_POOL_ID = TAPE_POOL.TAPE_POOL_ID " "WHERE " - "STORAGE_CLASS.DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME AND " "STORAGE_CLASS.STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME"; auto stmt = conn.createStmt(sql); - stmt.bindString(":DISK_INSTANCE_NAME", storageClass.diskInstanceName); stmt.bindString(":STORAGE_CLASS_NAME", storageClass.storageClassName); auto rset = stmt.executeQuery(); while (rset.next()) { @@ -6111,10 +6082,8 @@ uint64_t RdbmsCatalogue::getExpectedNbArchiveRoutes(rdbms::Conn &conn, const Sto "INNER JOIN STORAGE_CLASS ON " "ARCHIVE_ROUTE.STORAGE_CLASS_ID = STORAGE_CLASS.STORAGE_CLASS_ID " "WHERE " - "STORAGE_CLASS.DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME AND " "STORAGE_CLASS.STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME"; auto stmt = conn.createStmt(sql); - stmt.bindString(":DISK_INSTANCE_NAME", storageClass.diskInstanceName); stmt.bindString(":STORAGE_CLASS_NAME", storageClass.storageClassName); auto rset = stmt.executeQuery(); if(!rset.next()) { diff --git a/catalogue/RdbmsCatalogue.hpp b/catalogue/RdbmsCatalogue.hpp index e6a37e6bf51f1af96ccda212de192ec8f859893c..d7f8f4a1cdb7f0d209dfcf1943f5c95276ea18a8 100644 --- a/catalogue/RdbmsCatalogue.hpp +++ b/catalogue/RdbmsCatalogue.hpp @@ -225,26 +225,22 @@ public: /** * 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. */ - void deleteStorageClass(const std::string &diskInstanceName, const std::string &storageClassName) override; + void deleteStorageClass(const std::string &storageClassName) override; std::list<common::dataStructures::StorageClass> getStorageClasses() const override; - void modifyStorageClassNbCopies(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &name, const uint64_t nbCopies) override; - void modifyStorageClassComment(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &name, const std::string &comment) override; + void modifyStorageClassNbCopies(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const uint64_t nbCopies) override; + void modifyStorageClassComment(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const std::string &comment) override; /** * Modifies the name of the specified storage class. * - * @param diskInstanceName The name of the disk instance to which the - * storage class belongs. * @param currentName The current name of the storage class. * @param newName The new name of the storage class. */ - void modifyStorageClassName(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string ¤tName, const std::string &newName) override; + void modifyStorageClassName(const common::dataStructures::SecurityIdentity &admin, const std::string ¤tName, const std::string &newName) override; 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) override; void deleteTapePool(const std::string &name) override; @@ -266,7 +262,6 @@ public: void createArchiveRoute( const common::dataStructures::SecurityIdentity &admin, - const std::string &diskInstanceName, const std::string &storageClassName, const uint32_t copyNb, const std::string &tapePoolName, @@ -276,14 +271,10 @@ public: /** * 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 storageClassName The name of the storage class which is unique * @param copyNb The copy number of the tape file. */ void deleteArchiveRoute( - const std::string &diskInstanceName, const std::string &storageClassName, const uint32_t copyNb) override; @@ -297,18 +288,15 @@ public: * For a given storage class there should be no more than one route to any * given tape pool. * - * @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 storageClassName The name of the storage class which is unique * @param tapePoolName The name of the tape pool. */ std::list<common::dataStructures::ArchiveRoute> getArchiveRoutes( - const std::string &diskInstanceName, const std::string &storageClassName, + const std::string &storageClassName, const std::string &tapePoolName) const override; - void modifyArchiveRouteTapePoolName(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &storageClassName, const uint32_t copyNb, const std::string &tapePoolName) override; - void modifyArchiveRouteComment(const common::dataStructures::SecurityIdentity &admin, const std::string &instanceName, const std::string &storageClassName, const uint32_t copyNb, const std::string &comment) override; + void modifyArchiveRouteTapePoolName(const common::dataStructures::SecurityIdentity &admin, const std::string &storageClassName, const uint32_t copyNb, const std::string &tapePoolName) override; + void modifyArchiveRouteComment(const common::dataStructures::SecurityIdentity &admin, const std::string &storageClassName, const uint32_t copyNb, const std::string &comment) override; void createLogicalLibrary(const common::dataStructures::SecurityIdentity &admin, const std::string &name, const bool isDisabled, const std::string &comment) override; void deleteLogicalLibrary(const std::string &name) override; @@ -818,13 +806,10 @@ protected: * Returns true if the specified storage class exists. * * @param conn The database connection. - * @param diskInstanceName The name of the disk instance to which the storage - * class belongs. * @param storageClassName The name of the storage class. * @return True if the storage class exists. */ - bool storageClassExists(rdbms::Conn &conn, const std::string &diskInstanceName, const std::string &storageClassName) - const; + bool storageClassExists(rdbms::Conn &conn, const std::string &storageClassName) const; /** * Returns true if the specified tape pool exists. @@ -899,14 +884,12 @@ protected: * Returns true if the specified archive route exists. * * @param conn The database connection. - * @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. * @return True if the archive route exists. */ - bool archiveRouteExists(rdbms::Conn &conn, const std::string &diskInstanceName, const std::string &storageClassName, + bool archiveRouteExists(rdbms::Conn &conn, const std::string &storageClassName, const uint32_t copyNb) const; /** @@ -918,14 +901,12 @@ protected: * given tape pool. * * @param conn The database connection. - * @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 tapePoolName The name of the tape pool. */ std::list<common::dataStructures::ArchiveRoute> getArchiveRoutes(rdbms::Conn &conn, - const std::string &diskInstanceName, const std::string &storageClassName, const std::string &tapePoolName) const; + const std::string &storageClassName, const std::string &tapePoolName) const; /** * Returns true if the specified tape exists. @@ -1166,10 +1147,6 @@ protected: * instance and the name of the storage class. */ struct StorageClass { - /** - * The name of the disk instance to which the storage class belongs. - */ - std::string diskInstanceName; /** * The name of the storage class which is only guaranteed to be unique @@ -1180,12 +1157,10 @@ protected: /** * Constructor. * - * @param dIN The name of the disk instance to which the storage class - * belongs. * @param sN The name of the storage class which is only guaranteed to be * unique within its disk instance. */ - StorageClass(const std::string &d, const std::string &s): diskInstanceName(d), storageClassName(s) { + StorageClass(const std::string &s): storageClassName(s) { } /** @@ -1196,7 +1171,7 @@ protected: * side of the operator. */ bool operator<(const StorageClass &rhs) const { - return diskInstanceName < rhs.diskInstanceName || storageClassName < rhs.storageClassName; + return storageClassName < rhs.storageClassName; } }; // struct StorageClass diff --git a/catalogue/common_catalogue_schema.sql b/catalogue/common_catalogue_schema.sql index 58ef3fde0303fe614ba6708d130efed907b79e75..e8d1107280abcd4b877b0f5bfad56345ee4cf970 100644 --- a/catalogue/common_catalogue_schema.sql +++ b/catalogue/common_catalogue_schema.sql @@ -45,7 +45,7 @@ CREATE TABLE STORAGE_CLASS( LAST_UPDATE_HOST_NAME VARCHAR(100) CONSTRAINT STORAGE_CLASS_LUHN_NN NOT NULL, LAST_UPDATE_TIME UINT64TYPE CONSTRAINT STORAGE_CLASS_LUT_NN NOT NULL, CONSTRAINT STORAGE_CLASS_PK PRIMARY KEY(STORAGE_CLASS_ID), - CONSTRAINT STORAGE_CLASS_DIN_SCN_UN UNIQUE(DISK_INSTANCE_NAME, STORAGE_CLASS_NAME) + CONSTRAINT STORAGE_CLASS_SCN_UN UNIQUE(STORAGE_CLASS_NAME) ); CREATE TABLE TAPE_POOL( TAPE_POOL_ID UINT64TYPE CONSTRAINT TAPE_POOL_TPI_NN NOT NULL, diff --git a/catalogue/migrations/liquibase/oracle/1.0to1.1.sql b/catalogue/migrations/liquibase/oracle/1.0to1.1.sql index 8783c3b57f3979697689198a1dfe4c25c3072a57..3369164426d2035a0c2330e012f9d97791452949 100644 --- a/catalogue/migrations/liquibase/oracle/1.0to1.1.sql +++ b/catalogue/migrations/liquibase/oracle/1.0to1.1.sql @@ -104,10 +104,25 @@ ADD ( --changeset ccaffy:14 failOnError:true dbms:oracle --preconditions onFail:HALT onError:HALT --precondition-sql-check expectedResult:"1.0" SELECT CONCAT(CONCAT(CAST(SCHEMA_VERSION_MAJOR as VARCHAR(10)),'.'), CAST(SCHEMA_VERSION_MINOR AS VARCHAR(10))) AS CATALOGUE_VERSION FROM CTA_CATALOGUE; +ALTER TABLE STORAGE_CLASS +DROP CONSTRAINT STORAGE_CLASS_DIN_SCN_UN; +--rollback ALTER TABLE STORAGE_CLASS ADD ( +--rollback CONSTRAINT STORAGE_CLASS_DIN_SCN_UN UNIQUE(DISK_INSTANCE_NAME, STORAGE_CLASS_NAME) +--rollback ); + +--changeset ccaffy:15 failOnError:true dbms:oracle +--preconditions onFail:HALT onError:HALT +--precondition-sql-check expectedResult:"1.0" SELECT CONCAT(CONCAT(CAST(SCHEMA_VERSION_MAJOR as VARCHAR(10)),'.'), CAST(SCHEMA_VERSION_MINOR AS VARCHAR(10))) AS CATALOGUE_VERSION FROM CTA_CATALOGUE; +ALTER TABLE STORAGE_CLASS ADD CONSTRAINT STORAGE_CLASS_SCN_UN UNIQUE(STORAGE_CLASS_NAME); +--rollback ALTER TABLE STORAGE_CLASS DROP CONSTRAINT STORAGE_CLASS_SCN_UN; + +--changeset ccaffy:16 failOnError:true dbms:oracle +--preconditions onFail:HALT onError:HALT +--precondition-sql-check expectedResult:"1.0" SELECT CONCAT(CONCAT(CAST(SCHEMA_VERSION_MAJOR as VARCHAR(10)),'.'), CAST(SCHEMA_VERSION_MINOR AS VARCHAR(10))) AS CATALOGUE_VERSION FROM CTA_CATALOGUE; UPDATE CTA_CATALOGUE SET SCHEMA_VERSION_MINOR=1; --rollback UPDATE CTA_CATALOGUE SET SCHEMA_VERSION_MINOR=0 ---changeset ccaffy:15 failOnError:true dbms:oracle +--changeset ccaffy:17 failOnError:true dbms:oracle --preconditions onFail:HALT onError:HALT --precondition-sql-check expectedResult:"1.1" SELECT CONCAT(CONCAT(CAST(SCHEMA_VERSION_MAJOR as VARCHAR(10)),'.'), CAST(SCHEMA_VERSION_MINOR AS VARCHAR(10))) AS CATALOGUE_VERSION FROM CTA_CATALOGUE; UPDATE CTA_CATALOGUE SET NEXT_SCHEMA_VERSION_MAJOR=NULL; diff --git a/common/dataStructures/ArchiveRoute.cpp b/common/dataStructures/ArchiveRoute.cpp index 9270d0eca3185c5fadc926bcc673dafb160b366b..09836ddafe5b16c9ad6ef6bc6ec065ef99996839 100644 --- a/common/dataStructures/ArchiveRoute.cpp +++ b/common/dataStructures/ArchiveRoute.cpp @@ -34,8 +34,7 @@ ArchiveRoute::ArchiveRoute(): // operator== //------------------------------------------------------------------------------ bool ArchiveRoute::operator==(const ArchiveRoute &rhs) const { - return diskInstanceName==rhs.diskInstanceName - && storageClassName==rhs.storageClassName + return storageClassName==rhs.storageClassName && copyNb==rhs.copyNb && tapePoolName==rhs.tapePoolName && creationLog==rhs.creationLog @@ -54,8 +53,7 @@ bool ArchiveRoute::operator!=(const ArchiveRoute &rhs) const { // operator<< //------------------------------------------------------------------------------ std::ostream &operator<<(std::ostream &os, const ArchiveRoute &obj) { - os << "(diskInstanceName=" << obj.diskInstanceName - << " storageClassName=" << obj.storageClassName + os << "(storageClassName=" << obj.storageClassName << " copyNb=" << obj.copyNb << " tapePoolName=" << obj.tapePoolName << " creationLog=" << obj.creationLog diff --git a/common/dataStructures/ArchiveRoute.hpp b/common/dataStructures/ArchiveRoute.hpp index 8a7a7be68d59a9b15c233d9dcf1592a0f6432b09..2bd6868dd6c2ea154f8c7b2359632b37bdc0a301 100644 --- a/common/dataStructures/ArchiveRoute.hpp +++ b/common/dataStructures/ArchiveRoute.hpp @@ -41,11 +41,6 @@ struct ArchiveRoute { bool operator!=(const ArchiveRoute &rhs) const; - /** - * The name of the disk instance to which the storage class belongs. - */ - std::string diskInstanceName; - /** * The name of the storage class which is only guranateed to be unique within * its disk instance. @@ -63,7 +58,7 @@ struct ArchiveRoute { std::string comment; typedef std::map<uint32_t, ArchiveRoute> StorageClassMap; - typedef std::map<std::tuple<std::string/*disk instance*/, std::string /*storage class*/>, StorageClassMap> FullMap; + typedef std::map<std::string /*storage class*/, StorageClassMap> FullMap; }; // struct ArchiveRoute diff --git a/scheduler/OStoreDB/OStoreDB.cpp b/scheduler/OStoreDB/OStoreDB.cpp index 0d9a4cdc90b10dc5f2da90518651e97680893271..53a02d0c0ad500918deeceba4977feab3c2a26bb 100644 --- a/scheduler/OStoreDB/OStoreDB.cpp +++ b/scheduler/OStoreDB/OStoreDB.cpp @@ -2374,7 +2374,7 @@ uint64_t OStoreDB::RepackRequest::addSubrequestsAndUpdateStats(std::list<Subrequ // Set the repack info. RetrieveRequest::RepackInfo rRRepackInfo; try { - for (auto & ar: archiveRoutesMap.at(std::make_tuple(rsr.archiveFile.diskInstance, rsr.archiveFile.storageClass))) { + for (auto & ar: archiveRoutesMap.at(rsr.archiveFile.storageClass)) { rRRepackInfo.archiveRouteMap[ar.second.copyNb] = ar.second.tapePoolName; } //Check that we do not have the same destination tapepool for two different copyNb @@ -2397,9 +2397,9 @@ uint64_t OStoreDB::RepackRequest::addSubrequestsAndUpdateStats(std::list<Subrequ std::stringstream storageClassList; bool first=true; for (auto & sc: archiveRoutesMap) { - std::string diskInstance, storageClass; - std::tie(diskInstance, storageClass) = sc.first; - storageClassList << (first?"":" ") << "di=" << diskInstance << " sc=" << storageClass << " rc=" << sc.second.size(); + std::string storageClass; + storageClass = sc.first; + storageClassList << (first?"":" ") << " sc=" << storageClass << " rc=" << sc.second.size(); } params.add("storageClassList", storageClassList.str()); lc.log(log::ERR, "In OStoreDB::RepackRequest::addSubrequests(): not such archive route."); diff --git a/scheduler/Scheduler.cpp b/scheduler/Scheduler.cpp index 78a373920639ac31e9bc6ddd6df34991ecb13c08..2f21cdb40d03458eaaea5707c656f44a593d8fd3 100644 --- a/scheduler/Scheduler.cpp +++ b/scheduler/Scheduler.cpp @@ -470,7 +470,7 @@ void Scheduler::expandRepackRequest(std::unique_ptr<RepackRequest>& repackReques cta::common::dataStructures::ArchiveRoute::FullMap archiveRoutesMap; for(auto route: routes){ //insert the route into the map to allow a quick retrieval - archiveRoutesMap[std::make_pair(route.diskInstanceName,route.storageClassName)][route.copyNb] = route; + archiveRoutesMap[route.storageClassName][route.copyNb] = route; } uint64_t fSeq; cta::SchedulerDatabase::RepackRequest::TotalStatsFiles totalStatsFile; @@ -548,7 +548,7 @@ void Scheduler::expandRepackRequest(std::unique_ptr<RepackRequest>& repackReques if(repackInfo.type == RepackType::AddCopiesOnly || repackInfo.type == RepackType::MoveAndAddCopies){ //We are in the case where we possibly need to create new copies (if the number of copies the storage class of the current ArchiveFile //is greater than the number of tape files we have in the current ArchiveFile) - auto archiveFileRoutes = archiveRoutesMap[std::make_pair(archiveFile.diskInstance,archiveFile.storageClass)]; + auto archiveFileRoutes = archiveRoutesMap[archiveFile.storageClass]; auto storageClassItor = std::find_if(storageClasses.begin(),storageClasses.end(),[&archiveFile](const common::dataStructures::StorageClass& sc){ return sc.name == archiveFile.storageClass; }); diff --git a/scheduler/SchedulerTest.cpp b/scheduler/SchedulerTest.cpp index b799b74a03c85b485bc99d42377f408e9d3bd983..7e42fcd5ff4134a8c2e518437cc05cc5087f8eb6 100644 --- a/scheduler/SchedulerTest.cpp +++ b/scheduler/SchedulerTest.cpp @@ -224,7 +224,7 @@ public: tapePoolComment); const uint32_t copyNb = 1; const std::string archiveRouteComment = "Archive-route comment"; - catalogue.createArchiveRoute(s_adminOnAdminHost, s_diskInstance, s_storageClassName, copyNb, s_tapePoolName, + catalogue.createArchiveRoute(s_adminOnAdminHost, s_storageClassName, copyNb, s_tapePoolName, archiveRouteComment); } @@ -3180,11 +3180,11 @@ TEST_P(SchedulerTest, expandRepackRequestAddCopiesOnly) { storageClass.name = s_storageClassName; storageClass.nbCopies = 3; storageClass.comment = "Create storage class"; - catalogue.modifyStorageClassNbCopies(admin,storageClass.diskInstance,storageClass.name,storageClass.nbCopies); + catalogue.modifyStorageClassNbCopies(admin,storageClass.name,storageClass.nbCopies); //Create the two archive routes for the new copies - catalogue.createArchiveRoute(admin,storageClass.diskInstance,storageClass.name,2,tapepool2Name,"ArchiveRoute2"); - catalogue.createArchiveRoute(admin,storageClass.diskInstance,storageClass.name,3,tapepool3Name,"ArchiveRoute3"); + catalogue.createArchiveRoute(admin,storageClass.name,2,tapepool2Name,"ArchiveRoute2"); + catalogue.createArchiveRoute(admin,storageClass.name,3,tapepool3Name,"ArchiveRoute3"); //Create two other destinationTape std::string vidDestination1 = "vidDestination1"; @@ -3422,11 +3422,11 @@ TEST_P(SchedulerTest, expandRepackRequestMoveAndAddCopies){ storageClass.name = s_storageClassName; storageClass.nbCopies = 3; storageClass.comment = "Create storage class"; - catalogue.modifyStorageClassNbCopies(admin,storageClass.diskInstance,storageClass.name,storageClass.nbCopies); + catalogue.modifyStorageClassNbCopies(admin,storageClass.name,storageClass.nbCopies); //Create the two archive routes for the new copies - catalogue.createArchiveRoute(admin,storageClass.diskInstance,storageClass.name,2,tapepool2Name,"ArchiveRoute2"); - catalogue.createArchiveRoute(admin,storageClass.diskInstance,storageClass.name,3,tapepool3Name,"ArchiveRoute3"); + catalogue.createArchiveRoute(admin,storageClass.name,2,tapepool2Name,"ArchiveRoute2"); + catalogue.createArchiveRoute(admin,storageClass.name,3,tapepool3Name,"ArchiveRoute3"); //Create two other destinationTape and one for the move workflow std::string vidDestination1 = "vidDestination1"; diff --git a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp index 8da9b7cf33549269734f569ec379bf84d436beb5..480e7324429bb6886b9441f4314efde3d41c1c8a 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp @@ -304,7 +304,7 @@ public: tapePoolSupply, tapePoolComment)); const uint32_t copyNb = 1; const std::string archiveRouteComment = "Archive-route comment"; - catalogue.createArchiveRoute(s_adminOnAdminHost, s_diskInstance, s_storageClassName, copyNb, s_tapePoolName, + catalogue.createArchiveRoute(s_adminOnAdminHost, s_storageClassName, copyNb, s_tapePoolName, archiveRouteComment); } diff --git a/xroot_plugins/XrdCtaArchiveRouteLs.hpp b/xroot_plugins/XrdCtaArchiveRouteLs.hpp index 3ae5e1e3ffa6096d7521dee72d5fc22c025eb6da..2965f8ba20ed147225a77f3df75c55a4d6c4d026 100644 --- a/xroot_plugins/XrdCtaArchiveRouteLs.hpp +++ b/xroot_plugins/XrdCtaArchiveRouteLs.hpp @@ -73,7 +73,6 @@ int ArchiveRouteLsStream::fillBuffer(XrdSsiPb::OStreamBuffer<Data> *streambuf) { auto &ar = m_archiveRouteList.front(); auto ar_item = record.mutable_arls_item(); - ar_item->set_instance(ar.diskInstanceName); ar_item->set_storage_class(ar.storageClassName); ar_item->set_copy_number(ar.copyNb); ar_item->set_tapepool(ar.tapePoolName); diff --git a/xroot_plugins/XrdSsiCtaRequestMessage.cpp b/xroot_plugins/XrdSsiCtaRequestMessage.cpp index 24247ca28e3b492f0ebe0c208c7c313ff43c19c3..26f631403d741846711bce71daaf51b1f3198feb 100644 --- a/xroot_plugins/XrdSsiCtaRequestMessage.cpp +++ b/xroot_plugins/XrdSsiCtaRequestMessage.cpp @@ -718,13 +718,12 @@ void RequestMessage::processArchiveRoute_Add(cta::xrd::Response &response) { using namespace cta::admin; - auto &in = getRequired(OptionString::INSTANCE); auto &scn = getRequired(OptionString::STORAGE_CLASS); auto &cn = getRequired(OptionUInt64::COPY_NUMBER); auto &tapepool = getRequired(OptionString::TAPE_POOL); auto &comment = getRequired(OptionString::COMMENT); - m_catalogue.createArchiveRoute(m_cliIdentity, in, scn, cn, tapepool, comment); + m_catalogue.createArchiveRoute(m_cliIdentity, scn, cn, tapepool, comment); response.set_type(cta::xrd::Response::RSP_SUCCESS); } @@ -735,17 +734,16 @@ void RequestMessage::processArchiveRoute_Ch(cta::xrd::Response &response) { using namespace cta::admin; - auto &in = getRequired(OptionString::INSTANCE); auto &scn = getRequired(OptionString::STORAGE_CLASS); auto &cn = getRequired(OptionUInt64::COPY_NUMBER); auto tapepool = getOptional(OptionString::TAPE_POOL); auto comment = getOptional(OptionString::COMMENT); if(comment) { - m_catalogue.modifyArchiveRouteComment(m_cliIdentity, in, scn, cn, comment.value()); + m_catalogue.modifyArchiveRouteComment(m_cliIdentity, scn, cn, comment.value()); } if(tapepool) { - m_catalogue.modifyArchiveRouteTapePoolName(m_cliIdentity, in, scn, cn, tapepool.value()); + m_catalogue.modifyArchiveRouteTapePoolName(m_cliIdentity, scn, cn, tapepool.value()); } response.set_type(cta::xrd::Response::RSP_SUCCESS); @@ -757,11 +755,10 @@ void RequestMessage::processArchiveRoute_Rm(cta::xrd::Response &response) { using namespace cta::admin; - auto &in = getRequired(OptionString::INSTANCE); auto &scn = getRequired(OptionString::STORAGE_CLASS); auto &cn = getRequired(OptionUInt64::COPY_NUMBER); - m_catalogue.deleteArchiveRoute(in, scn, cn); + m_catalogue.deleteArchiveRoute(scn, cn); response.set_type(cta::xrd::Response::RSP_SUCCESS); } @@ -1329,16 +1326,15 @@ void RequestMessage::processStorageClass_Ch(cta::xrd::Response &response) { using namespace cta::admin; - auto &in = getRequired(OptionString::INSTANCE); auto &scn = getRequired(OptionString::STORAGE_CLASS); auto comment = getOptional(OptionString::COMMENT); auto cn = getOptional(OptionUInt64::COPY_NUMBER); if(comment) { - m_catalogue.modifyStorageClassComment(m_cliIdentity, in, scn, comment.value()); + m_catalogue.modifyStorageClassComment(m_cliIdentity, scn, comment.value()); } if(cn) { - m_catalogue.modifyStorageClassNbCopies(m_cliIdentity, in, scn, cn.value()); + m_catalogue.modifyStorageClassNbCopies(m_cliIdentity, scn, cn.value()); } response.set_type(cta::xrd::Response::RSP_SUCCESS); @@ -1350,10 +1346,9 @@ void RequestMessage::processStorageClass_Rm(cta::xrd::Response &response) { using namespace cta::admin; - auto &in = getRequired(OptionString::INSTANCE); auto &scn = getRequired(OptionString::STORAGE_CLASS); - m_catalogue.deleteStorageClass(in, scn); + m_catalogue.deleteStorageClass(scn); response.set_type(cta::xrd::Response::RSP_SUCCESS); }