From f6ab3a82d8b0598cc81acc575c443e4f120fb1f0 Mon Sep 17 00:00:00 2001 From: Michael Davis <michael.davis@cern.ch> Date: Tue, 28 Nov 2017 11:42:14 +0100 Subject: [PATCH] [ssi_af_ls] Implements client-side callback --- cmdline/CtaAdminCmd.cpp | 31 +++++++++++++++++++++ xroot_plugins/XrdCtaArchiveFileLs.hpp | 10 +++---- xroot_ssi_pb/XrdSsiPbIStreamBuffer.hpp | 37 -------------------------- 3 files changed, 36 insertions(+), 42 deletions(-) diff --git a/cmdline/CtaAdminCmd.cpp b/cmdline/CtaAdminCmd.cpp index 7bd87a7de0..4dddedf670 100644 --- a/cmdline/CtaAdminCmd.cpp +++ b/cmdline/CtaAdminCmd.cpp @@ -44,6 +44,37 @@ void RequestCallback<cta::xrd::Alert>::operator()(const cta::xrd::Alert &alert) OutputJsonString(std::cout, &alert); } + + +/*! + * Data/Stream callback. + * + * Defines how incoming records from the stream should be handled + */ +template<> +void IStreamBuffer<cta::xrd::Data>::DataCallback(cta::xrd::Data record) +{ + const cta::admin::ArchiveFileLsItem &af_ls_item = record.af_ls_item(); + + OutputJsonString(std::cout, &af_ls_item); + + std::cout << std::setfill(' ') << std::setw(7) << std::right << af_ls_item.af().archive_file_id() << ' ' + << std::setfill(' ') << std::setw(7) << std::right << af_ls_item.copy_nb() << ' ' + << std::setfill(' ') << std::setw(7) << std::right << af_ls_item.tf().vid() << ' ' + << std::setfill(' ') << std::setw(7) << std::right << af_ls_item.tf().f_seq() << ' ' + << std::setfill(' ') << std::setw(8) << std::right << af_ls_item.tf().block_id() << ' ' + << std::setfill(' ') << std::setw(8) << std::right << af_ls_item.af().disk_instance() << ' ' + << std::setfill(' ') << std::setw(7) << std::right << af_ls_item.af().disk_file_id() << ' ' + << std::setfill(' ') << std::setw(12) << std::right << af_ls_item.af().file_size() << ' ' + << std::setfill(' ') << std::setw(13) << std::right << af_ls_item.af().cs().type() << ' ' + << std::setfill(' ') << std::setw(14) << std::right << af_ls_item.af().cs().value() << ' ' + << std::setfill(' ') << std::setw(13) << std::right << af_ls_item.af().storage_class() << ' ' + << std::setfill(' ') << std::setw(8) << std::right << af_ls_item.af().df().owner() << ' ' + << std::setfill(' ') << std::setw(8) << std::right << af_ls_item.af().df().group() << ' ' + << std::setfill(' ') << std::setw(13) << std::right << af_ls_item.af().creation_time() << ' ' + << af_ls_item.af().df().path() << std::endl; +} + } // namespace XrdSsiPb diff --git a/xroot_plugins/XrdCtaArchiveFileLs.hpp b/xroot_plugins/XrdCtaArchiveFileLs.hpp index 10fa001295..d3fca5b1dc 100644 --- a/xroot_plugins/XrdCtaArchiveFileLs.hpp +++ b/xroot_plugins/XrdCtaArchiveFileLs.hpp @@ -70,13 +70,13 @@ tmp_num_items = 0; } // Get the next item and pass it back to the caller - cta::admin::ArchiveFileLsItem item; - item.mutable_af()->set_disk_instance("Hello"); - item.mutable_af()->set_disk_file_id("World"); - item.set_copy_nb(++tmp_num_items); + cta::xrd::Data record; + record.mutable_af_ls_item()->mutable_af()->set_disk_instance("Hello"); + record.mutable_af_ls_item()->mutable_af()->set_disk_file_id("World"); + record.mutable_af_ls_item()->set_copy_nb(++tmp_num_items); XrdSsiPb::OStreamBuffer *streambuf = new XrdSsiPb::OStreamBuffer(); - dlen = streambuf->serialize(item); + dlen = streambuf->serialize(record); std::cerr << "Returning buffer with " << dlen << " bytes of data." << std::endl; diff --git a/xroot_ssi_pb/XrdSsiPbIStreamBuffer.hpp b/xroot_ssi_pb/XrdSsiPbIStreamBuffer.hpp index 4cef8d0792..bf9d579f8a 100644 --- a/xroot_ssi_pb/XrdSsiPbIStreamBuffer.hpp +++ b/xroot_ssi_pb/XrdSsiPbIStreamBuffer.hpp @@ -196,42 +196,5 @@ std::cout << "[POP_RECORD] Saving split of 4+" << buf_len << " bytes" << std::en } } - - -#if 0 -/*! - * Data callback. - * - * Defines how Data/Stream messages should be handled - */ -template<> -void XrdSsiPbRequestType::DataCallback(XrdSsiRequest::PRD_Xeq &post_process, char *response_bufptr, int response_buflen) -{ - IStreamBuffer istream; - - istream.push(response_bufptr, response_buflen); - google::protobuf::io::CodedInputStream coded_stream(reinterpret_cast<const uint8_t*>(response_bufptr), response_buflen); - - - //OutputJsonString(std::cout, &line_item); - - std::cout << std::setfill(' ') << std::setw(7) << std::right << line_item.af().archive_file_id() << ' ' - << std::setfill(' ') << std::setw(7) << std::right << line_item.copy_nb() << ' ' - << std::setfill(' ') << std::setw(7) << std::right << line_item.tf().vid() << ' ' - << std::setfill(' ') << std::setw(7) << std::right << line_item.tf().f_seq() << ' ' - << std::setfill(' ') << std::setw(8) << std::right << line_item.tf().block_id() << ' ' - << std::setfill(' ') << std::setw(8) << std::right << line_item.af().disk_instance() << ' ' - << std::setfill(' ') << std::setw(7) << std::right << line_item.af().disk_file_id() << ' ' - << std::setfill(' ') << std::setw(12) << std::right << line_item.af().file_size() << ' ' - << std::setfill(' ') << std::setw(13) << std::right << line_item.af().cs().type() << ' ' - << std::setfill(' ') << std::setw(14) << std::right << line_item.af().cs().value() << ' ' - << std::setfill(' ') << std::setw(13) << std::right << line_item.af().storage_class() << ' ' - << std::setfill(' ') << std::setw(8) << std::right << line_item.af().df().owner() << ' ' - << std::setfill(' ') << std::setw(8) << std::right << line_item.af().df().group() << ' ' - << std::setfill(' ') << std::setw(13) << std::right << line_item.af().creation_time() << ' ' - << line_item.af().df().path() << std::endl; -} -#endif - } // namespace XrdSsiPb -- GitLab