Skip to content
GitLab
Menu
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
e04c8a2a
Commit
e04c8a2a
authored
Jun 23, 2016
by
Steven Murray
Browse files
Added catalogue::TapeSearchCriteria
parent
276a91e0
Changes
6
Hide whitespace changes
Inline
Side-by-side
catalogue/Catalogue.hpp
View file @
e04c8a2a
...
...
@@ -22,6 +22,7 @@
#include
"catalogue/ArchiveFileSearchCriteria.hpp"
#include
"catalogue/TapeFileWritten.hpp"
#include
"catalogue/TapeForWriting.hpp"
#include
"catalogue/TapeSearchCriteria.hpp"
#include
"common/dataStructures/AdminHost.hpp"
#include
"common/dataStructures/AdminUser.hpp"
#include
"common/dataStructures/ArchiveFile.hpp"
...
...
@@ -124,8 +125,16 @@ public:
virtual
void
createTape
(
const
common
::
dataStructures
::
SecurityIdentity
&
cliIdentity
,
const
std
::
string
&
vid
,
const
std
::
string
&
logicalLibraryName
,
const
std
::
string
&
tapePoolName
,
const
std
::
string
&
encryptionKey
,
const
uint64_t
capacityInBytes
,
const
bool
disabledValue
,
const
bool
fullValue
,
const
std
::
string
&
comment
)
=
0
;
virtual
void
deleteTape
(
const
std
::
string
&
vid
)
=
0
;
virtual
std
::
list
<
common
::
dataStructures
::
Tape
>
getTapes
(
const
std
::
string
&
vid
,
const
std
::
string
&
logicalLibraryName
,
const
std
::
string
&
tapePoolName
,
const
std
::
string
&
capacityInBytes
,
const
std
::
string
&
disabledValue
,
const
std
::
string
&
fullValue
,
const
std
::
string
&
busyValue
,
const
std
::
string
&
lbpValue
)
=
0
;
/**
* Returns the list of tapes that meet the specified search criteria.
*
* @param searchCriteria The search criteria.
* @return The list of tapes.
*/
virtual
std
::
list
<
common
::
dataStructures
::
Tape
>
getTapes
(
const
TapeSearchCriteria
&
searchCriteria
=
TapeSearchCriteria
())
const
=
0
;
virtual
void
reclaimTape
(
const
common
::
dataStructures
::
SecurityIdentity
&
cliIdentity
,
const
std
::
string
&
vid
)
=
0
;
virtual
void
modifyTapeLogicalLibraryName
(
const
common
::
dataStructures
::
SecurityIdentity
&
cliIdentity
,
const
std
::
string
&
vid
,
const
std
::
string
&
logicalLibraryName
)
=
0
;
virtual
void
modifyTapeTapePoolName
(
const
common
::
dataStructures
::
SecurityIdentity
&
cliIdentity
,
const
std
::
string
&
vid
,
const
std
::
string
&
tapePoolName
)
=
0
;
...
...
catalogue/InMemoryCatalogueTest.cpp
View file @
e04c8a2a
...
...
@@ -90,7 +90,7 @@ protected:
}
}
{
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
);
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
();
for
(
auto
&
tape
:
tapes
)
{
m_catalogue
->
deleteTape
(
tape
.
vid
);
}
...
...
@@ -947,7 +947,7 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, deleteLogicalLibrary_non_existant) {
TEST_F
(
cta_catalogue_InMemoryCatalogueTest
,
createTape
)
{
using
namespace
cta
;
ASSERT_TRUE
(
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
).
empty
());
ASSERT_TRUE
(
m_catalogue
->
getTapes
().
empty
());
const
std
::
string
vid
=
"vid"
;
const
std
::
string
logicalLibraryName
=
"logical_library_name"
;
...
...
@@ -966,7 +966,7 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, createTape) {
comment
);
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
);
m_catalogue
->
getTapes
();
ASSERT_EQ
(
1
,
tapes
.
size
());
...
...
@@ -1014,7 +1014,7 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, createTape_same_twice) {
TEST_F
(
cta_catalogue_InMemoryCatalogueTest
,
deleteTape
)
{
using
namespace
cta
;
ASSERT_TRUE
(
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
).
empty
());
ASSERT_TRUE
(
m_catalogue
->
getTapes
().
empty
());
const
std
::
string
vid
=
"vid"
;
const
std
::
string
logicalLibraryName
=
"logical_library_name"
;
...
...
@@ -1033,7 +1033,7 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, deleteTape) {
comment
);
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
);
m_catalogue
->
getTapes
();
ASSERT_EQ
(
1
,
tapes
.
size
());
...
...
@@ -1056,20 +1056,20 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, deleteTape) {
ASSERT_EQ
(
creationLog
,
lastModificationLog
);
m_catalogue
->
deleteTape
(
tape
.
vid
);
ASSERT_TRUE
(
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
).
empty
());
ASSERT_TRUE
(
m_catalogue
->
getTapes
().
empty
());
}
TEST_F
(
cta_catalogue_InMemoryCatalogueTest
,
deleteTape_non_existant
)
{
using
namespace
cta
;
ASSERT_TRUE
(
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
).
empty
());
ASSERT_TRUE
(
m_catalogue
->
getTapes
().
empty
());
ASSERT_THROW
(
m_catalogue
->
deleteTape
(
"non_exsitant_tape"
),
catalogue
::
UserError
);
}
TEST_F
(
cta_catalogue_InMemoryCatalogueTest
,
getTapesForWriting
)
{
using
namespace
cta
;
ASSERT_TRUE
(
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
).
empty
());
ASSERT_TRUE
(
m_catalogue
->
getTapes
().
empty
());
const
std
::
string
vid
=
"vid"
;
const
std
::
string
logicalLibraryName
=
"logical_library_name"
;
...
...
@@ -1829,7 +1829,7 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, prepareForNewFile_requester_mount_ru
TEST_F
(
cta_catalogue_InMemoryCatalogueTest
,
prepareToRetrieveFile
)
{
using
namespace
cta
;
ASSERT_TRUE
(
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
).
empty
());
ASSERT_TRUE
(
m_catalogue
->
getTapes
().
empty
());
const
std
::
string
vid1
=
"VID123"
;
const
std
::
string
vid2
=
"VID456"
;
...
...
@@ -1848,7 +1848,7 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, prepareToRetrieveFile) {
m_catalogue
->
createTape
(
m_cliSI
,
vid2
,
logicalLibraryName
,
tapePoolName
,
encryptionKey
,
capacityInBytes
,
disabledValue
,
fullValue
,
createTapeComment
);
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
);
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
();
const
std
::
map
<
std
::
string
,
common
::
dataStructures
::
Tape
>
vidToTape
=
tapeListToMap
(
tapes
);
{
auto
it
=
vidToTape
.
find
(
vid1
);
...
...
@@ -2062,7 +2062,7 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, fileWrittenToTape_many_archive_files
m_catalogue
->
createTape
(
m_cliSI
,
vid
,
logicalLibraryName
,
tapePoolName
,
encryptionKey
,
capacityInBytes
,
disabledValue
,
fullValue
,
comment
);
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
);
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
();
ASSERT_EQ
(
1
,
tapes
.
size
());
...
...
@@ -2118,7 +2118,7 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, fileWrittenToTape_many_archive_files
fileWritten
.
copyNb
=
1
;
m_catalogue
->
fileWrittenToTape
(
fileWritten
);
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
);
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
();
ASSERT_EQ
(
1
,
tapes
.
size
());
const
common
::
dataStructures
::
Tape
&
tape
=
tapes
.
front
();
ASSERT_EQ
(
vid
,
tape
.
vid
);
...
...
@@ -2296,7 +2296,7 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, fileWrittenToTape_2_tape_files_diffe
comment
);
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
);
m_catalogue
->
getTapes
();
ASSERT_EQ
(
2
,
tapes
.
size
());
...
...
@@ -2371,7 +2371,9 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, fileWrittenToTape_2_tape_files_diffe
m_catalogue
->
fileWrittenToTape
(
file1Written
);
{
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
file1Written
.
vid
,
""
,
""
,
""
,
""
,
""
,
""
,
""
);
catalogue
::
TapeSearchCriteria
searchCriteria
;
searchCriteria
.
vid
=
file1Written
.
vid
;
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
searchCriteria
);
ASSERT_EQ
(
1
,
tapes
.
size
());
const
common
::
dataStructures
::
Tape
&
tape
=
tapes
.
front
();
ASSERT_EQ
(
1
,
tape
.
lastFSeq
);
...
...
@@ -2420,8 +2422,10 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, fileWrittenToTape_2_tape_files_diffe
m_catalogue
->
fileWrittenToTape
(
file2Written
);
{
ASSERT_EQ
(
2
,
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
).
size
());
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
file2Written
.
vid
,
""
,
""
,
""
,
""
,
""
,
""
,
""
);
ASSERT_EQ
(
2
,
m_catalogue
->
getTapes
().
size
());
catalogue
::
TapeSearchCriteria
searchCriteria
;
searchCriteria
.
vid
=
file2Written
.
vid
;
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
searchCriteria
);
ASSERT_EQ
(
1
,
tapes
.
size
());
const
common
::
dataStructures
::
Tape
&
tape
=
tapes
.
front
();
ASSERT_EQ
(
1
,
tape
.
lastFSeq
);
...
...
@@ -2483,7 +2487,7 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, fileWrittenToTape_2_tape_files_same_
comment
);
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
);
m_catalogue
->
getTapes
();
ASSERT_EQ
(
1
,
tapes
.
size
());
...
...
@@ -2538,7 +2542,9 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, fileWrittenToTape_2_tape_files_same_
m_catalogue
->
fileWrittenToTape
(
file1Written
);
{
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
file1Written
.
vid
,
""
,
""
,
""
,
""
,
""
,
""
,
""
);
catalogue
::
TapeSearchCriteria
searchCriteria
;
searchCriteria
.
vid
=
file1Written
.
vid
;
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
searchCriteria
);
ASSERT_EQ
(
1
,
tapes
.
size
());
const
common
::
dataStructures
::
Tape
&
tape
=
tapes
.
front
();
ASSERT_EQ
(
1
,
tape
.
lastFSeq
);
...
...
@@ -2607,7 +2613,7 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, fileWrittenToTape_2_tape_files_corru
comment
);
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
);
m_catalogue
->
getTapes
();
ASSERT_EQ
(
1
,
tapes
.
size
());
...
...
@@ -2726,7 +2732,7 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, deleteArchiveFile) {
comment
);
const
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
);
m_catalogue
->
getTapes
();
ASSERT_EQ
(
2
,
tapes
.
size
());
...
...
@@ -2801,7 +2807,9 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, deleteArchiveFile) {
m_catalogue
->
fileWrittenToTape
(
file1Written
);
{
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
file1Written
.
vid
,
""
,
""
,
""
,
""
,
""
,
""
,
""
);
catalogue
::
TapeSearchCriteria
searchCriteria
;
searchCriteria
.
vid
=
file1Written
.
vid
;
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
searchCriteria
);
ASSERT_EQ
(
1
,
tapes
.
size
());
const
common
::
dataStructures
::
Tape
&
tape
=
tapes
.
front
();
ASSERT_EQ
(
1
,
tape
.
lastFSeq
);
...
...
@@ -2881,8 +2889,10 @@ TEST_F(cta_catalogue_InMemoryCatalogueTest, deleteArchiveFile) {
m_catalogue
->
fileWrittenToTape
(
file2Written
);
{
ASSERT_EQ
(
2
,
m_catalogue
->
getTapes
(
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
).
size
());
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
file2Written
.
vid
,
""
,
""
,
""
,
""
,
""
,
""
,
""
);
ASSERT_EQ
(
2
,
m_catalogue
->
getTapes
().
size
());
catalogue
::
TapeSearchCriteria
searchCriteria
;
searchCriteria
.
vid
=
file2Written
.
vid
;
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
=
m_catalogue
->
getTapes
(
searchCriteria
);
ASSERT_EQ
(
1
,
tapes
.
size
());
const
common
::
dataStructures
::
Tape
&
tape
=
tapes
.
front
();
ASSERT_EQ
(
1
,
tape
.
lastFSeq
);
...
...
catalogue/RdbmsCatalogue.cpp
View file @
e04c8a2a
...
...
@@ -25,6 +25,7 @@
#include
"common/exception/Exception.hpp"
#include
"common/utils/utils.hpp"
#include
<ctype.h>
#include
<iostream>
#include
<memory>
#include
<time.h>
...
...
@@ -32,6 +33,39 @@
namespace
cta
{
namespace
catalogue
{
namespace
{
/**
* Returns an all upper-case version of the specified string.
*
* @param str The string to be copied into an all upper case version of itself.
* @return An all upper-case version of the specified string.
*/
std
::
string
toUpper
(
const
std
::
string
&
str
)
{
std
::
string
upperStr
;
for
(
auto
c
:
str
)
{
upperStr
+=
toupper
(
c
);
}
return
upperStr
;
}
/**
* Returns true of the specified string in considered to be a valid
* representation of a boolean value.
*
* @param str The string to be tested.
* @return True if the specified string is a valid representation of a boolean value.
*/
bool
isValidBool
(
const
std
::
string
&
str
)
{
const
std
::
string
upperStr
=
toUpper
(
str
);
return
upperStr
==
"TRUE"
||
upperStr
==
"FALSE"
;
}
}
// anonymous namespace
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
...
...
@@ -1190,15 +1224,7 @@ void RdbmsCatalogue::deleteTape(const std::string &vid) {
//------------------------------------------------------------------------------
// getTapes
//------------------------------------------------------------------------------
std
::
list
<
common
::
dataStructures
::
Tape
>
RdbmsCatalogue
::
getTapes
(
const
std
::
string
&
vid
,
const
std
::
string
&
logicalLibraryName
,
const
std
::
string
&
tapePoolName
,
const
std
::
string
&
capacityInBytes
,
const
std
::
string
&
disabledValue
,
const
std
::
string
&
fullValue
,
const
std
::
string
&
busyValue
,
const
std
::
string
&
lbpValue
)
{
std
::
list
<
common
::
dataStructures
::
Tape
>
RdbmsCatalogue
::
getTapes
(
const
TapeSearchCriteria
&
searchCriteria
)
const
{
try
{
std
::
list
<
common
::
dataStructures
::
Tape
>
tapes
;
std
::
string
sql
=
...
...
@@ -1232,63 +1258,73 @@ std::list<common::dataStructures::Tape> RdbmsCatalogue::getTapes(
"LAST_UPDATE_USER_NAME AS LAST_UPDATE_USER_NAME,"
"LAST_UPDATE_HOST_NAME AS LAST_UPDATE_HOST_NAME,"
"LAST_UPDATE_TIME AS LAST_UPDATE_TIME "
"FROM "
"FROM "
"TAPE"
;
if
(
!
(
vid
.
empty
()
&&
logicalLibraryName
.
empty
()
&&
tapePoolName
.
empty
()
&&
capacityInBytes
.
empty
()
&&
disabledValue
.
empty
()
&&
fullValue
.
empty
()
&&
busyValue
.
empty
()
&&
lbpValue
.
empty
()))
{
searchCriteria
.
vid
.
empty
()
&&
searchCriteria
.
logicalLibrary
.
empty
()
&&
searchCriteria
.
tapePool
.
empty
()
&&
searchCriteria
.
capacityInBytes
.
empty
()
&&
searchCriteria
.
isDisabled
.
empty
()
&&
searchCriteria
.
isFull
.
empty
()
&&
searchCriteria
.
lbpIsOn
.
empty
()))
{
sql
+=
" WHERE "
;
}
bool
addedAWhereConstraint
=
false
;
if
(
!
vid
.
empty
())
{
if
(
!
searchCriteria
.
vid
.
empty
())
{
sql
+=
" VID = :VID"
;
addedAWhereConstraint
=
true
;
}
if
(
!
logicalLibrary
Name
.
empty
())
{
if
(
!
searchCriteria
.
logicalLibrary
.
empty
())
{
if
(
addedAWhereConstraint
)
sql
+=
" AND "
;
sql
+=
" LOGICAL_LIBRARY_NAME = :LOGICAL_LIBRARY_NAME"
;
addedAWhereConstraint
=
true
;
}
if
(
!
tapePool
Name
.
empty
())
{
if
(
!
searchCriteria
.
tapePool
.
empty
())
{
if
(
addedAWhereConstraint
)
sql
+=
" AND "
;
sql
+=
" TAPE_POOL_NAME = :TAPE_POOL_NAME"
;
addedAWhereConstraint
=
true
;
}
if
(
!
capacityInBytes
.
empty
())
{
if
(
!
utils
::
isValidUInt
(
capacityInBytes
))
{
throw
exception
::
Exception
(
capacityInBytes
+
" is not a
n
unsigned integer"
);
if
(
!
searchCriteria
.
capacityInBytes
.
empty
())
{
if
(
!
utils
::
isValidUInt
(
searchCriteria
.
capacityInBytes
))
{
throw
UserError
(
"Capacity in bytes "
+
searchCriteria
.
capacityInBytes
+
" is not a
valid
unsigned integer"
);
}
if
(
addedAWhereConstraint
)
sql
+=
" AND "
;
sql
+=
" CAPACITY_IN_BYTES = :CAPACITY_IN_BYTES"
;
}
if
(
!
d
isabled
Value
.
empty
())
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: Search by disabledValue in not supported"
);
}
if
(
!
fullValue
.
empty
())
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
"
failed: Search by fullValue in not supported"
)
;
if
(
!
searchCriteria
.
isD
isabled
.
empty
())
{
if
(
!
isValidBool
(
searchCriteria
.
isDisabled
))
{
throw
UserError
(
"Disabled tapes search criterion "
+
searchCriteria
.
isDisabled
+
" is not a valid boolean"
);
}
sql
+
=
"
IS_DISABLED = :IS_DISABLED"
;
}
if
(
!
busyValue
.
empty
())
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: Search by busyValue in not supported"
);
if
(
!
searchCriteria
.
isFull
.
empty
())
{
if
(
!
isValidBool
(
searchCriteria
.
isFull
))
{
throw
UserError
(
"Full tapes search criterion "
+
searchCriteria
.
isFull
+
" is not a valid boolean"
);
}
sql
+=
" IS_FULL = :IS_FULL"
;
}
if
(
!
lbpValue
.
empty
())
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: Search by lbpValue in not supported"
);
if
(
!
searchCriteria
.
lbpIsOn
.
empty
())
{
if
(
!
isValidBool
(
searchCriteria
.
lbpIsOn
))
{
throw
UserError
(
"LBP search criterion "
+
searchCriteria
.
lbpIsOn
+
" is not a valid boolean"
);
}
sql
+=
" LBP_IS_ON = :LBP_IS_ON"
;
}
std
::
unique_ptr
<
DbStmt
>
stmt
(
m_conn
->
createStmt
(
sql
));
if
(
!
vid
.
empty
())
stmt
->
bindString
(
":VID"
,
vid
);
if
(
!
logicalLibraryName
.
empty
())
stmt
->
bindString
(
":LOGICAL_LIBRARY_NAME"
,
logicalLibraryName
);
if
(
!
tapePoolName
.
empty
())
stmt
->
bindString
(
":TAPE_POOL_NAME"
,
tapePoolName
);
if
(
!
capacityInBytes
.
empty
())
stmt
->
bindUint64
(
":CAPACITY_IN_BYTES"
,
utils
::
toUint64
(
capacityInBytes
));
if
(
!
searchCriteria
.
vid
.
empty
())
stmt
->
bindString
(
":VID"
,
searchCriteria
.
vid
);
if
(
!
searchCriteria
.
logicalLibrary
.
empty
())
stmt
->
bindString
(
":LOGICAL_LIBRARY_NAME"
,
searchCriteria
.
logicalLibrary
);
if
(
!
searchCriteria
.
tapePool
.
empty
())
stmt
->
bindString
(
":TAPE_POOL_NAME"
,
searchCriteria
.
tapePool
);
if
(
!
searchCriteria
.
capacityInBytes
.
empty
())
stmt
->
bindUint64
(
":CAPACITY_IN_BYTES"
,
utils
::
toUint64
(
searchCriteria
.
capacityInBytes
));
if
(
!
searchCriteria
.
isDisabled
.
empty
())
stmt
->
bindUint64
(
":IS_DISABLED"
,
toUpper
(
searchCriteria
.
isDisabled
)
==
"TRUE"
);
if
(
!
searchCriteria
.
isFull
.
empty
())
stmt
->
bindUint64
(
":IS_FULL"
,
toUpper
(
searchCriteria
.
isFull
)
==
"TRUE"
);
if
(
!
searchCriteria
.
lbpIsOn
.
empty
())
stmt
->
bindUint64
(
":LBP_IS_ON"
,
toUpper
(
searchCriteria
.
lbpIsOn
)
==
"TRUE"
);
std
::
unique_ptr
<
DbRset
>
rset
(
stmt
->
executeQuery
());
while
(
rset
->
next
())
{
...
...
@@ -2409,6 +2445,10 @@ std::list<common::dataStructures::ArchiveFile> RdbmsCatalogue::getArchiveFilesFo
"WHERE "
"ARCHIVE_FILE.ARCHIVE_FILE_ID >= :STARTING_ARCHIVE_FILE_ID"
;
if
(
!
searchCriteria
.
archiveFileId
.
empty
())
{
if
(
!
utils
::
isValidUInt
(
searchCriteria
.
archiveFileId
))
{
throw
UserError
(
std
::
string
(
"Archive file ID "
)
+
searchCriteria
.
archiveFileId
+
" is not a valid unsigned integer"
);
}
sql
+=
" AND ARCHIVE_FILE.ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID"
;
}
if
(
!
searchCriteria
.
diskInstance
.
empty
())
{
...
...
@@ -2433,6 +2473,10 @@ std::list<common::dataStructures::ArchiveFile> RdbmsCatalogue::getArchiveFilesFo
sql
+=
" AND TAPE_FILE.VID = :VID"
;
}
if
(
!
searchCriteria
.
tapeFileCopyNb
.
empty
())
{
if
(
!
utils
::
isValidUInt
(
searchCriteria
.
tapeFileCopyNb
))
{
throw
UserError
(
std
::
string
(
"Tape-file copy-number "
)
+
searchCriteria
.
tapeFileCopyNb
+
" is not a valid unsigned integer"
);
}
sql
+=
" AND TAPE_FILE.COPY_NB = :TAPE_FILE_COPY_NB"
;
}
if
(
!
searchCriteria
.
tapePool
.
empty
())
{
...
...
catalogue/RdbmsCatalogue.hpp
View file @
e04c8a2a
...
...
@@ -103,8 +103,15 @@ public:
virtual
void
createTape
(
const
common
::
dataStructures
::
SecurityIdentity
&
cliIdentity
,
const
std
::
string
&
vid
,
const
std
::
string
&
logicalLibraryName
,
const
std
::
string
&
tapePoolName
,
const
std
::
string
&
encryptionKey
,
const
uint64_t
capacityInBytes
,
const
bool
disabledValue
,
const
bool
fullValue
,
const
std
::
string
&
comment
);
virtual
void
deleteTape
(
const
std
::
string
&
vid
);
virtual
std
::
list
<
common
::
dataStructures
::
Tape
>
getTapes
(
const
std
::
string
&
vid
,
const
std
::
string
&
logicalLibraryName
,
const
std
::
string
&
tapePoolName
,
const
std
::
string
&
capacityInBytes
,
const
std
::
string
&
disabledValue
,
const
std
::
string
&
fullValue
,
const
std
::
string
&
busyValue
,
const
std
::
string
&
lbpValue
);
/**
* Returns the list of tapes that meet the specified search criteria.
*
* @param searchCriteria The search criteria.
* @return The list of tapes.
*/
virtual
std
::
list
<
common
::
dataStructures
::
Tape
>
getTapes
(
const
TapeSearchCriteria
&
searchCriteria
)
const
;
virtual
void
reclaimTape
(
const
common
::
dataStructures
::
SecurityIdentity
&
cliIdentity
,
const
std
::
string
&
vid
);
virtual
void
modifyTapeLogicalLibraryName
(
const
common
::
dataStructures
::
SecurityIdentity
&
cliIdentity
,
const
std
::
string
&
vid
,
const
std
::
string
&
logicalLibraryName
);
virtual
void
modifyTapeTapePoolName
(
const
common
::
dataStructures
::
SecurityIdentity
&
cliIdentity
,
const
std
::
string
&
vid
,
const
std
::
string
&
tapePoolName
);
...
...
catalogue/TapeSearchCriteria.hpp
0 → 100644
View file @
e04c8a2a
/*
* 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
<string>
namespace
cta
{
namespace
catalogue
{
/**
* The collection of criteria used to select a set of tapes.
*
* A tape is selected if it meets all of the specified criteria.
*
* A criterion is only considered specified if it has been set.
*
* Please note that no wild cards, for example '*' or '%', are supported.
*/
struct
TapeSearchCriteria
{
/**
* The volume identifier of a tape.
*/
std
::
string
vid
;
/**
* The name of a logical library.
*/
std
::
string
logicalLibrary
;
/**
* The name of a tape pool.
*/
std
::
string
tapePool
;
/**
* The capacity of a tape in bytes
*/
std
::
string
capacityInBytes
;
/**
* Set to true if searching for disabled tapes.
*/
std
::
string
isDisabled
;
/**
* Set to true if searching for full tapes.
*/
std
::
string
isFull
;
/**
* Set to true if searching for tapes with logical block protection enabled.
*/
std
::
string
lbpIsOn
;
};
// struct TapeSearchCriteria
}
// namespace catalogue
}
// namespace cta
xroot_plugins/XrdCtaFile.cpp
View file @
e04c8a2a
...
...
@@ -873,39 +873,31 @@ int XrdCtaFile::xCom_tape() {
std
::
string
capacity
=
getOptionValue
(
"-c"
,
"--capacity"
,
false
);
if
((
hasOption
(
"-e"
,
"--enabled"
)
&&
hasOption
(
"-d"
,
"--disabled"
))
||
(
hasOption
(
"-f"
,
"--free"
)
&&
hasOption
(
"-F"
,
"--full"
))
// TODO BUSY IS GONE!!!!!
||
(
hasOption
(
"-b"
,
"--busy"
)
&&
hasOption
(
"-n"
,
"--notbusy"
))
||
(
hasOption
(
"-p"
,
"--lbp"
)
&&
hasOption
(
"-P"
,
"--nolbp"
)))
{
return
logRequestAndSetCmdlineResult
(
cta
::
common
::
dataStructures
::
FrontendReturnCode
::
userErrorNoRetry
,
help
.
str
());
}
std
::
string
disabled
=
""
;
std
::
string
full
=
""
;
std
::
string
busy
=
""
;
std
::
string
lbp
=
""
;
cta
::
catalogue
::
TapeSearchCriteria
searchCriteria
;
if
(
hasOption
(
"-e"
,
"--enabled"
))
{
d
isabled
=
"false"
;
searchCriteria
.
isD
isabled
=
"false"
;
}
if
(
hasOption
(
"-d"
,
"--disabled"
))
{
d
isabled
=
"true"
;
searchCriteria
.
isD
isabled
=
"true"
;
}
if
(
hasOption
(
"-f"
,
"--free"
))
{
f
ull
=
"false"
;
searchCriteria
.
isF
ull
=
"false"
;
}
if
(
hasOption
(
"-F"
,
"--full"
))
{
full
=
"true"
;
}
if
(
hasOption
(
"-b"
,
"--busy"
))
{
busy
=
"false"
;
}
if
(
hasOption
(
"-n"
,
"--notbusy"
))
{
busy
=
"true"
;
searchCriteria
.
isFull
=
"true"
;
}
if
(
hasOption
(
"-p"
,
"--lbp"
))
{
lbp
=
"fals
e"
;
searchCriteria
.
lbpIsOn
=
"tru
e"
;
}
if
(
hasOption
(
"-P"
,
"--nolbp"
))
{
lbp
=
"tru
e"
;
searchCriteria
.
lbpIsOn
=
"fals
e"
;
}
std
::
list
<
cta
::
common
::
dataStructures
::
Tape
>
list
=
m_catalogue
->
getTapes
(
vid
,
logicallibrary
,
tapepool
,
capacity
,
disabled
,
full
,
busy
,
lbp
);
std
::
list
<
cta
::
common
::
dataStructures
::
Tape
>
list
=
m_catalogue
->
getTapes
(
searchCriteria
);
if
(
list
.
size
()
>
0
)
{
std
::
vector
<
std
::
vector
<
std
::
string
>>
responseTable
;
std
::
vector
<
std
::
string
>
header
=
{
"vid"
,
"logical library"
,
"tapepool"
,
"encription key"
,
"capacity"
,
"occupancy"
,
"last fseq"
,
"busy"
,
"full"
,
"disabled"
,
"lpb"
,
"label drive"
,
"label time"
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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