diff --git a/catalogue/CMakeLists.txt b/catalogue/CMakeLists.txt index a29d311794946562ac2315c9d5d1fdf41f60cf33..2a15d56567f0d60c40ab7fd6725da2f67bcabfd0 100644 --- a/catalogue/CMakeLists.txt +++ b/catalogue/CMakeLists.txt @@ -54,7 +54,6 @@ set (CATALOGUE_LIB_SRC_FILES RdbmsCatalogueGetDeletedArchiveFilesItor.cpp SchemaCreatingSqliteCatalogue.cpp SqliteCatalogue.cpp - SqliteCatalogueFactory.cpp SchemaVersion.cpp TapeForWriting.cpp ) diff --git a/catalogue/CatalogueFactoryFactory.cpp b/catalogue/CatalogueFactoryFactory.cpp index 69c885444c37ad1187218342510d94876a0cf752..72e7f4752bad3101cdf723cb64e6eba20b00e9e3 100644 --- a/catalogue/CatalogueFactoryFactory.cpp +++ b/catalogue/CatalogueFactoryFactory.cpp @@ -21,7 +21,6 @@ #include "catalogue/MysqlCatalogueFactory.hpp" #include "catalogue/OracleCatalogueFactory.hpp" #include "catalogue/PostgresqlCatalogueFactory.hpp" -#include "catalogue/SqliteCatalogueFactory.hpp" #include "common/make_unique.hpp" namespace cta { @@ -48,7 +47,7 @@ std::unique_ptr<CatalogueFactory> CatalogueFactoryFactory::create( case rdbms::Login::DBTYPE_POSTGRESQL: return cta::make_unique<PostgresqlCatalogueFactory>(log, login, nbConns, nbArchiveFileListingConns, maxTriesToConnect); case rdbms::Login::DBTYPE_SQLITE: - return cta::make_unique<SqliteCatalogueFactory>(log, login, nbConns, nbArchiveFileListingConns, maxTriesToConnect); + throw exception::Exception("Sqlite file based databases are not supported"); case rdbms::Login::DBTYPE_NONE: throw exception::Exception("Cannot create a catalogue without a database type"); default: diff --git a/catalogue/CreateSchemaCmd.cpp b/catalogue/CreateSchemaCmd.cpp index cce077a13e0da7b5b571d7799062e9891276e636..16a740986b98b320d1bb03741aaab4410e9295a4 100644 --- a/catalogue/CreateSchemaCmd.cpp +++ b/catalogue/CreateSchemaCmd.cpp @@ -69,12 +69,11 @@ int CreateSchemaCmd::exceptionThrowingMain(const int argc, char *const *const ar switch(login.dbType) { case rdbms::Login::DBTYPE_IN_MEMORY: + std::cerr << "Creating the database schema for an in_memory database is not supported" << std::endl; + return 1; case rdbms::Login::DBTYPE_SQLITE: - { - SqliteCatalogueSchema schema; - executeNonQueries(conn, schema.sql); - } - break; + std::cerr << "Creating the database schema for an sqlite database is not supported" << std::endl; + return 1; case rdbms::Login::DBTYPE_POSTGRESQL: { PostgresCatalogueSchema schema; diff --git a/catalogue/DropSchemaCmd.cpp b/catalogue/DropSchemaCmd.cpp index 584cae2f90858824250d304d6c6661dcc1a8c359..741bb6b7dfa1ce3a9635de55749b1bba02338014 100644 --- a/catalogue/DropSchemaCmd.cpp +++ b/catalogue/DropSchemaCmd.cpp @@ -18,9 +18,9 @@ #include "catalogue/DropSchemaCmd.hpp" #include "catalogue/DropSchemaCmdLineArgs.hpp" +#include "catalogue/SchemaChecker.hpp" #include "common/exception/Exception.hpp" #include "rdbms/ConnPool.hpp" -#include "catalogue/SchemaChecker.hpp" #include <algorithm> @@ -107,9 +107,9 @@ void DropSchemaCmd::dropCatalogueSchema(const rdbms::Login::DbType &dbType, rdbm try { switch(dbType) { case rdbms::Login::DBTYPE_IN_MEMORY: + throw exception::Exception("Dropping the schema of an in_memory database is not supported"); case rdbms::Login::DBTYPE_SQLITE: - dropSqliteCatalogueSchema(conn); - break; + throw exception::Exception("Dropping the schema of an sqlite database is not supported"); case rdbms::Login::DBTYPE_MYSQL: dropMysqlCatalogueSchema(conn); break; @@ -120,7 +120,7 @@ void DropSchemaCmd::dropCatalogueSchema(const rdbms::Login::DbType &dbType, rdbm dropOracleCatalogueSchema(conn); break; case rdbms::Login::DBTYPE_NONE: - throw exception::Exception("Cannot delete the schema of catalogue database without a database type"); + throw exception::Exception("Cannot delete the schema of catalogue database without a database type"); default: { exception::Exception ex; @@ -133,49 +133,6 @@ void DropSchemaCmd::dropCatalogueSchema(const rdbms::Login::DbType &dbType, rdbm } } -//------------------------------------------------------------------------------ -// dropSqliteCatalogueSchema -//------------------------------------------------------------------------------ -void DropSchemaCmd::dropSqliteCatalogueSchema(rdbms::Conn &conn) { - try { - std::list<std::string> tablesInDb = conn.getTableNames(); - std::list<std::string> tablesToDrop = { - "CTA_CATALOGUE", - "ARCHIVE_ROUTE", - "TAPE_FILE", - "TEMP_TAPE_FILE", - "DATABASECHANGELOGLOCK", /* Liquibase specific table */ - "DATABASECHANGELOG", /* Liquibase specific table */ - "TAPE_FILE_RECYCLE_BIN", - "ARCHIVE_FILE_RECYCLE_BIN", - "ARCHIVE_FILE", - "ARCHIVE_FILE_ID", - "TAPE", - "MEDIA_TYPE", - "MEDIA_TYPE_ID", - "REQUESTER_MOUNT_RULE", - "REQUESTER_GROUP_MOUNT_RULE", - "ADMIN_USER", - "STORAGE_CLASS", - "STORAGE_CLASS_ID", - "TAPE_POOL", - "TAPE_POOL_ID", - "VIRTUAL_ORGANIZATION", - "VIRTUAL_ORGANIZATION_ID", - "LOGICAL_LIBRARY", - "LOGICAL_LIBRARY_ID", - "MOUNT_POLICY", - "ACTIVITIES_WEIGHTS", - "USAGESTATS", - "EXPERIMENTS", - "DISK_SYSTEM" - }; - dropDatabaseTables(conn, tablesToDrop); - } catch(exception::Exception &ex) { - throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - } -} - //------------------------------------------------------------------------------ // dropMysqlCatalogueSchema //------------------------------------------------------------------------------ @@ -373,7 +330,9 @@ bool DropSchemaCmd::isProductionSet(cta::rdbms::Conn & conn){ throw cta::exception::Exception("Cannot check the IS_PRODUCTION bit because the CTA_CATALOGUE table is empty or does not exist."); } - +//------------------------------------------------------------------------------ +// isProductionProtectionCheckable +//------------------------------------------------------------------------------ bool DropSchemaCmd::isProductionProtectionCheckable(rdbms::Conn& conn, const cta::rdbms::Login::DbType dbType) { cta::catalogue::SchemaChecker::Builder builder("catalogue",dbType,conn); auto checker = builder.build(); diff --git a/catalogue/SqliteCatalogueFactory.cpp b/catalogue/SqliteCatalogueFactory.cpp deleted file mode 100644 index bbd4d1c98fb005b7b37b6d387d1d9f9cd239326a..0000000000000000000000000000000000000000 --- a/catalogue/SqliteCatalogueFactory.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The CERN Tape Archive (CTA) project - * Copyright (C) 2015 CERN - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "catalogue/CatalogueRetryWrapper.hpp" -#include "catalogue/SqliteCatalogueFactory.hpp" -#include "catalogue/SqliteCatalogue.hpp" -#include "common/exception/Exception.hpp" -#include "common/make_unique.hpp" - -namespace cta { -namespace catalogue { - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -SqliteCatalogueFactory::SqliteCatalogueFactory( - log::Logger &log, - const rdbms::Login &login, - const uint64_t nbConns, - const uint64_t nbArchiveFileListingConns, - const uint32_t maxTriesToConnect): - m_log(log), - m_login(login), - m_nbConns(nbConns), - m_nbArchiveFileListingConns(nbArchiveFileListingConns), - m_maxTriesToConnect(maxTriesToConnect) { - if(rdbms::Login::DBTYPE_SQLITE != login.dbType) { - exception::Exception ex; - ex.getMessage() << __FUNCTION__ << "failed: Incorrect database type: expected=DBTYPE_SQLITE actual=" << - login.dbTypeToString(login.dbType); - throw ex; - } -} - -//------------------------------------------------------------------------------ -// create -//------------------------------------------------------------------------------ -std::unique_ptr<Catalogue> SqliteCatalogueFactory::create() { - try { - auto c = cta::make_unique<SqliteCatalogue>(m_log, m_login.database, m_nbConns, m_nbArchiveFileListingConns); - return cta::make_unique<CatalogueRetryWrapper>(m_log, std::move(c), m_maxTriesToConnect); - } catch(exception::Exception &ex) { - throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - } -} - -} // namespace catalogue -} // namespace cta diff --git a/catalogue/SqliteCatalogueFactory.hpp b/catalogue/SqliteCatalogueFactory.hpp deleted file mode 100644 index 18b92d7506b145e9a01238a7006e327cef738845..0000000000000000000000000000000000000000 --- a/catalogue/SqliteCatalogueFactory.hpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * The CERN Tape Archive (CTA) project - * Copyright (C) 2015 CERN - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include "catalogue/CatalogueFactory.hpp" -#include "rdbms/Login.hpp" - -namespace cta { -namespace catalogue { - -/** - * Factory of Catalogue objects. - */ -class SqliteCatalogueFactory: public CatalogueFactory { -public: - - /** - * Constructor - * - * @param log Object representing the API to the CTA logging system. - * @param login The database login details to be used to create new - * connections. - * @param nbConns The maximum number of concurrent connections to the - * underlying relational database for all operations accept listing archive - * files which can be relatively long operations. - * @param nbArchiveFileListingConns The maximum number of concurrent - * connections to the underlying relational database for the sole purpose of - * listing archive files. - * @param maxTriesToConnext The maximum number of times a single method should - * try to connect to the database in the event of LostDatabaseConnection - * exceptions being thrown. - */ - SqliteCatalogueFactory( - log::Logger &log, - const rdbms::Login &login, - const uint64_t nbConns, - const uint64_t nbArchiveFileListingConns, - const uint32_t maxTriesToConnect); - - /** - * Returns a newly created CTA catalogue object. - */ - std::unique_ptr<Catalogue> create() override; - -private: - - /** - * Object representing the API to the CTA logging system. - */ - log::Logger &m_log; - - /** - * The database login details to be used to create new connections. - */ - rdbms::Login m_login; - - /** - * The maximum number of concurrent connections to the underlying relational - * database for all operations accept listing archive files which can be - * relatively long operations. - */ - uint64_t m_nbConns; - - /** - * The maximum number of concurrent connections to the underlying relational - * database for the sole purpose of listing archive files. - */ - uint64_t m_nbArchiveFileListingConns; - - /** - * The maximum number of times a single method should try to connect to the - * database in the event of LostDatabaseConnection - * exceptions being thrown. - */ - uint32_t m_maxTriesToConnect; - -}; // class SqliteCatalogueFactory - -} // namespace catalogue -} // namespace cta