diff --git a/cmdline/CtaAdminCmd.cpp b/cmdline/CtaAdminCmd.cpp index 34176444fe31d8f5d457bcb9ac76f4e0f96b31e3..e9dc07958260de8d6abd1164d3ae9c9e23f7bd9f 100644 --- a/cmdline/CtaAdminCmd.cpp +++ b/cmdline/CtaAdminCmd.cpp @@ -62,10 +62,8 @@ void IStreamBuffer<cta::xrd::Data>::DataCallback(cta::xrd::Data record) const { case Data::kAfItemFieldNumber : switch(record.af_item().type()) { - case ArchiveFileItem::ARCHIVEFILE_LS: - CtaAdminCmd::printAfLsItem(record.af_item()); - break; - case ArchiveFileItem::LISTPENDINGARCHIVES: + case ArchiveFileItem::ARCHIVEFILE_LS: CtaAdminCmd::printAfLsItem(record.af_item()); break; + case ArchiveFileItem::LISTPENDINGARCHIVES: CtaAdminCmd::printLpaItem(record.af_item()); break; case ArchiveFileItem::LISTPENDINGRETRIEVES: default: throw std::runtime_error("Not implemented/received invalid stream data from CTA Frontend."); @@ -73,7 +71,7 @@ void IStreamBuffer<cta::xrd::Data>::DataCallback(cta::xrd::Data record) const case Data::kAfSummaryItemFieldNumber : switch(record.af_summary_item().type()) { - case ArchiveFileSummaryItem::LISTPENDINGARCHIVES: + case ArchiveFileSummaryItem::LISTPENDINGARCHIVES: CtaAdminCmd::printLpaSummaryItem(record.af_summary_item()); break; case ArchiveFileSummaryItem::LISTPENDINGRETRIEVES: default: throw std::runtime_error("Not implemented/received invalid stream data from CTA Frontend."); @@ -197,15 +195,17 @@ void CtaAdminCmd::send() const std::cout << response.message_txt(); // Print streaming response header switch(response.show_header()) { - case HeaderType::ARCHIVEFILE_LS: printAfLsHeader(); break; + case HeaderType::ARCHIVEFILE_LS: printAfLsHeader(); break; + case HeaderType::LISTPENDINGARCHIVES: printLpaHeader(); break; + case HeaderType::LISTPENDINGARCHIVES_SUMMARY: printLpaSummaryHeader(); break; case HeaderType::NONE: - default: break; + default: break; } break; - case Response::RSP_ERR_PROTOBUF: throw XrdSsiPb::PbException(response.message_txt()); + case Response::RSP_ERR_PROTOBUF: throw XrdSsiPb::PbException(response.message_txt()); case Response::RSP_ERR_USER: - case Response::RSP_ERR_CTA: throw std::runtime_error(response.message_txt()); - default: throw XrdSsiPb::PbException("Invalid response type."); + case Response::RSP_ERR_CTA: throw std::runtime_error(response.message_txt()); + default: throw XrdSsiPb::PbException("Invalid response type."); } // If there is a Data/Stream payload, wait until it has been processed before exiting @@ -404,6 +404,65 @@ void CtaAdminCmd::printAfLsItem(const cta::admin::ArchiveFileItem &af_item) << std::endl; } + + +void CtaAdminCmd::printLpaHeader() +{ + std::cout << TEXT_RED + << std::setfill(' ') << std::setw(18) << std::right << "tapepool" << ' ' + << std::setfill(' ') << std::setw(7) << std::right << "id" << ' ' + << std::setfill(' ') << std::setw(13) << std::right << "storage class" << ' ' + << std::setfill(' ') << std::setw(7) << std::right << "copy no" << ' ' + << std::setfill(' ') << std::setw(7) << std::right << "disk id" << ' ' + << std::setfill(' ') << std::setw(8) << std::right << "instance" << ' ' + << std::setfill(' ') << std::setw(13) << std::right << "checksum type" << ' ' + << std::setfill(' ') << std::setw(14) << std::right << "checksum value" << ' ' + << std::setfill(' ') << std::setw(12) << std::right << "size" << ' ' + << std::setfill(' ') << std::setw(8) << std::right << "user" << ' ' + << std::setfill(' ') << std::setw(8) << std::right << "group" << ' ' + << "path" + << TEXT_NORMAL << std::endl; +} + + + +void CtaAdminCmd::printLpaItem(const cta::admin::ArchiveFileItem &af_item) +{ + std::cout << std::setfill(' ') << std::setw(7) << std::right << af_item.af().archive_id() << ' ' + << std::setfill(' ') << std::setw(7) << std::right << af_item.copy_nb() << ' ' + << std::setfill(' ') << std::setw(7) << std::right << af_item.tf().vid() << ' ' + << std::setfill(' ') << std::setw(7) << std::right << af_item.tf().f_seq() << ' ' + << std::setfill(' ') << std::setw(8) << std::right << af_item.tf().block_id() << ' ' + << std::setfill(' ') << std::setw(8) << std::right << af_item.af().disk_instance() << ' ' + << std::setfill(' ') << std::setw(7) << std::right << af_item.af().disk_id() << ' ' + << std::setfill(' ') << std::setw(12) << std::right << af_item.af().size() << ' ' + << std::setfill(' ') << std::setw(13) << std::right << af_item.af().cs().type() << ' ' + << std::setfill(' ') << std::setw(14) << std::right << af_item.af().cs().value() << ' ' + << std::setfill(' ') << std::setw(13) << std::right << af_item.af().storage_class() << ' ' + << std::setfill(' ') << std::setw(8) << std::right << af_item.af().df().owner() << ' ' + << std::setfill(' ') << std::setw(8) << std::right << af_item.af().df().group() << ' ' + << std::setfill(' ') << std::setw(13) << std::right << af_item.af().creation_time() << ' ' + << af_item.af().df().path() + << std::endl; +} + + + +void CtaAdminCmd::printLpaSummaryHeader() +{ + std::cout << TEXT_RED + << std::setfill(' ') << std::setw(18) << std::right << "tapepool" << ' ' + << std::setfill(' ') << std::setw(13) << std::right << "total files" << ' ' + << std::setfill(' ') << std::setw(12) << std::right << "total size" << ' ' + << TEXT_NORMAL << std::endl; +} + + + +void CtaAdminCmd::printLpaSummaryItem(const cta::admin::ArchiveFileSummaryItem &af_summary_item) +{ +} + }} // namespace cta::admin diff --git a/cmdline/CtaAdminCmd.hpp b/cmdline/CtaAdminCmd.hpp index 896230bb9c0eb7119010e52ef002f7cc52c1b583..e0935cfb98c372000096d9e67e94ef1f673bb23a 100644 --- a/cmdline/CtaAdminCmd.hpp +++ b/cmdline/CtaAdminCmd.hpp @@ -34,15 +34,17 @@ public: */ void send() const; - /*! - * Print header for stream responses from "af ls" command - */ + // Static methods to format streaming responses + + // "archivefile ls" command static void printAfLsHeader(); + static void printAfLsItem(const ArchiveFileItem &af_item); - /*! - * Handle stream responses for "af ls" command - */ - static void printAfLsItem(const cta::admin::ArchiveFileItem &af_item); + // "listpendingarchives" command + static void printLpaHeader(); + static void printLpaItem(const ArchiveFileItem &af_item); + static void printLpaSummaryHeader(); + static void printLpaSummaryItem(const ArchiveFileSummaryItem &af_summary_item); private: /*! diff --git a/xroot_plugins/XrdCtaListPendingQueue.hpp b/xroot_plugins/XrdCtaListPendingQueue.hpp index dcc647c1a5e947ec165860922c45793e9d5f3a4a..d0695709f1b8f954c3ce5842799a50316e192360 100644 --- a/xroot_plugins/XrdCtaListPendingQueue.hpp +++ b/xroot_plugins/XrdCtaListPendingQueue.hpp @@ -130,14 +130,17 @@ Data ListPendingQueue<OStoreDB::ArchiveQueueItor_t>::fillRecord(const std::strin { Data record; + // Response type + record.mutable_af_item()->set_type(cta::admin::ArchiveFileItem::LISTPENDINGARCHIVES); + // Tapepool - record.mutable_af_ls_item()->set_tapepool(tapepool); + record.mutable_af_item()->set_tapepool(tapepool); // Copy number - record.mutable_af_ls_item()->set_copy_nb(job.copyNumber); + record.mutable_af_item()->set_copy_nb(job.copyNumber); // Archive file - auto af = record.mutable_af_ls_item()->mutable_af(); + auto af = record.mutable_af_item()->mutable_af(); af->set_archive_id(job.archiveFileID); af->set_disk_instance(job.instanceName); af->set_disk_id(job.request.diskFileID); @@ -150,41 +153,6 @@ Data ListPendingQueue<OStoreDB::ArchiveQueueItor_t>::fillRecord(const std::strin af->mutable_df()->set_path(job.request.diskFileInfo.path); #if 0 - if(m_isExtended) - { - - } else { - auto lpa = record.mutable_lpa_summary(); - lpa->set_ - } -#endif -#if 0 - // Copy number - record.mutable_af_ls_item()->set_copy_nb(jt->first); - - // Archive file - auto af = record.mutable_af_ls_item()->mutable_af(); - af->set_archive_id(archiveFile.archiveFileID); - af->set_disk_instance(archiveFile.diskInstance); - af->set_disk_id(archiveFile.diskFileId); - af->set_size(archiveFile.fileSize); - af->mutable_cs()->set_type(archiveFile.checksumType); - af->mutable_cs()->set_value(archiveFile.checksumValue); - af->set_storage_class(archiveFile.storageClass); - af->mutable_df()->set_owner(archiveFile.diskFileInfo.owner); - af->mutable_df()->set_group(archiveFile.diskFileInfo.group); - af->mutable_df()->set_path(archiveFile.diskFileInfo.path); - af->set_creation_time(archiveFile.creationTime); - - // Tape file - auto tf = record.mutable_af_ls_item()->mutable_tf(); - tf->set_vid(jt->second.vid); - tf->set_f_seq(jt->second.fSeq); - tf->set_block_id(jt->second.blockId); -#endif -#if 0 - std::map<std::string, std::list<cta::common::dataStructures::ArchiveJob>> result; - if(has_flag(OptionBoolean::EXTENDED)) { for(auto it = result.cbegin(); it != result.cend(); it++) { diff --git a/xroot_plugins/XrdSsiCtaRequestMessage.cpp b/xroot_plugins/XrdSsiCtaRequestMessage.cpp index f07d7381b4bd7b3b5c1d48012e5d83d8ce262639..219883bb8f62a11c24a83c9a771186d2a52fdbee 100644 --- a/xroot_plugins/XrdSsiCtaRequestMessage.cpp +++ b/xroot_plugins/XrdSsiCtaRequestMessage.cpp @@ -1216,8 +1216,6 @@ void RequestMessage::processListPendingArchives(const cta::admin::AdminCmd &admi { using namespace cta::admin; - std::stringstream cmdlineOutput; - // Search filter criteria auto tapepool = getOptional(OptionString::TAPE_POOL); @@ -1225,32 +1223,15 @@ void RequestMessage::processListPendingArchives(const cta::admin::AdminCmd &admi stream = new ListPendingQueue<OStoreDB::ArchiveQueueItor_t>(has_flag(OptionBoolean::EXTENDED), m_scheddb.getArchiveJobItor(tapepool ? tapepool.value() : "")); - // Send the column headers in the metadata + // Should the client display column headers? if(has_flag(OptionBoolean::SHOW_HEADER)) { if(has_flag(OptionBoolean::EXTENDED)) { - cmdlineOutput << TEXT_RED - << std::setfill(' ') << std::setw(18) << std::right << "tapepool" << ' ' - << std::setfill(' ') << std::setw(7) << std::right << "id" << ' ' - << std::setfill(' ') << std::setw(13) << std::right << "storage class" << ' ' - << std::setfill(' ') << std::setw(7) << std::right << "copy no" << ' ' - << std::setfill(' ') << std::setw(7) << std::right << "disk id" << ' ' - << std::setfill(' ') << std::setw(8) << std::right << "instance" << ' ' - << std::setfill(' ') << std::setw(13) << std::right << "checksum type" << ' ' - << std::setfill(' ') << std::setw(14) << std::right << "checksum value" << ' ' - << std::setfill(' ') << std::setw(12) << std::right << "size" << ' ' - << std::setfill(' ') << std::setw(8) << std::right << "user" << ' ' - << std::setfill(' ') << std::setw(8) << std::right << "group" << ' ' - << "path" << TEXT_NORMAL; + response.set_show_header(HeaderType::LISTPENDINGARCHIVES); } else { - cmdlineOutput << TEXT_RED - << std::setfill(' ') << std::setw(18) << std::right << "tapepool" << ' ' - << std::setfill(' ') << std::setw(13) << std::right << "total files" << ' ' - << std::setfill(' ') << std::setw(12) << std::right << "total size" << ' ' - << TEXT_NORMAL; + response.set_show_header(HeaderType::LISTPENDINGARCHIVES_SUMMARY); } } - response.set_message_txt(cmdlineOutput.str()); response.set_type(cta::xrd::Response::RSP_SUCCESS); }