diff --git a/cmdline/EosCtaStub.cpp b/cmdline/EosCtaStub.cpp index 3e70e6602c6cecd6fa229558d6c3893656447742..015bcf5ec8e73f43ff24e44e87ed6e0837f7b7fd 100644 --- a/cmdline/EosCtaStub.cpp +++ b/cmdline/EosCtaStub.cpp @@ -36,7 +36,7 @@ namespace XrdSsiPb { /*! * Alert callback. * - * Defines how Alert messages should be logged by EOS or directed to the User. + * Defines how Alert messages should be logged by EOS (or directed to the User) */ template<> @@ -247,8 +247,7 @@ void fillNotification(eos::wfe::Notification ¬ification, bool &isStderr, bool int exceptionThrowingMain(int argc, const char *const *const argv) { - // Verify that the version of the Google Protocol Buffer library that we linked against is - // compatible with the version of the headers we compiled against + // Verify that the Google Protocol Buffer header and linked library versions are compatible GOOGLE_PROTOBUF_VERIFY_VERSION; diff --git a/eos/messages/eos_messages.proto b/eos/messages/eos_messages.proto index 3fb6c963f8975b8e746c8106abecbcd54f28bd36..6c247277b78181e90eda257c8e3f79d4ce125de0 100644 --- a/eos/messages/eos_messages.proto +++ b/eos/messages/eos_messages.proto @@ -109,8 +109,7 @@ message Response { enum ResponseType { RSP_SUCCESS = 0; //< Notification was queued successfully RSP_ERR_PROTOBUF = 1; //< Framework error caused by Google Protocol Buffers layer - RSP_ERR_XROOT = 2; //< Framework error caused by XRoot protocol layer - RSP_ERR_CTA = 3; //< Server error reported by CTA Frontend + RSP_ERR_CTA = 2; //< Server error reported by CTA Frontend } ResponseType rsp_type = 1; //< Encode the type of this reply Alert alert_msg = 2; //< Text of the reply diff --git a/xroot_plugins/XrdSsiCtaRequestProc.cpp b/xroot_plugins/XrdSsiCtaRequestProc.cpp index 66430dbeee4dc19555a98d27b60ea2566f7438da..d7d85166d9039d1bc46f05d82b7654c7a26755b2 100644 --- a/xroot_plugins/XrdSsiCtaRequestProc.cpp +++ b/xroot_plugins/XrdSsiCtaRequestProc.cpp @@ -46,57 +46,70 @@ namespace XrdSsiPb { template <> void RequestProc<eos::wfe::Notification, eos::wfe::Response, eos::wfe::Alert>::ExecuteAction() { - // Instantiate the scheduler + try + { + // Instantiate the scheduler - const cta::rdbms::Login catalogueLogin = cta::rdbms::Login::parseFile("/etc/cta/cta_catalogue_db.conf"); - const uint64_t nbConns = 10; - const uint64_t nbArchiveFileListingConns = 2; + const cta::rdbms::Login catalogueLogin = cta::rdbms::Login::parseFile("/etc/cta/cta_catalogue_db.conf"); + const uint64_t nbConns = 10; + const uint64_t nbArchiveFileListingConns = 2; - std::unique_ptr<cta::catalogue::Catalogue> my_catalogue = cta::catalogue::CatalogueFactory::create(catalogueLogin, nbConns, nbArchiveFileListingConns); - cta::common::Configuration ctaConf("/etc/cta/cta-frontend.conf"); - std::string backend_str = ctaConf.getConfEntString("ObjectStore", "BackendPath", nullptr); + std::unique_ptr<cta::catalogue::Catalogue> my_catalogue = cta::catalogue::CatalogueFactory::create(catalogueLogin, nbConns, nbArchiveFileListingConns); + cta::common::Configuration ctaConf("/etc/cta/cta-frontend.conf"); + std::string backend_str = ctaConf.getConfEntString("ObjectStore", "BackendPath", nullptr); - std::unique_ptr<cta::objectstore::Backend> backend(cta::objectstore::BackendFactory::createBackend(backend_str)); - cta::objectstore::BackendPopulator backendPopulator(*backend, "Frontend"); - cta::OStoreDBWithAgent scheddb(*backend, backendPopulator.getAgentReference()); + std::unique_ptr<cta::objectstore::Backend> backend(cta::objectstore::BackendFactory::createBackend(backend_str)); + cta::objectstore::BackendPopulator backendPopulator(*backend, "Frontend"); + cta::OStoreDBWithAgent scheddb(*backend, backendPopulator.getAgentReference()); - cta::Scheduler *scheduler = new cta::Scheduler(*my_catalogue, scheddb, 5, 2*1000*1000); - cta::log::StdoutLogger log("ctafrontend"); - cta::log::LogContext lc(log); + cta::Scheduler *scheduler = new cta::Scheduler(*my_catalogue, scheddb, 5, 2*1000*1000); + cta::log::StdoutLogger log("ctafrontend"); + cta::log::LogContext lc(log); - // Output message in Json format (for debugging) + // Output message in Json format (for debugging) + + std::cerr << "Received message:" << std::endl; + OutputJsonString(std::cerr, &m_request); + + // Unpack message - std::cerr << "Received message:" << std::endl; - OutputJsonString(std::cerr, &m_request); + cta::common::dataStructures::UserIdentity originator; + originator.name = m_request.cli().user().username(); + originator.group = m_request.cli().user().groupname(); - // Unpack message + cta::common::dataStructures::DiskFileInfo diskFileInfo; + diskFileInfo.owner = m_request.file().owner().username(); + diskFileInfo.group = m_request.file().owner().groupname(); + diskFileInfo.path = m_request.file().lpath(); - cta::common::dataStructures::UserIdentity originator; - originator.name = m_request.cli().user().username(); - originator.group = m_request.cli().user().groupname(); + cta::common::dataStructures::ArchiveRequest request; + request.checksumType = m_request.file().cks().name(); + request.checksumValue = m_request.file().cks().value(); + request.diskFileInfo = diskFileInfo; + request.diskFileID = m_request.file().fid(); + request.fileSize = m_request.file().size(); + request.requester = originator; + request.srcURL = m_request.wf().instance().url(); + request.storageClass = m_request.file().xattr().at("CTA_StorageClass"); + request.archiveReportURL = "null:"; - cta::common::dataStructures::DiskFileInfo diskFileInfo; - diskFileInfo.owner = m_request.file().owner().username(); - diskFileInfo.group = m_request.file().owner().groupname(); - diskFileInfo.path = m_request.file().lpath(); + std::string client_username = m_request.cli().user().username(); - cta::common::dataStructures::ArchiveRequest request; - request.checksumType = m_request.file().cks().name(); - request.checksumValue = m_request.file().cks().value(); - request.diskFileInfo = diskFileInfo; - request.diskFileID = m_request.file().fid(); - request.fileSize = m_request.file().size(); - request.requester = originator; - request.srcURL = m_request.wf().instance().url(); - request.storageClass = m_request.file().xattr().at("CTA_StorageClass"); - request.archiveReportURL = "null:"; + // Queue the request - std::string client_username = m_request.cli().user().username(); + uint64_t archiveFileId = scheduler->queueArchive(client_username, request, lc); + std::cout << "<eos::wfe::path::fxattr:sys.archiveFileId>" << archiveFileId << std::endl; - // Queue the request + // Set metadata - uint64_t archiveFileId = scheduler->queueArchive(client_username, request, lc); - std::cout << "<eos::wfe::path::fxattr:sys.archiveFileId>" << archiveFileId << std::endl; + m_metadata.set_rsp_type(eos::wfe::Response::RSP_SUCCESS); + } + catch(std::exception &ex) + { + m_metadata.set_rsp_type(eos::wfe::Response::RSP_ERR_CTA); + m_metadata.mutable_alert_msg()->set_audience(eos::wfe::Alert::EOSLOG); + m_metadata.mutable_alert_msg()->set_message_txt(ex.what()); + } #if 0 // Set reply @@ -126,10 +139,6 @@ void RequestProc<eos::wfe::Notification, eos::wfe::Response, eos::wfe::Alert>::E template <> void RequestProc<eos::wfe::Notification, eos::wfe::Response, eos::wfe::Alert>::ExecuteMetadata() { - // Set metadata - - m_metadata.set_rsp_type(eos::wfe::Response::RSP_SUCCESS); - // Output message in Json format (for debugging) std::cerr << "Preparing metadata..." << std::endl; diff --git a/xroot_ssi_pb/XrdSsiPbRequestProc.h b/xroot_ssi_pb/XrdSsiPbRequestProc.h index 2ad89b177c72b7bc1d424f07e3c7b6609c000287..57e80d491bda93a96970faea154dcc8b4f5eef57 100644 --- a/xroot_ssi_pb/XrdSsiPbRequestProc.h +++ b/xroot_ssi_pb/XrdSsiPbRequestProc.h @@ -163,15 +163,6 @@ void RequestProc<RequestType, MetadataType, AlertType>::Execute() SetMetadata(m_metadata_str.c_str(), m_metadata_str.size()); } -#if 0 - // Serialize the Response - - if(!m_response.SerializeToString(&m_response_str)) - { - throw PbException("m_response.SerializeToString() failed"); - } -#endif - // Send the response. This must always be called, even if the response is empty, as Finished() // will not be called until the Response has been processed.