Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
46a17f53
Commit
46a17f53
authored
Jul 11, 2017
by
Steven Murray
Browse files
Logger passed through to Catalogue constructor
parent
0fb7666f
Changes
27
Hide whitespace changes
Inline
Side-by-side
catalogue/Catalogue.cpp
View file @
46a17f53
...
...
@@ -21,6 +21,12 @@
namespace
cta
{
namespace
catalogue
{
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
Catalogue
::
Catalogue
(
log
::
Logger
&
log
)
:
m_log
(
log
)
{
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
...
...
catalogue/Catalogue.hpp
View file @
46a17f53
...
...
@@ -59,6 +59,7 @@
#include
"common/dataStructures/VidToTapeMap.hpp"
#include
"common/dataStructures/WriteTestResult.hpp"
#include
"common/exception/UserError.hpp"
#include
"common/log/Logger.hpp"
#include
<list>
#include
<map>
...
...
@@ -76,6 +77,12 @@ namespace catalogue {
*/
class
Catalogue
{
public:
/**
* Constructor.
*
* @param log Object representing the API to the CTA logging system.
*/
Catalogue
(
log
::
Logger
&
log
);
/**
* Destructor.
...
...
@@ -528,6 +535,13 @@ public:
*/
virtual
bool
tapeExists
(
const
std
::
string
&
vid
)
const
=
0
;
private:
/**
* Object representing the API to the CTA logging system.
*/
log
::
Logger
&
m_log
;
};
// class Catalogue
}
// namespace catalogue
...
...
catalogue/CatalogueFactory.cpp
View file @
46a17f53
...
...
@@ -29,17 +29,20 @@ namespace catalogue {
//------------------------------------------------------------------------------
// create
//------------------------------------------------------------------------------
std
::
unique_ptr
<
Catalogue
>
CatalogueFactory
::
create
(
const
rdbms
::
Login
&
login
,
const
uint64_t
nbConns
,
std
::
unique_ptr
<
Catalogue
>
CatalogueFactory
::
create
(
log
::
Logger
&
log
,
const
rdbms
::
Login
&
login
,
const
uint64_t
nbConns
,
const
uint64_t
nbArchiveFileListingConns
)
{
try
{
switch
(
login
.
dbType
)
{
case
rdbms
::
Login
::
DBTYPE_IN_MEMORY
:
return
cta
::
make_unique
<
InMemoryCatalogue
>
(
nbConns
,
nbArchiveFileListingConns
);
return
cta
::
make_unique
<
InMemoryCatalogue
>
(
log
,
nbConns
,
nbArchiveFileListingConns
);
case
rdbms
::
Login
::
DBTYPE_ORACLE
:
return
cta
::
make_unique
<
OracleCatalogue
>
(
login
.
username
,
login
.
password
,
login
.
database
,
nbConns
,
return
cta
::
make_unique
<
OracleCatalogue
>
(
log
,
login
.
username
,
login
.
password
,
login
.
database
,
nbConns
,
nbArchiveFileListingConns
);
case
rdbms
::
Login
::
DBTYPE_SQLITE
:
return
cta
::
make_unique
<
SqliteCatalogue
>
(
login
.
database
,
nbConns
,
nbArchiveFileListingConns
);
return
cta
::
make_unique
<
SqliteCatalogue
>
(
log
,
login
.
database
,
nbConns
,
nbArchiveFileListingConns
);
case
rdbms
::
Login
::
DBTYPE_NONE
:
throw
exception
::
Exception
(
"Cannot create a catalogue without a database type"
);
default:
...
...
catalogue/CatalogueFactory.hpp
View file @
46a17f53
...
...
@@ -41,6 +41,7 @@ public:
/**
* Creates a CTA catalogue object using the specified database login details.
*
* @param log Object representing the API to the CTA logging system.
* @param login The database connection details.
* @param nbConns The maximum number of concurrent connections to the
* underlying relational database for all operations accept listing archive
...
...
@@ -51,7 +52,10 @@ public:
* @return The newly created CTA catalogue object. Please note that it is the
* responsibility of the caller to delete the returned CTA catalogue object.
*/
static
std
::
unique_ptr
<
Catalogue
>
create
(
const
rdbms
::
Login
&
login
,
const
uint64_t
nbConns
,
static
std
::
unique_ptr
<
Catalogue
>
create
(
log
::
Logger
&
log
,
const
rdbms
::
Login
&
login
,
const
uint64_t
nbConns
,
const
uint64_t
nbArchiveFileListingConns
);
};
// class CatalogueFactory
...
...
catalogue/CatalogueFactoryTest.cpp
View file @
46a17f53
...
...
@@ -19,6 +19,7 @@
#include
"catalogue/ArchiveFileRow.hpp"
#include
"catalogue/CatalogueFactory.hpp"
#include
"common/exception/Exception.hpp"
#include
"common/log/DummyLogger.hpp"
#include
<gtest/gtest.h>
#include
<memory>
...
...
@@ -27,7 +28,8 @@ namespace unitTests {
class
cta_catalogue_CatalogueFactoryTest
:
public
::
testing
::
Test
{
public:
cta_catalogue_CatalogueFactoryTest
()
{
cta_catalogue_CatalogueFactoryTest
()
:
m_dummyLog
(
"dummy"
)
{
m_localAdmin
.
username
=
"local_admin_user"
;
m_localAdmin
.
host
=
"local_admin_host"
;
...
...
@@ -43,6 +45,7 @@ protected:
virtual
void
TearDown
()
{
}
cta
::
log
::
DummyLogger
m_dummyLog
;
cta
::
common
::
dataStructures
::
SecurityIdentity
m_localAdmin
;
cta
::
common
::
dataStructures
::
SecurityIdentity
m_admin
;
};
...
...
@@ -54,7 +57,7 @@ TEST_F(cta_catalogue_CatalogueFactoryTest, instance_in_memory) {
rdbms
::
Login
login
(
rdbms
::
Login
::
DBTYPE_IN_MEMORY
,
""
,
""
,
""
);
const
uint64_t
nbConns
=
1
;
const
uint64_t
nbArchiveFileListingConns
=
1
;
std
::
unique_ptr
<
Catalogue
>
catalogue
(
CatalogueFactory
::
create
(
login
,
nbConns
,
nbArchiveFileListingConns
));
std
::
unique_ptr
<
Catalogue
>
catalogue
(
CatalogueFactory
::
create
(
m_dummyLog
,
login
,
nbConns
,
nbArchiveFileListingConns
));
ASSERT_TRUE
(
nullptr
!=
catalogue
.
get
());
ASSERT_TRUE
(
catalogue
->
getAdminUsers
().
empty
());
...
...
catalogue/CatalogueTest.cpp
View file @
46a17f53
...
...
@@ -35,7 +35,8 @@ namespace unitTests {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta_catalogue_CatalogueTest
::
cta_catalogue_CatalogueTest
()
{
cta_catalogue_CatalogueTest
::
cta_catalogue_CatalogueTest
()
:
m_dummyLog
(
"dummy"
)
{
m_localAdmin
.
username
=
"local_admin_user"
;
m_localAdmin
.
host
=
"local_admin_host"
;
...
...
@@ -56,7 +57,7 @@ void cta_catalogue_CatalogueTest::SetUp() {
const
uint64_t
nbConns
=
2
;
const
uint64_t
nbArchiveFileListingConns
=
2
;
m_catalogue
=
CatalogueFactory
::
create
(
login
,
nbConns
,
nbArchiveFileListingConns
);
m_catalogue
=
CatalogueFactory
::
create
(
m_dummyLog
,
login
,
nbConns
,
nbArchiveFileListingConns
);
m_conn
=
connFactory
->
create
();
{
...
...
catalogue/CatalogueTest.hpp
View file @
46a17f53
...
...
@@ -21,6 +21,7 @@
#include
"catalogue/ArchiveFileRow.hpp"
#include
"catalogue/CatalogueFactory.hpp"
#include
"common/exception/Exception.hpp"
#include
"common/log/DummyLogger.hpp"
#include
"rdbms/Conn.hpp"
#include
"rdbms/LoginFactory.hpp"
...
...
@@ -38,6 +39,7 @@ public:
protected:
cta
::
log
::
DummyLogger
m_dummyLog
;
std
::
unique_ptr
<
cta
::
catalogue
::
Catalogue
>
m_catalogue
;
cta
::
common
::
dataStructures
::
SecurityIdentity
m_localAdmin
;
cta
::
common
::
dataStructures
::
SecurityIdentity
m_admin
;
...
...
catalogue/CreateAdminHostCmd.cpp
View file @
46a17f53
...
...
@@ -20,6 +20,7 @@
#include
"catalogue/CreateAdminHostCmd.hpp"
#include
"catalogue/CreateAdminHostCmdLineArgs.hpp"
#include
"common/exception/Exception.hpp"
#include
"common/log/DummyLogger.hpp"
#include
"rdbms/ConnFactoryFactory.hpp"
namespace
cta
{
...
...
@@ -55,7 +56,8 @@ int CreateAdminHostCmd::exceptionThrowingMain(const int argc, char *const *const
const
rdbms
::
Login
dbLogin
=
rdbms
::
Login
::
parseFile
(
cmdLineArgs
.
dbConfigPath
);
const
uint64_t
nbDbConns
=
1
;
const
uint64_t
nbArchiveFileListingDbConns
=
0
;
auto
catalogue
=
CatalogueFactory
::
create
(
dbLogin
,
nbDbConns
,
nbArchiveFileListingDbConns
);
log
::
DummyLogger
dummyLog
(
"dummy"
);
auto
catalogue
=
CatalogueFactory
::
create
(
dummyLog
,
dbLogin
,
nbDbConns
,
nbArchiveFileListingDbConns
);
const
common
::
dataStructures
::
SecurityIdentity
adminRunningCommand
(
getUsername
(),
getHostname
());
catalogue
->
createAdminHost
(
adminRunningCommand
,
cmdLineArgs
.
adminHostname
,
cmdLineArgs
.
comment
);
...
...
catalogue/CreateAdminUserCmd.cpp
View file @
46a17f53
...
...
@@ -20,6 +20,7 @@
#include
"catalogue/CreateAdminUserCmd.hpp"
#include
"catalogue/CreateAdminUserCmdLineArgs.hpp"
#include
"common/exception/Exception.hpp"
#include
"common/log/DummyLogger.hpp"
#include
"rdbms/ConnFactoryFactory.hpp"
namespace
cta
{
...
...
@@ -55,7 +56,8 @@ int CreateAdminUserCmd::exceptionThrowingMain(const int argc, char *const *const
const
rdbms
::
Login
dbLogin
=
rdbms
::
Login
::
parseFile
(
cmdLineArgs
.
dbConfigPath
);
const
uint64_t
nbDbConns
=
1
;
const
uint64_t
nbArchiveFileListingDbConns
=
1
;
auto
catalogue
=
CatalogueFactory
::
create
(
dbLogin
,
nbDbConns
,
nbArchiveFileListingDbConns
);
log
::
DummyLogger
dummyLog
(
"dummy"
);
auto
catalogue
=
CatalogueFactory
::
create
(
dummyLog
,
dbLogin
,
nbDbConns
,
nbArchiveFileListingDbConns
);
const
common
::
dataStructures
::
SecurityIdentity
adminRunningCommand
(
getUsername
(),
getHostname
());
catalogue
->
createAdminUser
(
adminRunningCommand
,
cmdLineArgs
.
adminUsername
,
cmdLineArgs
.
comment
);
...
...
catalogue/InMemoryCatalogue.cpp
View file @
46a17f53
...
...
@@ -27,8 +27,11 @@ namespace catalogue {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
InMemoryCatalogue
::
InMemoryCatalogue
(
const
uint64_t
nbConns
,
const
uint64_t
nbArchiveFileListingConns
)
:
SchemaCreatingSqliteCatalogue
(
"file::memory:?cache=shared"
,
nbConns
,
nbArchiveFileListingConns
)
{
InMemoryCatalogue
::
InMemoryCatalogue
(
log
::
Logger
&
log
,
const
uint64_t
nbConns
,
const
uint64_t
nbArchiveFileListingConns
)
:
SchemaCreatingSqliteCatalogue
(
log
,
"file::memory:?cache=shared"
,
nbConns
,
nbArchiveFileListingConns
)
{
}
//------------------------------------------------------------------------------
...
...
catalogue/InMemoryCatalogue.hpp
View file @
46a17f53
...
...
@@ -34,6 +34,7 @@ public:
/**
* Constructor.
*
* @param log Object representing the API to the CTA logging system.
* @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.
...
...
@@ -41,7 +42,10 @@ public:
* connections to the underlying relational database for the sole purpose of
* listing archive files.
*/
InMemoryCatalogue
(
const
uint64_t
nbConns
,
const
uint64_t
nbArchiveFileListingConns
);
InMemoryCatalogue
(
log
::
Logger
&
log
,
const
uint64_t
nbConns
,
const
uint64_t
nbArchiveFileListingConns
);
/**
* Destructor.
...
...
catalogue/OracleCatalogue.cpp
View file @
46a17f53
...
...
@@ -36,14 +36,17 @@ namespace catalogue {
// constructor
//------------------------------------------------------------------------------
OracleCatalogue
::
OracleCatalogue
(
log
::
Logger
&
log
,
const
std
::
string
&
username
,
const
std
::
string
&
password
,
const
std
::
string
&
database
,
const
uint64_t
nbConns
,
const
uint64_t
nbArchiveFileListingConns
)
:
RdbmsCatalogue
(
log
,
rdbms
::
ConnFactoryFactory
::
create
(
rdbms
::
Login
(
rdbms
::
Login
::
DBTYPE_ORACLE
,
username
,
password
,
database
)),
nbConns
,
nbArchiveFileListingConns
)
{
nbConns
,
nbArchiveFileListingConns
)
{
}
...
...
catalogue/OracleCatalogue.hpp
View file @
46a17f53
...
...
@@ -39,6 +39,7 @@ public:
/**
* Constructor.
*
* @param log Object representing the API to the CTA logging system.
* @param username The database username.
* @param password The database password.
* @param database The database name.
...
...
@@ -50,6 +51,7 @@ public:
* listing archive files.
*/
OracleCatalogue
(
log
::
Logger
&
log
,
const
std
::
string
&
username
,
const
std
::
string
&
password
,
const
std
::
string
&
database
,
...
...
catalogue/RdbmsCatalogue.cpp
View file @
46a17f53
...
...
@@ -39,9 +39,11 @@ namespace catalogue {
// constructor
//------------------------------------------------------------------------------
RdbmsCatalogue
::
RdbmsCatalogue
(
log
::
Logger
&
log
,
std
::
unique_ptr
<
rdbms
::
ConnFactory
>
connFactory
,
const
uint64_t
nbConns
,
const
uint64_t
nbArchiveFileListingConns
)
:
Catalogue
(
log
),
m_connFactory
(
std
::
move
(
connFactory
)),
m_connPool
(
*
m_connFactory
,
nbConns
),
m_archiveFileListingConnPool
(
*
m_connFactory
,
nbArchiveFileListingConns
)
{
...
...
catalogue/RdbmsCatalogue.hpp
View file @
46a17f53
...
...
@@ -61,6 +61,7 @@ protected:
/**
* Protected constructor only to be called by sub-classes.
*
* @param log Object representing the API to the CTA logging system.
* @param connFactory The factory for creating new database connections.
* @param nbConns The maximum number of concurrent connections to the
* underlying relational database for all operations accept listing archive
...
...
@@ -69,7 +70,10 @@ protected:
* connections to the underlying relational database for the sole purpose of
* listing archive files.
*/
RdbmsCatalogue
(
std
::
unique_ptr
<
rdbms
::
ConnFactory
>
connFactory
,
const
uint64_t
nbConns
,
RdbmsCatalogue
(
log
::
Logger
&
log
,
std
::
unique_ptr
<
rdbms
::
ConnFactory
>
connFactory
,
const
uint64_t
nbConns
,
const
uint64_t
nbArchiveFileListingConns
);
public:
...
...
catalogue/SchemaCreatingSqliteCatalogue.cpp
View file @
46a17f53
...
...
@@ -28,10 +28,11 @@ namespace catalogue {
// constructor
//------------------------------------------------------------------------------
SchemaCreatingSqliteCatalogue
::
SchemaCreatingSqliteCatalogue
(
log
::
Logger
&
log
,
const
std
::
string
&
filename
,
const
uint64_t
nbConns
,
const
uint64_t
nbArchiveFileListingConns
)
:
SqliteCatalogue
(
filename
,
nbConns
,
nbArchiveFileListingConns
)
{
SqliteCatalogue
(
log
,
filename
,
nbConns
,
nbArchiveFileListingConns
)
{
try
{
createCatalogueSchema
();
}
catch
(
exception
::
Exception
&
ex
)
{
...
...
catalogue/SchemaCreatingSqliteCatalogue.hpp
View file @
46a17f53
...
...
@@ -34,6 +34,7 @@ public:
/**
* Constructor.
*
* @param log Object representing the API to the CTA logging system.
* @param filename The filename to be passed to the sqlite3_open() function.
* @param nbConns The maximum number of concurrent connections to the
* underlying relational database for all operations accept listing archive
...
...
@@ -42,7 +43,10 @@ public:
* connections to the underlying relational database for the sole purpose of
* listing archive files.
*/
SchemaCreatingSqliteCatalogue
(
const
std
::
string
&
filename
,
const
uint64_t
nbConns
,
SchemaCreatingSqliteCatalogue
(
log
::
Logger
&
log
,
const
std
::
string
&
filename
,
const
uint64_t
nbConns
,
const
uint64_t
nbArchiveFileListingConns
);
/**
...
...
catalogue/SqliteCatalogue.cpp
View file @
46a17f53
...
...
@@ -33,9 +33,13 @@ namespace catalogue {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
SqliteCatalogue
::
SqliteCatalogue
(
const
std
::
string
&
filename
,
const
uint64_t
nbConns
,
SqliteCatalogue
::
SqliteCatalogue
(
log
::
Logger
&
log
,
const
std
::
string
&
filename
,
const
uint64_t
nbConns
,
const
uint64_t
nbArchiveFileListingConns
)
:
RdbmsCatalogue
(
log
,
rdbms
::
ConnFactoryFactory
::
create
(
rdbms
::
Login
(
rdbms
::
Login
::
DBTYPE_SQLITE
,
""
,
""
,
filename
)),
nbConns
,
nbArchiveFileListingConns
)
{
...
...
catalogue/SqliteCatalogue.hpp
View file @
46a17f53
...
...
@@ -34,6 +34,7 @@ public:
/**
* Constructor.
*
* @param log Object representing the API to the CTA logging system.
* @param filename The filename to be passed to the sqlite3_open() function.
* @param nbConns The maximum number of concurrent connections to the
* underlying relational database for all operations accept listing archive
...
...
@@ -42,7 +43,10 @@ public:
* connections to the underlying relational database for the sole purpose of
* listing archive files.
*/
SqliteCatalogue
(
const
std
::
string
&
filename
,
const
uint64_t
nbConns
,
SqliteCatalogue
(
log
::
Logger
&
log
,
const
std
::
string
&
filename
,
const
uint64_t
nbConns
,
const
uint64_t
nbArchiveFileListingConns
);
public:
...
...
common/log/DummyLogger.hpp
View file @
46a17f53
...
...
@@ -24,7 +24,7 @@ namespace cta {
namespace
log
{
/**
* A dummy logger class whose implementation of the API of the CA
STOR
logging
* A dummy logger class whose implementation of the API of the C
T
A logging
* system does nothing.
*
* The primary purpose of this class is to facilitate the unit testing of
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment