Commit 056fd79c authored by Steven Murray's avatar Steven Murray
Browse files

[Catalogue] operations#179 Slow `cta-admin sq` even when there is very little activity

Fixed the count of writable tapes.  The previous commit counted incorrectly if
a tape had more than one state bit set to true (disabled, full and readonly).
parent b9c1cc60
......@@ -1916,6 +1916,154 @@ TEST_P(cta_catalogue_CatalogueTest, createTapePool_vo_does_not_exist) {
exception::UserError);
}
 
TEST_P(cta_catalogue_CatalogueTest, createTapePool_tapes_of_mixed_state) {
using namespace cta;
const bool logicalLibraryIsDisabled= false;
const uint64_t nbPartialTapes = 2;
const bool isEncrypted = true;
const cta::optional<std::string> supply("value for the supply pool mechanism");
m_catalogue->createMediaType(m_admin, m_mediaType);
m_catalogue->createLogicalLibrary(m_admin, m_tape1.logicalLibraryName, logicalLibraryIsDisabled, "Create logical library");
m_catalogue->createVirtualOrganization(m_admin, m_vo);
m_catalogue->createTapePool(m_admin, m_tape1.tapePoolName, m_vo.name, nbPartialTapes, isEncrypted, supply, "Create tape pool");
{
const auto pools = m_catalogue->getTapePools();
ASSERT_EQ(1, pools.size());
const auto &pool = pools.front();
ASSERT_EQ(m_tape1.tapePoolName, pool.name);
ASSERT_EQ(m_vo.name, pool.vo.name);
ASSERT_EQ(0, pool.nbTapes);
ASSERT_EQ(0, pool.capacityBytes);
ASSERT_EQ(0, pool.dataBytes);
ASSERT_EQ(0, pool.nbPhysicalFiles);
}
m_catalogue->createTape(m_admin, m_tape1);
auto tape_disabled_01 = m_tape1;
tape_disabled_01.vid = "D000001";
tape_disabled_01.disabled = true;
m_catalogue->createTape(m_admin, tape_disabled_01);
auto tape_disabled_02 = m_tape1;
tape_disabled_02.vid = "D000002";
tape_disabled_02.disabled = true;
m_catalogue->createTape(m_admin, tape_disabled_02);
auto tape_full_01 = m_tape1;
tape_full_01.vid = "F000001";
tape_full_01.full = true;
m_catalogue->createTape(m_admin, tape_full_01);
auto tape_full_02 = m_tape1;
tape_full_02.vid = "F000002";
tape_full_02.full = true;
m_catalogue->createTape(m_admin, tape_full_02);
auto tape_full_03 = m_tape1;
tape_full_03.vid = "F000003";
tape_full_03.full = true;
m_catalogue->createTape(m_admin, tape_full_03);
auto tape_readOnly_01 = m_tape1;
tape_readOnly_01.vid = "RO00001";
tape_readOnly_01.readOnly = true;
m_catalogue->createTape(m_admin, tape_readOnly_01);
auto tape_readOnly_02 = m_tape1;
tape_readOnly_02.vid = "RO00002";
tape_readOnly_02.readOnly = true;
m_catalogue->createTape(m_admin, tape_readOnly_02);
auto tape_readOnly_03 = m_tape1;
tape_readOnly_03.vid = "RO00003";
tape_readOnly_03.readOnly = true;
m_catalogue->createTape(m_admin, tape_readOnly_03);
auto tape_readOnly_04 = m_tape1;
tape_readOnly_04.vid = "RO00004";
tape_readOnly_04.readOnly = true;
m_catalogue->createTape(m_admin, tape_readOnly_04);
auto tape_disabled_full_readOnly_01 = m_tape1;
tape_disabled_full_readOnly_01.vid = "DFRO001";
tape_disabled_full_readOnly_01.disabled = true;
tape_disabled_full_readOnly_01.full = true;
tape_disabled_full_readOnly_01.readOnly = true;
m_catalogue->createTape(m_admin, tape_disabled_full_readOnly_01);
auto tape_disabled_full_readOnly_02 = m_tape1;
tape_disabled_full_readOnly_02.vid = "DFRO002";
tape_disabled_full_readOnly_02.disabled = true;
tape_disabled_full_readOnly_02.full = true;
tape_disabled_full_readOnly_02.readOnly = true;
m_catalogue->createTape(m_admin, tape_disabled_full_readOnly_02);
auto tape_disabled_full_readOnly_03 = m_tape1;
tape_disabled_full_readOnly_03.vid = "DFRO003";
tape_disabled_full_readOnly_03.disabled = true;
tape_disabled_full_readOnly_03.full = true;
tape_disabled_full_readOnly_03.readOnly = true;
m_catalogue->createTape(m_admin, tape_disabled_full_readOnly_03);
auto tape_disabled_full_readOnly_04 = m_tape1;
tape_disabled_full_readOnly_04.vid = "DFRO004";
tape_disabled_full_readOnly_04.disabled = true;
tape_disabled_full_readOnly_04.full = true;
tape_disabled_full_readOnly_04.readOnly = true;
m_catalogue->createTape(m_admin, tape_disabled_full_readOnly_04);
auto tape_disabled_full_readOnly_05 = m_tape1;
tape_disabled_full_readOnly_05.vid = "DFRO005";
tape_disabled_full_readOnly_05.disabled = true;
tape_disabled_full_readOnly_05.full = true;
tape_disabled_full_readOnly_05.readOnly = true;
m_catalogue->createTape(m_admin, tape_disabled_full_readOnly_05);
const auto tapes = m_catalogue->getTapes();
ASSERT_EQ(15, tapes.size());
{
const auto pools = m_catalogue->getTapePools();
ASSERT_EQ(1, pools.size());
const auto &pool = pools.front();
ASSERT_EQ(m_tape1.tapePoolName, pool.name);
ASSERT_EQ(m_vo.name, pool.vo.name);
ASSERT_EQ(15, pool.nbTapes);
ASSERT_EQ(15, pool.nbEmptyTapes);
ASSERT_EQ(7, pool.nbDisabledTapes);
ASSERT_EQ(8, pool.nbFullTapes);
ASSERT_EQ(9, pool.nbReadOnlyTapes);
ASSERT_EQ(1, pool.nbWritableTapes);
ASSERT_EQ(15 * m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(0, pool.dataBytes);
ASSERT_EQ(0, pool.nbPhysicalFiles);
}
{
const auto pool = m_catalogue->getTapePool(m_tape1.tapePoolName);
ASSERT_TRUE((bool)pool);
ASSERT_EQ(m_tape1.tapePoolName, pool->name);
ASSERT_EQ(m_vo.name, pool->vo.name);
ASSERT_EQ(15, pool->nbTapes);
ASSERT_EQ(15, pool->nbEmptyTapes);
ASSERT_EQ(7, pool->nbDisabledTapes);
ASSERT_EQ(8, pool->nbFullTapes);
ASSERT_EQ(9, pool->nbReadOnlyTapes);
ASSERT_EQ(1, pool->nbWritableTapes);
ASSERT_EQ(15 * m_mediaType.capacityInBytes, pool->capacityBytes);
ASSERT_EQ(0, pool->dataBytes);
ASSERT_EQ(0, pool->nbPhysicalFiles);
}
}
TEST_P(cta_catalogue_CatalogueTest, deleteTapePool) {
using namespace cta;
 
......@@ -9198,6 +9346,7 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(1, pool.nbWritableTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(0, pool.dataBytes);
ASSERT_EQ(0, pool.nbPhysicalFiles);
......@@ -9222,6 +9371,7 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(1, pool.nbWritableTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(0, pool.dataBytes);
ASSERT_EQ(0, pool.nbPhysicalFiles);
......@@ -9339,6 +9489,7 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(1, pool.nbWritableTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
......@@ -9402,6 +9553,7 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(1, pool.nbWritableTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
......@@ -10020,6 +10172,7 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(1, pool.nbWritableTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
......@@ -10041,6 +10194,7 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
ASSERT_EQ(1, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(0, pool.nbWritableTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
......@@ -10062,6 +10216,7 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(1, pool.nbWritableTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
......@@ -10083,6 +10238,7 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(1, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(0, pool.nbWritableTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
......@@ -10104,6 +10260,7 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(1, pool.nbWritableTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
......@@ -10125,6 +10282,7 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(1, pool.nbReadOnlyTapes);
ASSERT_EQ(0, pool.nbWritableTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
......@@ -10146,6 +10304,7 @@ TEST_P(cta_catalogue_CatalogueTest, filesWrittenToTape_many_archive_files) {
ASSERT_EQ(0, pool.nbDisabledTapes);
ASSERT_EQ(0, pool.nbFullTapes);
ASSERT_EQ(0, pool.nbReadOnlyTapes);
ASSERT_EQ(1, pool.nbWritableTapes);
ASSERT_EQ(m_mediaType.capacityInBytes, pool.capacityBytes);
ASSERT_EQ(nbArchiveFiles * archiveFileSize, pool.dataBytes);
ASSERT_EQ(nbArchiveFiles, pool.nbPhysicalFiles);
......
......@@ -1995,6 +1995,7 @@ std::list<TapePool> RdbmsCatalogue::getTapePools() const {
"COALESCE(SUM(CASE WHEN TAPE.IS_DISABLED <> '0' THEN 1 ELSE 0 END), 0) AS NB_DISABLED_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_FULL <> '0' THEN 1 ELSE 0 END), 0) AS NB_FULL_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_READ_ONLY <> '0' THEN 1 ELSE 0 END), 0) AS NB_READ_ONLY_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_DISABLED = '0' AND TAPE.IS_FULL = '0' AND TAPE.IS_READ_ONLY = '0' THEN 1 ELSE 0 END), 0) AS NB_WRITABLE_TAPES,"
"COALESCE(SUM(MEDIA_TYPE.CAPACITY_IN_BYTES), 0) AS CAPACITY_IN_BYTES,"
"COALESCE(SUM(TAPE.DATA_IN_BYTES), 0) AS DATA_IN_BYTES,"
"COALESCE(SUM(TAPE.LAST_FSEQ), 0) AS NB_PHYSICAL_FILES,"
......@@ -2048,6 +2049,7 @@ std::list<TapePool> RdbmsCatalogue::getTapePools() const {
pool.nbDisabledTapes = rset.columnUint64("NB_DISABLED_TAPES");
pool.nbFullTapes = rset.columnUint64("NB_FULL_TAPES");
pool.nbReadOnlyTapes = rset.columnUint64("NB_READ_ONLY_TAPES");
pool.nbWritableTapes = rset.columnUint64("NB_WRITABLE_TAPES");
pool.capacityBytes = rset.columnUint64("CAPACITY_IN_BYTES");
pool.dataBytes = rset.columnUint64("DATA_IN_BYTES");
pool.nbPhysicalFiles = rset.columnUint64("NB_PHYSICAL_FILES");
......@@ -2089,6 +2091,7 @@ cta::optional<TapePool> RdbmsCatalogue::getTapePool(const std::string &tapePoolN
"COALESCE(SUM(CASE WHEN TAPE.IS_DISABLED <> '0' THEN 1 ELSE 0 END), 0) AS NB_DISABLED_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_FULL <> '0' THEN 1 ELSE 0 END), 0) AS NB_FULL_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_READ_ONLY <> '0' THEN 1 ELSE 0 END), 0) AS NB_READ_ONLY_TAPES,"
"COALESCE(SUM(CASE WHEN TAPE.IS_DISABLED = '0' AND TAPE.IS_FULL = '0' AND TAPE.IS_READ_ONLY = '0' THEN 1 ELSE 0 END), 0) AS NB_WRITABLE_TAPES,"
"COALESCE(SUM(MEDIA_TYPE.CAPACITY_IN_BYTES), 0) AS CAPACITY_IN_BYTES,"
"COALESCE(SUM(TAPE.DATA_IN_BYTES), 0) AS DATA_IN_BYTES,"
"COALESCE(SUM(TAPE.LAST_FSEQ), 0) AS NB_PHYSICAL_FILES,"
......@@ -2148,6 +2151,7 @@ cta::optional<TapePool> RdbmsCatalogue::getTapePool(const std::string &tapePoolN
pool.nbDisabledTapes = rset.columnUint64("NB_DISABLED_TAPES");
pool.nbFullTapes = rset.columnUint64("NB_FULL_TAPES");
pool.nbReadOnlyTapes = rset.columnUint64("NB_READ_ONLY_TAPES");
pool.nbWritableTapes = rset.columnUint64("NB_WRITABLE_TAPES");
pool.capacityBytes = rset.columnUint64("CAPACITY_IN_BYTES");
pool.dataBytes = rset.columnUint64("DATA_IN_BYTES");
pool.nbPhysicalFiles = rset.columnUint64("NB_PHYSICAL_FILES");
......
......@@ -33,6 +33,7 @@ TapePool::TapePool():
nbDisabledTapes(0),
nbFullTapes(0),
nbReadOnlyTapes(0),
nbWritableTapes(0),
capacityBytes(0),
dataBytes(0),
nbPhysicalFiles(0) {
......
......@@ -100,6 +100,11 @@ struct TapePool {
*/
uint64_t nbReadOnlyTapes;
/**
* The total number of writable tapes in the pool.
*/
uint64_t nbWritableTapes;
/**
* The total capacity of all the tapes in the pool in bytes.
*/
......
......@@ -1652,11 +1652,7 @@ std::list<common::dataStructures::QueueAndMountSummary> Scheduler::getQueuesAndM
mountOrQueue.disabledTapes = tapePool->nbDisabledTapes;
mountOrQueue.fullTapes = tapePool->nbFullTapes;
mountOrQueue.readOnlyTapes = tapePool->nbReadOnlyTapes;
// Please note that archived and exported tapes are NOT taken into account
// for the moment because they are not currently supported
const auto nbNonWritableTape = tapePool->nbDisabledTapes + tapePool->nbFullTapes + tapePool->nbReadOnlyTapes;
mountOrQueue.writableTapes =
(tapePool->nbTapes >= nbNonWritableTape) ? tapePool->nbTapes - nbNonWritableTape : 0;
mountOrQueue.writableTapes = tapePool->nbWritableTapes;
}
} else if (common::dataStructures::MountType::Retrieve==mountOrQueue.mountType) {
// Get info for this tape.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment