}
void
-RotatingFile::open(ManagerID) {
+RotatingFile::open() {
if (isOpen() || MultiThreadingMgr::instance().isTestMode()) {
return;
}
/// it is created. If the file is already open, the method simply
/// returns.
///
- /// @param id the forensic backend manager ID.
- ///
/// @throw LegalLogMgrError if the file cannot be opened.
- virtual void open(isc::dhcp::ManagerID id = 0);
+ virtual void open();
/// @brief Closes the underlying file.
///
timer_name_ += "]DbReconnectTimer";
}
-void MySqlStore::open(ManagerID id) {
+void MySqlStore::open() {
LegalLogDbLogger pushed(mysql_legal_log_db_logger);
// Test schema version first.
std::pair<uint32_t, uint32_t> code_version(MYSQL_SCHEMA_VERSION_MAJOR,
MYSQL_SCHEMA_VERSION_MINOR);
- LegalLogMgrPtr store = LegalLogMgrFactory::instance(id);
- LegalLogMgrFactory::instance(id).reset();
-
string timer_name;
bool retry = false;
if (LegalLogMgr::getParameters().count("retry-on-startup")) {
<< db_version.second);
}
- LegalLogMgrFactory::instance(id) = store;
-
// Create an initial context.
pool_.reset(new MySqlStoreContextPool());
pool_->pool_.push_back(createContext());
///
/// Finally, all the SQL commands are pre-compiled.
///
- /// @param id the forensic backend manager ID.
- ///
/// @throw isc::db::DbOpenError Error opening the database
/// @throw isc::db::DbOperationError An operation on the open
/// database has failed.
- virtual void open(ManagerID id = 0);
+ virtual void open();
/// @brief Closes the store.
virtual void close();
std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
params.emplace("retry-on-startup", "true");
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-
- // Check params validity is done by open().
- EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+ ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
// Verify there is no instance.
ASSERT_FALSE(LegalLogMgrFactory::instance());
std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
params.emplace("retry-on-startup", "true");
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-
- // Check params validity is done by open().
- EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+ ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
// Verify there is no instance.
ASSERT_FALSE(LegalLogMgrFactory::instance());
std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
params.emplace("retry-on-startup", "true");
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-
- // Check params validity is done by open().
- EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+ ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
// Verify there is no instance.
ASSERT_FALSE(LegalLogMgrFactory::instance());
std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
params.emplace("retry-on-startup", "true");
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-
- // Check params validity is done by open().
- EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+ ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
// Verify there is no instance.
ASSERT_FALSE(LegalLogMgrFactory::instance());
// Verify that a MySqlStore with no database name is rejected.
DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(invalidConnectString());
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-
- // Check params validity is done by open().
- EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenError);
+ ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenError);
io_service_->poll();
// Verify that a MySqlStore with database name is not rejected.
DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(validConnectString());
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
- LegalLogMgrFactory::setParameters(params);
-
- // Check params validity is done by open().
- EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+ ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
ASSERT_TRUE(LegalLogMgrFactory::instance());
// Verify that a MySqlStore with database name is not rejected.
DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(validConnectString());
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-
- // Check params validity is done by open().
- EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+ ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
ASSERT_TRUE(LegalLogMgrFactory::instance());
// Verify that a MySqlStore with database name is not rejected.
DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(access);
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
- LegalLogMgrFactory::setParameters(params);
-
- // Check params validity is done by open().
- EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+ ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
ASSERT_TRUE(LegalLogMgrFactory::instance());
// Verify that a MySqlStore with database name is not rejected.
DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(access);
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-
- // Check params validity is done by open().
- EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+ ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
ASSERT_TRUE(LegalLogMgrFactory::instance());
timer_name_ += "]DbReconnectTimer";
}
-void PgSqlStore::open(ManagerID id) {
+void PgSqlStore::open() {
LegalLogDbLogger pushed(pgsql_legal_log_db_logger);
// Check TLS support.
pair<uint32_t, uint32_t> code_version(PGSQL_SCHEMA_VERSION_MAJOR,
PGSQL_SCHEMA_VERSION_MINOR);
- LegalLogMgrPtr store = LegalLogMgrFactory::instance(id);
- LegalLogMgrFactory::instance(id).reset();
-
string timer_name;
bool retry = false;
if (LegalLogMgr::getParameters().count("retry-on-startup")) {
<< db_version.second);
}
- LegalLogMgrFactory::instance(id) = store;
-
// Create an initial context.
pool_.reset(new PgSqlStoreContextPool());
pool_->pool_.push_back(createContext());
///
/// Finally, all the SQL commands are pre-compiled.
///
- /// @param id the forensic backend manager ID.
- ///
/// @throw isc::db::DbOpenError Error opening the database
/// @throw isc::db::DbOperationError An operation on the open
/// database has failed.
- virtual void open(ManagerID id = 0);
+ virtual void open();
/// @brief Closes the store.
virtual void close();
std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
params.emplace("retry-on-startup", "true");
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-
- // Check params validity is done by open().
- EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+ ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
// Verify there is no instance.
ASSERT_FALSE(LegalLogMgrFactory::instance());
std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
params.emplace("retry-on-startup", "true");
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-
- // Check params validity is done by open().
- EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+ ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
// Verify there is no instance.
ASSERT_FALSE(LegalLogMgrFactory::instance());
std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
params.emplace("retry-on-startup", "true");
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-
- // Check params validity is done by open().
- EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+ ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
// Verify there is no instance.
ASSERT_FALSE(LegalLogMgrFactory::instance());
std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
params.emplace("retry-on-startup", "true");
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-
- // Check params validity is done by open().
- EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+ ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
// Verify there is no instance.
ASSERT_FALSE(LegalLogMgrFactory::instance());
// Verify that a PgSqlStore with no database name is rejected.
DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(invalidConnectString());
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-
- // Check params validity is done by open().
- EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenError);
+ ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenError);
io_service_->poll();
// Verify that a PgSqlStore with database name is not rejected.
DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(validConnectString());
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
- LegalLogMgrFactory::setParameters(params);
-
- // Check params validity is done by open().
- EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+ ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
ASSERT_TRUE(LegalLogMgrFactory::instance());
// Verify that a PgSqlStore with database name is not rejected.
DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(validConnectString());
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-
- // Check params validity is done by open().
- EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+ ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
ASSERT_TRUE(LegalLogMgrFactory::instance());
// Verify that a PgSqlStore with database name is not rejected.
DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(access);
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
- LegalLogMgrFactory::setParameters(params);
-
- // Check params validity is done by open().
- EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+ ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
ASSERT_TRUE(LegalLogMgrFactory::instance());
// Verify that a PgSqlStore with database name is not rejected.
DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(access);
- ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-
- // Check params validity is done by open().
- EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+ ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
ASSERT_TRUE(LegalLogMgrFactory::instance());
/// @brief Defines a smart pointer to a LegalLogMgr.
typedef boost::shared_ptr<LegalLogMgr> LegalLogMgrPtr;
-/// @brief Manger ID used by hook libraries to retrieve respective LegalLogMgr instance.
-typedef uint64_t ManagerID;
-
/// @brief LegalLogMgr abstract class
class LegalLogMgr {
public:
static void parseExtraParameters(const isc::data::ConstElementPtr& parameters, isc::db::DatabaseConnection::ParameterMap& map);
/// @brief Opens the store.
- ///
- /// @param id the forensic backend manager ID.
- virtual void open(ManagerID id = 0) = 0;
+ virtual void open() = 0;
/// @brief Closes the store.
virtual void close() = 0;
isc::db::DatabaseConnection::ParameterMap parameters_;
};
+/// @brief Manger ID used by hook libraries to retrieve respective LegalLogMgr instance.
+typedef uint64_t ManagerID;
+
/// @brief LegalLogMgr pool
typedef std::map<ManagerID, std::pair<isc::db::DatabaseConnection::ParameterMap, LegalLogMgrPtr>> LegalLogMgrPool;
// Add the parameters and an empty instance in case retry on startup is configured.
pool_[id] = pair<DatabaseConnection::ParameterMap, LegalLogMgrPtr>(parameters, LegalLogMgrPtr());
- backend->open(id);
+ backend->open();
// Apply extra parameters.
if (parameters.find("request-parser-format") != parameters.end()) {
}
/// @brief Opens the store.
- virtual void open(ManagerID) {
+ virtual void open() {
}
/// @brief Closes the store.